Manual Ad Break Playback

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 will fire an AD_BREAK_READY event when an ad break has loaded, and wait on you to start the break's playback.

Prerequisites

  • An Android application with the IMA SDK implemented.

Helpful primers

If you still need to implement the IMA SDK in your app, check out our Get Started guide.

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 on the Basic Example to implement manual ad break playback:

public VideoPlayerController(Context context, VideoPlayer videoPlayer,
            ViewGroup adUiContainer) {
  ...
  ImaSdkSettings imaSdkSettings = new ImaSdkSettings();
  // Tell the SDK we want to control ad break playback.
  imaSdkSettings.setAutoPlayAdBreaks(false);
  mSdkFactory = ImaSdkFactory.getInstance();
  mAdsLoader = mSdkFactory.createAdsLoader(context, imaSdkSettings);
  ...
}
...
@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 we're ready. To skip this ad break,
        // simply return from this handler without calling mAdsManager.start().
        mAdsManager.start();
        break;
      ...
}

FAQ

Is manual ad playback required for an IMA SDK implementation?
Absolutely not! 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.