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