AVPlayer在模拟器上工作但在真实设备上崩溃

时间:2017-02-07 05:21:09

标签: swift avplayer

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

    }

0 个答案:

没有答案