.plistに通常のファイルを追加しました:http ://tinyurl.com/c7e9joy iPhoneがロックされているか、アプリの外にいてリモートボタンを開くと、アプリのロゴとタイトルが表示されますが、反応しないでください。(私は自分のiPhoneでテストしています。)
// Makes sure we are able to connect to the media buttons on the lock screen.
- (BOOL) canBecomeFirstResponder
{
return YES;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
- (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent {
NSLog(@"REMOTE");
if (receivedEvent.type == UIEventTypeRemoteControl) {
switch (receivedEvent.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
[self playBtnPressed:nil];
break;
case UIEventSubtypeRemoteControlPreviousTrack:
[self skipTrack:nil];
break;
case UIEventSubtypeRemoteControlNextTrack:
[self skipTrack:nil];
break;
default:
break;
}
}
}