Question

I have an application that plays music and want to use lockscreen control (play/pause). With NSLog I can see that my app get's the button trigger but not theUIEventSubtypeRemoteControlTogglePlayPause.

Here's a bit of my code:

- (void)viewDidLoad {
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
    [self becomeFirstResponder];
}

- (BOOL)canBecomeFirstResponder {
    return YES;
}

- (void)remoteControlReceivedWithEvent:(UIEvent *)receivedEvent
{
    NSLog(@"REMOTE RECEIVE");
    if (receivedEvent.type == UIEventTypeRemoteControl)
    {
        NSLog(@"received remote event");
        switch (receivedEvent.subtype)
        {
            case UIEventSubtypeRemoteControlTogglePlayPause:
                NSLog(@"toggle button received");
                //[self togglePlayPauseTapped: nil];
                break;
            default:
                break;
        }
    }

I get "REMOTE RECEIVE" and "received remote event" from the NSLog Output but not the line inside ...TogglePlayPause.

Any ideas?

Was it helpful?

Solution

use the case

UIEventSubtypeRemoteControlPause

UIEventSubtypeRemoteControlPlay

for iOS 7

OTHER TIPS

The accepted answer is not clear.

UIEventSubtypeRemoteControlPlay, UIEventSubtypeRemoteControlPause and UIEventSubtypeRemoteControlStop are called within the user interaction.

UIEventSubtypeRemoteControlTogglePlayPause is called within headset interaction.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top