Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 检测AVQueuePlayer中的视频项目何时更改_Ios_Swift - Fatal编程技术网

Ios 检测AVQueuePlayer中的视频项目何时更改

Ios 检测AVQueuePlayer中的视频项目何时更改,ios,swift,Ios,Swift,在我的项目中,我使用AVQueuePlayer播放多个视频,在某些情况下,我想知道当前项目何时完成,下一个项目何时开始。我使用如下的Noftification: NotificationCenter.default.addObserver(self, selector: #selector(self.goToStepTwo), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: self.player?.currentI

在我的项目中,我使用AVQueuePlayer播放多个视频,在某些情况下,我想知道当前项目何时完成,下一个项目何时开始。我使用如下的Noftification:

NotificationCenter.default.addObserver(self, selector: #selector(self.goToStepTwo), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: self.player?.currentItem)
但这种方法只适用于第一项

感谢使用

.addObserver(self, selector: #selector(self.goToStepTwo), name: .AVPlayerItemDidPlayToEndTime, object: self.player?.currentItem)
您明确要求在
self.player?.currentItem
播放到最后时通知您

要获得任何项目的通知,只需使用
nil
作为
对象

.addObserver(self, selector: #selector(self.goToStepTwo), name: .AVPlayerItemDidPlayToEndTime, object: nil)

obj

观察者希望接收其通知的对象;也就是说,只有此发件人发送的通知才会传递给观察者

如果通过
nil
,通知中心不会使用通知的发送者来决定是否将其发送给观察者