2015-08-29 116 views
2

我正在創建一個可以使用MPRemoteCommandCenter控制的iOS應用程序。這工作正常。從MPRemoteCommandCenter丟失「正在播放」狀態

將應用程序AVAudioSession類別從AVAudioSessionCategoryPlayback更改爲AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers時,它將停止接收遠程控制事件。這可以。

但是,當我將該類別更改回AVAudioSessionCategoryPlayback時,我沒有按預期從MPRemoteCommandCenter收到事件。

如何收回「正在播放」狀態的我的應用程序?

+0

在http://stackoverflow.com/questions/24625510/switching-avaudiosession-categories-then-retaking-control-of-remote-control-cent的答案並沒有幫助爲'beginReceivingRemoteControlEvents'是棄用「MPRemoteCommandCenter」。 – Henrik

回答

1

我沒發現,設置AVAudioSessionCategory當選項被保留。因此,通過調用setCategory(AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers)setCategory(AVAudioSessionCategoryPlayback)後,.MixWithOthers選擇是始終有效。

我無法找到一個AVAudioSessionCategoryOptions.None的選擇,但提供一個空數組做復位類別選項。

.setCategory(AVAudioSessionCategoryPlayback, withOptions: [])