Enable Google DAI playback (Android v3)

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

PropertyTypeDescription
adTagParametersΒ 3.19.0+Map<String, String>Limited set of key-value pairs that enable the player to override default information with custom information during a stream request

These key-value pairs should be properly formatted without encoding. See: Supply Targeting Parameters to Your Stream.
apiKeyStringStream request API key
assetKeyStringStream 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.
cmsIDStringContent 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.
videoIDStringIdentifier 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.

🚧

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. If you have custom ad tag parameters, add them to the settings object with the setAdTagParameters() method.
  5. 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);

// Add your custom parameters here
Map<String, String> tagParams = new HashMap<>();
tagParams.put("cust_params", "sport=football&city=newyork");
imaDaiSettings.setAdTagParameters(tagParams);

// 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);


FAQ

Which Android SDK features are not supported with Google DAI?



The following features are not supported during a casting session with an Android SDK player:

  • Advertising
  • Multiple-audio tracks or AudioTrack switching
  • Multiple qualities or quality switching
  • 608/708 captions
  • DVR and live streaming capabilities