Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mAdsLoader.addAdsLoadedListener(new AdsLoader.AdsLoadedListener() {
- @Override
- public void onAdsManagerLoaded(AdsManagerLoadedEvent adsManagerLoadedEvent) {
- // Ads were successfully loaded, so get the AdsManager instance. AdsManager has
- // events for ad playback and errors.
- mAdsManager = adsManagerLoadedEvent.getAdsManager();
- // Attach event and error event listeners.
- mAdsManager.addAdErrorListener(new AdErrorEvent.AdErrorListener() {
- @Override
- public void onAdError(AdErrorEvent adErrorEvent) {
- }
- });
- mAdsManager.addAdEventListener(new AdEvent.AdEventListener() {
- @Override
- public void onAdEvent(AdEvent adEvent) {
- switch (adEvent.getType()) {
- case LOADED:
- // AdEventType.LOADED will be fired when ads are ready to be played.
- // AdsManager.start() begins ad playback. This method is ignored for VMAP or
- // ad rules playlists, as the SDK will automatically start executing the
- // playlist.
- mAdsManager.start();
- break;
- case CONTENT_PAUSE_REQUESTED:
- // AdEventType.CONTENT_PAUSE_REQUESTED is fired immediately before a video
- // ad is played.
- mIsAdDisplayed = true;
- youboraPlugin.pauseMonitoring();
- mNexPlayer.pause();
- break;
- case CONTENT_RESUME_REQUESTED:
- // AdEventType.CONTENT_RESUME_REQUESTED is fired when the ad is completed
- // and you should start playing your content.
- mIsAdDisplayed = false;
- youboraPlugin.resumeMonitoring();
- mNexPlayer.resume();
- break;
- case ALL_ADS_COMPLETED:
- if (mAdsManager != null) {
- mAdsManager.destroy();
- mAdsManager = null;
- }
- break;
- case STARTED:
- break;
- default:
- break;
- }
- }
- });
- mAdsManager.init();
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement