Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIEventSubtypeRemoteControlTogglePlayPause not doing anything

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?

like image 683
ASCJU Avatar asked Oct 18 '13 09:10

ASCJU


1 Answers

use the case

UIEventSubtypeRemoteControlPause

UIEventSubtypeRemoteControlPlay

for iOS 7

like image 200
Shubhank Avatar answered Sep 28 '22 14:09

Shubhank