Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RemoteControlReceivedWithEvent in iOS 7 issue

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

like image 890
Michael Ortiz Avatar asked Jan 13 '23 06:01

Michael Ortiz


1 Answers

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.

like image 185
Donelle C Sanders Jr Avatar answered Feb 02 '23 04:02

Donelle C Sanders Jr