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.
publicVideoPlayerController(Contextcontext,VideoPlayerWithAdPlaybackvideoPlayerWithAdPlayback,ViewplayButton,ViewplayPauseToggle,Stringlanguage,ViewGroupcompanionViewGroup,Loggerlog){...sdkFactory=ImaSdkFactory.getInstance();ImaSdkSettingsimaSdkSettings=sdkFactory.createImaSdkSettings();imaSdkSettings.setLanguage(language);// Tell the SDK you want to control ad break playback.imaSdkSettings.setAutoPlayAdBreaks(false);...}...@OverridepublicvoidonAdEvent(AdEventadEvent){...switch(adEvent.getType()){// Listen for the AD_BREAK_READY event.caseAD_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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-20 UTC."],[[["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."]]],[]]