我正在为iOS创建一个应用程序,该应用程序可以使用MPRemoteCommandCenter进行控制。这个很好用。
当将应用程序AVAudioSession类别从AVAudioSessionCategoryPlayback更改为AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers时,它将停止接收远程控制事件。这很好。
但是,当我将类别更改为AVAudioSessionCategoryPlayback时,我不会像预期的那样接收来自MPRemoteCommandCenter的事件。
如何为我的应用程序恢复“现在播放”状态?
发布于 2015-08-29 09:59:38
我确实发现,在设置AVAudioSessionCategory时,会保留这些选项。因此,通过先调用setCategory(AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers),然后调用setCategory(AVAudioSessionCategoryPlayback),.MixWithOthers选项始终有效。
我无法找到一个AVAudioSessionCategoryOptions.None选项,但是提供一个空数组确实重置了类别选项。
.setCategory(AVAudioSessionCategoryPlayback, withOptions: [])
https://stackoverflow.com/questions/32284272
复制相似问题