Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios “失去”;“现在玩”;来自MPRemoteCommandCenter的状态_Ios_Swift_Avfoundation - Fatal编程技术网

Ios “失去”;“现在玩”;来自MPRemoteCommandCenter的状态

Ios “失去”;“现在玩”;来自MPRemoteCommandCenter的状态,ios,swift,avfoundation,Ios,Swift,Avfoundation,我正在为iOS创建一个应用程序,可以使用MPRemoteCommandCenter进行控制。这个很好用 将应用程序AVAudioSession类别从AVAudioSessionCategoryPlayback更改为AVAudioSessionCategoryPlayback时,使用选项:.MixWithOthers,它将停止接收远程控制事件。这很好 但是,当我将类别更改回AVAudioSessionCategoryPlayback时,我不会像预期的那样从MPRemoteCommandCenter

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

将应用程序
AVAudioSession
类别从
AVAudioSessionCategoryPlayback
更改为
AVAudioSessionCategoryPlayback时,使用选项:.MixWithOthers
,它将停止接收远程控制事件。这很好

但是,当我将类别更改回
AVAudioSessionCategoryPlayback
时,我不会像预期的那样从
MPRemoteCommandCenter
接收事件


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

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

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

.setCategory(AVAudioSessionCategoryPlayback,带有选项:[])

中的答案没有帮助,因为
开始接收RemoteControlEvents
被弃用,取而代之的是
MPRemoteCommandCenter