swift AVPlayerItemDidPlayToEndTimeNotification 无效
swift AVPlayerItemDidPlayToEndTimeNotification not work
我创建了一个class,名为DecryptAudioPlayer,它继承了NSObject,这个class引用了一个AVPlayer,观察下面init.like时的通知AVPlayerItemDidPlayToEndTimeNotification:
override init() {
super.init()
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.playToEnd(_:)), name: AVPlayerItemDidPlayToEndTimeNotification, object: nil)
}
我有方法:
func playToEnd(notification:NSNotification) {
Log.printLog("notification:\(notification)")
}
但有时播放器无法收到 AVPlayerItemDidPlayToEndTimeNotification,我很confused.it 似乎 AVPlayerItem 可能不会 post AVPlayerItemDidPlayToEndTimeNotification 结束时间,谁能告诉我为什么?
我可以得到停滞的通知来解决问题。所以这个问题可以暂时放下
我创建了一个class,名为DecryptAudioPlayer,它继承了NSObject,这个class引用了一个AVPlayer,观察下面init.like时的通知AVPlayerItemDidPlayToEndTimeNotification:
override init() {
super.init()
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.playToEnd(_:)), name: AVPlayerItemDidPlayToEndTimeNotification, object: nil)
}
我有方法:
func playToEnd(notification:NSNotification) {
Log.printLog("notification:\(notification)")
}
但有时播放器无法收到 AVPlayerItemDidPlayToEndTimeNotification,我很confused.it 似乎 AVPlayerItem 可能不会 post AVPlayerItemDidPlayToEndTimeNotification 结束时间,谁能告诉我为什么?
我可以得到停滞的通知来解决问题。所以这个问题可以暂时放下