从MPRemoteCommandCenter丢失“正在播放”状态

我正在创建一个可以使用MPRemoteCommandCenter控制的iOS应用程序。 这很好用。

将应用程序AVAudioSession类别从AVAudioSessionCategoryPlaybackAVAudioSessionCategoryPlayback, withOptions: .MixWithOthers ,它会停止接收远程控制事件。 这可以。

但是当我将类别更改回AVAudioSessionCategoryPlayback ,我没有按预期从MPRemoteCommandCenter接收事件。

如何为我的应用程序回收“正在播放”状态?

我确实发现在设置AVAudioSessionCategory时会保留选项。 因此,首先调用setCategory(AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers) ,然后再setCategory(AVAudioSessionCategoryPlayback) .MixWithOthers选项始终有效。

我无法找到AVAudioSessionCategoryOptions.None选项,但提供空数组确实重置了类别选项。

.setCategory(AVAudioSessionCategoryPlayback, withOptions: [])