大家好我在播放视频时面临一个奇怪的问题,当我从背景到前景时,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()
}
}