I am having a hard time trying to figure out why in iOS 7 the remote controls don't work. In iOS 7, in the lock screen or even in the Control Center, the buttons are unresponsive and the funny thing is that it works fine on iOS 6.
Here is the code I use:
- (void)remoteControlReceivedWithEvent:(UIEvent *)receivedEvent {
if (receivedEvent.type == UIEventTypeRemoteControl) {
switch (receivedEvent.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
if (player.playbackState == MPMusicPlaybackStatePlaying) {
[player pause];
}
else {
[player play];
}
break;
case UIEventSubtypeRemoteControlPreviousTrack:
break;
case UIEventSubtypeRemoteControlNextTrack:
break;
default:
break;
}
}}
This is where I found the information about how to perform this:
https://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/Remote-ControlEvents/Remote-ControlEvents.html
Any ideas why this is happening? It works on iOS 6 but not iOS 7.
Thanks
I ran into this same problem and I ended up removing the case statement UIEventSubtypeRemoteControlTogglePlayPause and added case statements UIEventSubtypeRemoteControlPlay and UIEventSubtypeRemoteControlPause individually. I don't have an good explanation for why this changed.
*UPDATE*
I found that UIEventSubtypeRemoteControlTogglePlayPause is called when the user is using their headset to control the player. Just a FYI.
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