Losing “Now Playing” status from MPRemoteCommandCenter

主宰稳场 提交于 2020-01-03 21:08:22

问题


I am creating an application for iOS that can be controlled using the MPRemoteCommandCenter. This works fine.

When changing the application AVAudioSession category from AVAudioSessionCategoryPlayback to AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers, it stops receiving remote control events. This is fine.

But when I change the category back to AVAudioSessionCategoryPlayback, I do not receive events from MPRemoteCommandCenter as expected.

How can I reclaim "Now Playing" status for my application?


回答1:


I did discover that when setting AVAudioSessionCategory the options are retained. So by calling setCategory(AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers) first and then setCategory(AVAudioSessionCategoryPlayback) later, the .MixWithOthers option was always in effect.

I was unable to find a AVAudioSessionCategoryOptions.None option, but supplying an empty array did reset the category options.

.setCategory(AVAudioSessionCategoryPlayback, withOptions: [])



来源:https://stackoverflow.com/questions/32284272/losing-now-playing-status-from-mpremotecommandcenter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!