【发布时间】:2020-12-23 00:16:56
【问题描述】:
我有不同的UIViews 一个在另一个之上;他们每个人都使用AVPlayer 播放视频
我需要在最后重播每个视频,为此我使用以下代码:
NotificationCenter.default.addObserver(self, selector: #selector(playerDidReachEnd), name: .AVPlayerItemDidPlayToEndTime, object: self.player.currentItem)
@objc fileprivate func playerDidReachEnd(){
self.player.seek(to: .zero)
self.player.play()
}
I noticed that when the selector is called, all the other players in the other UIViews start playing as well...
这对我来说很奇怪,因为我将观察者的对象设置为只有 self.player.currentItem
我怎样才能只播放这个AVPlayer?
【问题讨论】:
标签: swift uiview avplayer nsnotificationcenter