I have a audio player app, that is created with Cordova and native AudioStreamer plugin calls.. Everything works perfectly, BUT, now i want to use the remoteControlReceivedWithEvent event to use the native remote controle when the app is in the background..
When I call my Cordova plugin to start the native player I also call ..
- (void)startStream:(CDVInvokedUrlCommand*)command
streamer = [[[AudioStreamer alloc] initWithURL:url] retain];
[streamer start];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self canBecomeFirstResponder];
And when I stop the stream:
- (void)stopStream:(CDVInvokedUrlCommand*)command
[streamer stop];
[streamer release];
streamer = nil;
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
It all work perfect, but i DONT know where to put the remote events...
- (void)remoteControlReceivedWithEvent:(UIEvent *)event {
switch (event.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
NSLog(@"PAUSE!!!");
break;
case UIEventSubtypeRemoteControlPlay:
NSLog(@"PAUSE!!!");
break;
case UIEventSubtypeRemoteControlPause:
NSLog(@"PAUSE!!!");
break;
case UIEventSubtypeRemoteControlStop:
NSLog(@"PAUSE!!!");
break;
default:
break;
}
}