我有一个音乐流媒体应用程序,我在其中使用锁定屏幕控件来播放/暂停/下一首歌曲。
我的应用中有 Admob 插页式广告。
但是,当我使用锁屏控件时,它也会传递给视频广告,因此视频广告开始与我的应用程序的音乐一起播放。有什么办法可以防止这种情况发生吗?
这是我处理锁定屏幕控件的方式。我不与任何代码中的广告进行交互,但控件仍然传递给 admob 的视频播放器:
- (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;
}
}
}