0

I'd like to handle remove control events in my app, but also would like the event can be passed on to other apps when I'm done.

I cannot find clear instructions in Apple's Remote Control Events doc section: http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/Remote-ControlEvents/Remote-ControlEvents.html#//apple_ref/doc/uid/TP40009541-CH7-SW3

Here it says:

iOS converts commands into UIEvent objects and delivers the events to an app. The app sends them to the first responder and, if the first responder doesn’t handle them, they travel up the responder chain. For more information about the responder chain, see “The Responder Chain Follows a Specific Delivery Path.”

So I thought I'd place

[[self nextResponder] remoteControlReceivedWithEvent: receivedEvent];

at the end of my event handler method, expecting that after my handler is done, a currently playing music app, e.g., the built-in music player, would be able to receive the event. But to my surprise, it never did.

What am I missing here?

1 Answer 1

2

Make sure you call the following methods to begin receiving the events.

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];

Then in your application delegate you need to listen for the events.

-(void)remoteControlReceivedWithEvent:(UIEvent *)event{
    if (event.type == UIEventTypeRemoteControl){
        switch (event.subtype) {
            case UIEventSubtypeRemoteControlTogglePlayPause:
                break;
            default:
                break;
        }
    }
}

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.