当我从后台到前台时,AVPlayerControllerTimeResolver实例被取消分配

时间:2017-02-13 11:34:36

标签: ios swift avplayer avplayerviewcontroller

大家好我在播放视频时面临一个奇怪的问题,当我从背景到前景时,AVPlayerControllerTimeResolver实例正在被解除分配。

我的错误日志如下 -

  

**由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'实例0x170251610   类的AVPlayerControllerTimeResolver在键时被释放   价值观察员仍在注册。目前的观察   信息:(   上下文:0x1b31fa9a0,属性:0x17424e2b0>   上下文:0x1b31fa9a8,属性:0x17024ea90>上下文:0x1b31fa9b0,属性:0x1702507a0>    上下文:0x1b31fa9b8,属性:0x170250050> )'

这是我的代码 -

@IBAction func play(_ sender: Any) {
let videoURL = NSURL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
    let player = AVPlayer(url: videoURL! as URL)
    self.avpplayerController = AVPlayerViewController()
    avpplayerController?.player = player
    self.present(avpplayerController!, animated: true) {
        self.avpplayerController?.player!.play()
    }
}

0 个答案:

没有答案