所以我试图从这个项目源中编辑一些源代码...... https://github.com/ariiyu/VideoPlayerSample
所以,当我只是尝试替换视频路径和文件时,它崩溃了,我不知道为什么?
这是 ViewController 源代码之一...
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.
}
}