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
- JWP Android SDK 3.12.0+
- All the JWP Android SDK requirements
- Google DAI dependency
- All Google account information listed in the following table
| Property | Type | Description |
|---|---|---|
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. |
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.
For the following reasons, be sure that the URL used for the
PlaylistItem.fileis consistent with the media content registered with DAI for yourvideoIDorassetKey:
- If the DAI request fails, the video URL will play as a fallback.
- Analytics will be attributed to correct media item.
- Define your Google account information.
- If you are displaying a video on demand, define
cmsIDandvideoID. - If you are displaying a live stream, define
assetKey.
- If you are displaying a video on demand, define
- If your content is protected, set the
apiKeyproperty with your Google DAI API key. - Instantiate an
ImaDaiSettingsobject. In our code example, we name thisimaDaiSettings. - If you have custom ad tag parameters, add them to the settings object with the
setAdTagParameters()method. - Add the
ImaDaiSettingsobject to theimaDaiSettingsproperty of thePlaylistItemobject.
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
Updated almost 3 years ago
