In the .plist I have added the normal: http://tinyurl.com/c7e9joy And when the iPhone is locked or I'm outside the app and open the remote buttons, I can see the app logo and title there, but they don't react. (I'm testing on my own 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;
}
}
}
You are unregistering for the events in viewWillDisapear meaning that anytime that view isn't visible on the phone you wont be registered for the events. I would change where you register and unregister to the viewDidLoad and viewDidUnload hooks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With