失去来自 MPRemoteCommandCenter 的 "Now Playing" 状态
Losing "Now Playing" status from MPRemoteCommandCenter
我正在为 iOS 创建一个可以使用 MPRemoteCommandCenter
控制的应用程序。这很好用。
将应用程序 AVAudioSession
类别从 AVAudioSessionCategoryPlayback
更改为 AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers
时,它会停止接收远程控制事件。这很好。
但是当我将类别改回 AVAudioSessionCategoryPlayback
时,我没有按预期收到来自 MPRemoteCommandCenter
的事件。
如何恢复我的申请的 "Now Playing" 状态?
我确实发现设置 AVAudioSessionCategory
时选项会保留。因此,通过先调用 setCategory(AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers)
然后再调用 setCategory(AVAudioSessionCategoryPlayback)
,.MixWithOthers
选项始终有效。
我找不到 AVAudioSessionCategoryOptions.None
选项,但提供一个空数组确实重置了类别选项。
.setCategory(AVAudioSessionCategoryPlayback, withOptions: [])
我正在为 iOS 创建一个可以使用 MPRemoteCommandCenter
控制的应用程序。这很好用。
将应用程序 AVAudioSession
类别从 AVAudioSessionCategoryPlayback
更改为 AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers
时,它会停止接收远程控制事件。这很好。
但是当我将类别改回 AVAudioSessionCategoryPlayback
时,我没有按预期收到来自 MPRemoteCommandCenter
的事件。
如何恢复我的申请的 "Now Playing" 状态?
我确实发现设置 AVAudioSessionCategory
时选项会保留。因此,通过先调用 setCategory(AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers)
然后再调用 setCategory(AVAudioSessionCategoryPlayback)
,.MixWithOthers
选项始终有效。
我找不到 AVAudioSessionCategoryOptions.None
选项,但提供一个空数组确实重置了类别选项。
.setCategory(AVAudioSessionCategoryPlayback, withOptions: [])