AI-generated Key Takeaways
-
This guide explains how to manually control ad break playback timing in your Android app using the IMA SDK.
-
By disabling autoplay and listening for the
AD_BREAK_READY
event, you can trigger ad breaks at your desired moments. -
This feature is optional and provides flexibility for publishers who need custom ad playback control beyond the default ad schedule.
-
The Advanced Example showcases the implementation, but the Basic Example with the Exoplayer-IMA extension cannot be used as a basis for this guide.
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:
- Tell the SDK you want to control ad break playback.
- Listen for the AD_BREAK_READY event.
- 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.