在我设法使用 MPMoviePlayerController 在后台播放音频并尝试使其接收远程控制之后。但是当我点击播放/暂停按钮时,没有任何反应,音频继续播放。然后我试图显示是否有日志输出但没有输出。
这是我的代码:
-(void)viewDidAppear:(BOOL)animated{
...
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
}
- (void)remoteControlReceivedWithEvent:(UIEvent *)event {
NSLog(@"remoteControlReceivedWithEvent: %@", event);
if (event.type==UIEventTypeRemoteControl) {
if (event.subtype==UIEventSubtypeRemoteControlPlay) {
NSLog(@"Play");
} else if (event.subtype==UIEventSubtypeRemoteControlPause) {
NSLog(@"Pause");
} else if (event.subtype==UIEventSubtypeRemoteControlTogglePlayPause) {
NSLog(@"Play Pause");
}
}
}
感谢您在高级方面的努力。