从MPRemoteCommandCenter丢失“正在播放”状态
我正在创建一个可以使用MPRemoteCommandCenter
控制的iOS应用程序。 这很好用。
将应用程序AVAudioSession
类别从AVAudioSessionCategoryPlayback
为AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers
,它会停止接收远程控制事件。 这可以。
但是当我将类别更改回AVAudioSessionCategoryPlayback
,我没有按预期从MPRemoteCommandCenter
接收事件。
如何为我的应用程序回收“正在播放”状态?
我确实发现在设置AVAudioSessionCategory
时会保留选项。 因此,首先调用setCategory(AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers)
,然后再setCategory(AVAudioSessionCategoryPlayback)
.MixWithOthers
选项始终有效。
我无法找到AVAudioSessionCategoryOptions.None
选项,但提供空数组确实重置了类别选项。
.setCategory(AVAudioSessionCategoryPlayback, withOptions: [])