【发布时间】:2019-10-01 15:09:35
【问题描述】:
我正在使用AVPlayer 在我的 iOS 应用程序中播放音频(因为我正在播放的音频文件不是本地的),当我的曲目完成时,我想隐藏 InfoCenter 控件,但我收到此错误:
AVAudioSession.mm:1079:-[AVAudioSession setActive:withOptions:error:]: Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session.
不过,我之前暂停了我的AVPlayer。
这是我的代码:
player.pause()
player.replaceCurrentItem(with: nil)
MPNowPlayingInfoCenter.default().nowPlayingInfo = nil
try? audioSession.setActive(false, options: .notifyOthersOnDeactivation)
由于此错误,本机控件仍然可见,但不再起作用。
【问题讨论】:
-
嗯...这对我没有帮助。我没有使用队列.. 我只有一个
AVPlayer一次播放一首曲目... -
我猜this link 会帮你解决这个问题。
-
如果你停止而不是暂停怎么办?
-
@matt AVPlayer 没有像 AVAudioPlayer 那样的停止功能
标签: ios swift avplayer mpnowplayinginfocenter