我在我的应用程序中使用 AVPlayer。MPNowPlayingInfoCenter 适用于模拟器。但在真实设备上,它不适用于控制屏幕音乐播放/暂停按钮。
最佳答案
要启用远程控制事件,您应该使用 beginReceivingRemoteControlEvents在 UIApplication .例子:
UIApplication.sharedApplication().beginReceivingRemoteControlEvents()
如果在某个时候您想停止接收事件,请调用:
UIApplication.sharedApplication().endReceivingRemoteControlEvents()
要处理远程事件,您应该实现 remoteControlReceivedWithEvent :
override func remoteControlReceivedWithEvent(event: UIEvent) {
// Your implementation
}
关于ios - MPNowPlayingInfoCenter 适用于模拟器,但不适用于设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32284001/