gpt4 book ai didi

ios - AVPlayer 中断通知不起作用

转载 作者:行者123 更新时间:2023-11-28 13:27:57 27 4
gpt4 key购买 nike

我正在使用 avplayer 通知来处理中断,但似乎没有触发通知

 private func setupNotifications() {
let notificationCenter = NotificationCenter.default
notificationCenter.addObserver(self, selector: #selector(handleInterruption), name: AVAudioSession.interruptionNotification, object: nil)
notificationCenter.addObserver(self, selector: #selector(playerDidRecieveError(_:)), name: .AVPlayerItemNewErrorLogEntry, object: nil)
notificationCenter.addObserver(self, selector: #selector(playerDidRecieveError(_:)), name: .AVPlayerItemFailedToPlayToEndTime , object: nil)
notificationCenter.addObserver(self, selector: #selector(playerDidRecieveError(_:)), name: .AVPlayerItemPlaybackStalled , object: nil)
}

最佳答案

我正在使用类似的东西:

NotificationCenter.default.addObserver(self, selector:#selector(self.playerDidFinishPlaying(note:)),name: NSNotification.Name.AVPlayerItemNewErrorLogEntry, object: player?.currentItem)

NotificationCenter.default.addObserver(self, selector:#selector(self.playerDidFinishPlaying(note:)),name: NSNotification.Name.AVPlayerItemFailedToPlayToEndTime, object: player?.currentItem)

NotificationCenter.default.addObserver(self, selector:#selector(self.playerDidFinishPlaying(note:)),name: NSNotification.Name.AVPlayerItemPlaybackStalled, object: player?.currentItem)

NotificationCenter.default.addObserver(self, selector:#selector(self.playerDidFinishPlaying(note:)),name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: player?.currentItem)

@objc func playerDidFinishPlaying(note: NSNotification){
print("Finished")
}

关于ios - AVPlayer 中断通知不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58029500/

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