Enable Google DAI playback

Enable ad playback with the Google Dynamic Ad Insertion ad client in an Android app.

After adding the Google IMA Dynamic Ad Insertion (DAI) SDK to your app and acquiring the required items listed in the Requirements section, you can enable Google DAI ad playback in your Android app.


Requirements

Property Type Description
apiKey String Stream request API key
assetKey String Stream asset key, used for live streams

You can find this ID in your Google Ad Manager portal. Ask your Google representative for assistance locating this ID.
cmsID String Content management system ID of the video, used for video on demand

You can find this ID in your Google Ad Manager portal. Ask your Google representative for assistance locating this ID.
videoID String Identifier of the DAI video to be displayed, used for video on demand

You can find this ID in your Google Ad Manager portal. Ask your Google representative for assistance locating this ID.



Specify ad content for a single playlist item

Use the following steps to set up dynamic ad insertion for a playlist item.

IMPORTANT

For the following reasons, be sure that the URL used for the PlaylistItem.file is consistent with the media content registered with DAI for your videoID or assetKey:

• If the DAI request fails, the video URL will play as a fallback.
• Analytics will be attributed to correct media item.


  1. Define your Google account information.
    • If you are displaying a video on demand, define cmsID and videoID.
    • If you are displaying a live stream, define assetKey.
  2. If your content is protected, set the apiKey property with your Google DAI API key.
  3. Instantiate an ImaDaiSettings object. In our code example, we name this imaDaiSettings.
  4. Add the ImaDaiSettings object to the imaDaiSettings property of the PlaylistItem object.


mPlayerView = findViewById(R.id.jwplayer);

String cmsId = "CMS_ID";
String videoId = "VIDEO_ID";
// apiKey can be null
String apiKey = "YOUR_API_KEY";
boolean isDash = false;
ImaDaiSettings imaDaiSettings = new ImaDaiSettings(cmsId, videoId, isDash, apiKey);

// Setup a media source
PlaylistItem playlistItem = new PlaylistItem.Builder()
    .file("https://content.jwplatform.com/manifests/{MEDIA_ID}.m3u8")
    .imaDaiSettings(imaDaiSettings)
    .build();

playlist.add(playlistItem);

PlayerConfig config = new PlayerConfig.Builder()
    .playlist(playlist)
    .build();

mPlayerView.setup(config);
mPlayerView = findViewById(R.id.jwplayer);

String assetKey = "ASSET_KEY_ID";
String apiKey = "YOUR_API_KEY";
boolean isDash = false;
ImaDaiSettings imaDaiSettings = new ImaDaiSettings(assetKey, isDash, apiKey);

// Setup a media source
PlaylistItem playlistItem = new PlaylistItem.Builder()
	.file("https://content.jwplatform.com/manifests/{MEDIA_ID}.m3u8")
	.imaDaiSettings(imaDaiSettings)
	.build();

playlist.add(playlistItem);

PlayerConfig config = new PlayerConfig.Builder()
    .playlist(playlist)
    .build();

mPlayerView.setup(config);

Updated 13 days ago


Enable Google DAI playback


Enable ad playback with the Google Dynamic Ad Insertion ad client in an Android app.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.