gpt4 book ai didi

ios - AVPlayerItemDidPlayToEndTimeNotification 未触发

转载 作者:搜寻专家 更新时间:2023-10-30 21:48:23 26 4
gpt4 key购买 nike

我正在使用 AVPlayer 从 url 播放视频。 AVPlayerItemDidPlayToEndTimeNotification 未触发。我已经把断点检查了。下面是我的代码片段:-

    @IBAction func playButtonClicked(sender: UIButton) {
let url:NSURL = NSURL(string: self.currentSelectedContent.link)!
moviePlayer = AVPlayer(URL: url)
playerViewController = AVPlayerViewController()
playerViewController.player = moviePlayer

self.presentViewController(playerViewController, animated: true) {
NSNotificationCenter.defaultCenter().addObserver(self, selector: "moviePlayBackFinished", name: AVPlayerItemDidPlayToEndTimeNotification, object: self.moviePlayer)
self.playerViewController.player?.play()
}

}

func moviePlayBackFinished() {
self.playerViewController.dismissViewControllerAnimated(true, completion: nil)
}

最佳答案

根据文档,观察对象必须是 AVPlayerItem 实例,而不是 AVPlayer 本身。尝试将 self.movi​​ePlayer 更改为 self.movi​​ePlayer.currentItem

关于ios - AVPlayerItemDidPlayToEndTimeNotification 未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33871179/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com