如果我有一个AVPlayer,则可以监视AVPlayerItemDidPlayToEndTime
。但是,如果我有两个AVPlayers,我将不知道哪个完成了。有没有办法知道哪个完成?
答案 0 :(得分:2)
您可以尝试
@objc func playerDidFinishPlaying( _ sender: Notification) {
if let _ = sender.object as? Player1 {
}
}
NotificationCenter.default.addObserver(self, selector: #selector(playerDidFinishPlaying(_:)) , name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: nil)