Google IMA

Code samples

  • Google IMA ads: pre-roll, mid-roll, and post-roll ads from a VMAP ad tag, with an ad event log.

The SDK includes a Google Interactive Media Ads (IMA) plugin for client-side ads.

To get started, add the IMA library and player styles, and import the IMA plugin:

import "@castlabs/prestoplay/cl.ima";
<link rel="stylesheet" href="clpp.styles.css">
<script src="https://imasdk.googleapis.com/js/sdkloader/ima3.js"></script>

Pass a Video Multiple Ad Playlist (VMAP) ad tag to the player:

player.open({
  // ...
  ima: {
    adTagUrl: '//pubads.g.doubleclick.net/...'
  }
});

Pass a Video Ad Serving Template (VAST) ad tag to the player:

player.open({
  // ...
  ima: {
    adTagUrl: '//pubads.g.doubleclick.net/...',
    isVast: true
  }
});

See ImaConfiguration for all available configuration options.

IMA SDK on smart TVs

For smart TV-specific limitations, including skippable ads, see Smart TV.

IMA SDK on iOS

The IMA plugin is supported on iOS in experimental mode, for the same reasons as on smart TVs.

Custom UI controls give a better user experience than built-in video controls on iOS.

See ImaConfiguration and its disableCustomPlayback option to disable ads on iOS devices if you run into issues.

Next topic: Yospace
Previous topic: Advertising