UIEventSubtypeRemoteControlTogglePlayPause not doing anything
Asked Answered
H

2

5

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?

Hurdygurdy answered 18/10, 2013 at 9:16 Comment(0)
S
9

use the case

UIEventSubtypeRemoteControlPause

UIEventSubtypeRemoteControlPlay

for iOS 7

Schaaf answered 18/10, 2013 at 9:26 Comment(0)
M
0

The accepted answer is not clear.

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

UIEventSubtypeRemoteControlTogglePlayPause is called within headset interaction.

Magnification answered 29/6, 2016 at 14:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.