Skip to content

Google IMA ads

Attach the IMA provider once, then put an ad tag on any media item. The SDK draws the ad chrome — yellow progress bar, AD chip with pod position, countdown, cue markers on the scrubber — identically on all platforms, while IMA renders its own skip button and clickthrough (a Google requirement).

val player = OGPlayer.Builder(context)
.setAdsProvider(ImaAdsProvider(context))
.build()
player.load(
OGMediaItem.Builder(contentUrl)
.setAdBreaks(AdTagConfig("https://pubads.g.doubleclick.net/...vmap..."))
.build(),
)

What you observe, on every platform, through the same AdListener: onAdBreakStartedonAdStarted (with pod position and duration) → onAdProgress ticks → onAdCompletedonAdBreakCompleted, plus onAdError (never fatal to content). VMAP cue points surface via adCuePositionsMs and as yellow dots on the scrubber; played breaks drop their cue.

Web-only extra: the ad-blocker policy (adBlockerPolicy: "notice" | "block" | "none") — detection is deterministic (error 902) and the hard policy refuses content until the blocker is off.

Within one player instance, ads the viewer has already watched for a given video + ad tag are not requested again when that same combination is load()ed again. Reloading a video — after an error, a settings change, a DRM refresh — never forces the viewer back through the same preroll. A new player instance is always a fresh ad session, so a genuinely new watch (a new screen, a new page) requests ads normally.

Platform nuance, worth knowing exactly:

  • Android tracks this per break: a watched preroll stays skipped while unwatched mid-rolls in the same VMAP schedule still play after a reload.
  • iOS and web skip the ad request once the video’s whole ad schedule has completed. A partially watched VMAP schedule (preroll seen, mid-rolls not reached) starts over on reload — the IMA SDKs on these platforms offer no way to mark individual breaks as already played.

For the most common setup — a single preroll — all three platforms behave identically: watch it once, reload freely.

Want a reload to request ads again anyway? Use a new player instance, or vary the tag URL (an extra query parameter is enough — ad servers ignore parameters they don’t know).