gpt4 book ai didi

ios - 视频无法在 iPhone 上播放

转载 作者:行者123 更新时间:2023-11-28 06:42:33 24 4
gpt4 key购买 nike

enter image description here我刚刚有一个简单的视频。当我在模拟器中运行该应用程序时,视频会播放,但当我在我的 iPhone 上运行它时,它说视频丢失。非常感谢任何帮助!

这是我的代码:

import UIKit
import AVKit
import AVFoundation

class ViewController: UIViewController {

var playerviewcontroller = AVPlayerViewController()
var playerview = AVPlayer ()

@IBAction func playMusic(sender: AnyObject) {
var fileURL = NSURL(fileURLWithPath:"/Users/MorganEvans/Documents/Apps/32134.mp4")
playerview = AVPlayer(URL: fileURL)

playerviewcontroller.player = playerview

self.presentViewController(playerviewcontroller, animated: true){

self.playerviewcontroller.player?.play()
}


}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

}

最佳答案

视频文件应该像这样添加到 Xcode 项目中:

enter image description here

然后你可以这样获取视频的url:

let movieURL = NSBundle.mainBundle().URLForResource("ElephantSeals", withExtension: "mov")!

关于ios - 视频无法在 iPhone 上播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37568570/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com