AVPlayer在模拟器中正常工作但在设备上崩溃。卡住请帮帮忙。
override func viewDidAppear(animated: Bool) {
let fileURL = NSURL(string: NSUserDefaults.standardUserDefaults().objectForKey("introVideoURl") as! String)
playVideo(fileURL!) // crashing line
}
func playVideo(url: NSURL) throws-> AnyObject{
let player = AVPlayer(URL: url)
playerController.player = player
self.addChildViewController(playerController)
self.view.addSubview(playerController.view)
playerController.view.frame = self.view.frame
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(introVideoController.playerDidFinishPlaying(_:)),
name: AVPlayerItemDidPlayToEndTimeNotification, object: player.currentItem)
player.play()
return true
}