I have a music streaming app in which I use lock screen controls to play/pause/next the song.
I have Admob Interstitial ads in my app.
However when I use the lock screen controls, it gets passed down to the video ad as well because of which the video ad starts playing along with my app's music. Is there any way to prevent this?
Here's how I am handling the lock screen controls. I don't interact with the ads in any of this code but still the control gets passed down to admob's video player:
- (void)remoteControlReceivedWithEvent:(UIEvent *)event {
////NSLog(@"CustomApp:remoteControlReceivedWithEvent:%@", event.description);
if (event.type == UIEventTypeRemoteControl)
{
switch (event.subtype)
{
case UIEventSubtypeRemoteControlPlay:
// play the video
dispatch_async(dispatch_get_main_queue(), ^{
[[[SoundEngine sharedInstance] audioPlayer] resume];
//[[SoundEngine sharedInstance] setLockScreenElapsedTime];
});
break;
case UIEventSubtypeRemoteControlPause:
// pause the video
dispatch_async(dispatch_get_main_queue(), ^{
[[[SoundEngine sharedInstance] audioPlayer] pause];
//[[SoundEngine sharedInstance] setLockScreenElapsedTime];
});
break;
case UIEventSubtypeRemoteControlNextTrack:
// to change the video
dispatch_async(dispatch_get_main_queue(), ^{
[[SoundEngine sharedInstance] nextClicked];
//[[SoundEngine sharedInstance] setLockScreenElapsedTime];
});
break;
case UIEventSubtypeRemoteControlPreviousTrack:
// to play the privious video
dispatch_async(dispatch_get_main_queue(), ^{
[[SoundEngine sharedInstance] prevClicked];
//[[SoundEngine sharedInstance] setLockScreenElapsedTime];
});
break;
default:
break;
}
}
}