Ios “失去”;“现在玩”;来自MPRemoteCommandCenter的状态
我正在为iOS创建一个应用程序,可以使用Ios “失去”;“现在玩”;来自MPRemoteCommandCenter的状态,ios,swift,avfoundation,Ios,Swift,Avfoundation,我正在为iOS创建一个应用程序,可以使用MPRemoteCommandCenter进行控制。这个很好用 将应用程序AVAudioSession类别从AVAudioSessionCategoryPlayback更改为AVAudioSessionCategoryPlayback时,使用选项:.MixWithOthers,它将停止接收远程控制事件。这很好 但是,当我将类别更改回AVAudioSessionCategoryPlayback时,我不会像预期的那样从MPRemoteCommandCenter
MPRemoteCommandCenter
进行控制。这个很好用
将应用程序AVAudioSession
类别从AVAudioSessionCategoryPlayback
更改为AVAudioSessionCategoryPlayback时,使用选项:.MixWithOthers
,它将停止接收远程控制事件。这很好
但是,当我将类别更改回AVAudioSessionCategoryPlayback
时,我不会像预期的那样从MPRemoteCommandCenter
接收事件
如何为我的应用程序恢复“正在播放”状态?我确实发现,在设置
AVAudioSessionCategory
时,选项被保留。因此,通过先调用setCategory(AVAudioSessionCategoryPlayback,with options:.MixWithOthers)
然后再调用setCategory(AVAudioSessionCategoryPlayback)
,.MixWithOthers
选项始终有效
我找不到AVAudioSessionCategoryOptions。无
选项,但提供空数组确实重置了类别选项
.setCategory(AVAudioSessionCategoryPlayback,带有选项:[])
中的答案没有帮助,因为开始接收RemoteControlEvents
被弃用,取而代之的是MPRemoteCommandCenter
。