Initiate ad breaks manually

Select platform: Android iOS

This guide provides instructions on overriding the default ad break schedule and configuring your own ad break playback timings. When manual ad break playback is implemented, the SDK fires an AD_BREAK_READY event when an ad break has loaded, and waits on you to start the break's playback.

Prerequisites

  • An Android application with the IMA SDK implemented.

Configuring manual ad break playback

To configure manual ad break playback:

  1. Tell the SDK you want to control ad break playback.
  2. Listen for the AD_BREAK_READY event.
  3. Tell the SDK to play ads when you're ready.

The snippet below shows the modifications required to the Advanced Example to implement manual ad break playback.

  public 
  
 VideoPlayerController 
 ( 
  
 Context 
  
 context 
 , 
  
 VideoPlayerWithAdPlayback 
  
 videoPlayerWithAdPlayback 
 , 
  
 View 
  
 playButton 
 , 
  
 View 
  
 playPauseToggle 
 , 
  
 String 
  
 language 
 , 
  
 ViewGroup 
  
 companionViewGroup 
 , 
  
 Logger 
  
 log 
 ) 
  
 { 
  
 ... 
  
  
 sdkFactory 
  
 = 
  
 ImaSdkFactory 
 . 
 getInstance 
 (); 
  
 ImaSdkSettings 
  
 imaSdkSettings 
  
 = 
  
 sdkFactory 
 . 
 createImaSdkSettings 
 (); 
  
 imaSdkSettings 
 . 
 setLanguage 
 ( 
 language 
 ); 
 
  
  // Tell the SDK you want to control ad break playback. 
  
 imaSdkSettings 
 . 
 setAutoPlayAdBreaks 
 ( 
 false 
 ); 
 
  
   
 ... 
 } 
 ... 
 @ 
 Override 
 public 
  
 void 
  
 onAdEvent 
 ( 
 AdEvent 
  
 adEvent 
 ) 
  
 { 
  
 ... 
  
 switch 
  
 ( 
 adEvent 
 . 
 getType 
 ()) 
  
 { 
 
  
  // Listen for the AD_BREAK_READY event. 
  
 case 
  
 AD_BREAK_READY 
 : 
  
 // Tell the SDK to play ads when you're ready. To skip this ad break, 
  
 // simply return from this handler without calling adsManager.start(). 
  
 adsManager 
 . 
 start 
 (); 
  
 break 
 ; 
 
  
  ... 
 } 
 

FAQ

Is manual ad playback required for an IMA SDK implementation?
No. manual ad playback is an optional feature for publishers who don't want the IMA SDK to automatically play ad breaks as scheduled by an ad rule or VMAP response.
Create a Mobile Website
View Site in Mobile | Classic
Share by: