0
所以我想编辑从本项目源一些源代码... https://github.com/ariiyu/VideoPlayerSampleAVPlayerViewController发出
所以,当我只是简单地尝试更换视频路径和文件崩溃,我不知道为什么?
这里是视图控制器源代码中的一个......
import UIKit
import AVFoundation
import AVKit
class SecondViewController: AVPlayerViewController {
override func viewDidLoad() {
super.viewDidLoad()
// I try to replace the string with my movie file here and crashes
let moviePath = NSBundle.mainBundle().pathForResource("hogevideo", ofType: "mp4")!
let url = NSURL(fileURLWithPath: moviePath)
let playerItem = AVPlayerItem(URL: url)
player = AVPlayer(playerItem: playerItem)
player.play()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
确保您的文件存在。 – Bannings
我其实只是想通了......我没有设置文件来定位项目。不过谢谢 – user3708224