Write sender apps for the CAF DAI SDK
Stay organized with collections
Save and categorize content based on your preferences.
Unlike previous integrations between Chromecast and DAI, the CAF DAI SDK focuses heavily on maintaining the standards and expectations set by the Cast Application Framework. As such, there are no requirements to heavily customize your sender apps to manage bidirectional communications between the IMA and the sender app. These communications are now managed via the integrated CAF Ad Breaks functionality, rather than requiring custom message systems to communicate between the sender app and receiver.
Depending on your sender, you may still need to add some limited code to your senders to fully enable CAF Ad Breaks support, such as adding support for skippable ads to web senders.
All that is required now, aside from support for CAF Ad Breaks, is to include the DAI stream data in the CAF MediaInfo object that is sent from the sender to the receiver. You can choose to send this data in many different ways, for example, you could hard code the contentSourceID on your receiver and only send videoID with the MediaInfo object, or you could send an arbitrary identifier to the receiver, and from there query an online database for the actual DAI parameters.
However, for the purpose of simplicity, all our samples will assume that you follow this simple structure and naming convention for your MediaInfo objects:
contentId
|
A unique identifier for this media item
|
contentUrl
|
The fallback stream url to load if the DAI StreamRequest fails for any reason
|
streamType
|
For live streams this value should be set to 'LIVE'. For VOD streams, this value should be set to 'BUFFERED'
|
customData
|
assetKey
|
Live streams only. Identifies the live stream to be loaded
|
contentSourceId
|
VOD streams only. Identifies the media feed that contains the requested stream.
|
videoId
|
VOD streams only. Identifies the requested stream within the specified media feed.
|
ApiKey
|
An optional API key that can be required to retrieve the stream url from the IMA DAI SDK.
|
senderCanSkip
|
A boolean value to let the receiver know whether the sending device has the ability to display a skip button, enabling support for skippable ads
|
Example LIVE Stream:
{
"media": {
"contentId": "bbb",
"contentUrl": "https://storage.googleapis.com/interactive-media-ads/media/bbb.m3u8",
"streamType": "LIVE",
"customData": {
"assetKey": "sN_IYUG8STe1ZzhIIE_ksA",
"ApiKey": "",
"senderCanSkip": true
}
},
"credentials": "testCredentials"
}
Example VOD Stream:
{
"media": {
"contentId": "tos",
"contentUrl": "https://storage.googleapis.com/interactive-media-ads/media/tos.m3u8",
"streamType": "BUFFERED",
"customData": {
"contentSourceId": "2548831",
"videoId": "tears-of-steel",
"ApiKey": "",
"senderCanSkip": true
}
},
"credentials": "testCredentials"
}
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[null,null,["Last updated 2025-08-20 UTC."],[[["\u003cp\u003eChromecast's CAF DAI SDK leverages the Cast Application Framework for seamless integration and bidirectional communication with IMA, reducing sender app customization.\u003c/p\u003e\n"],["\u003cp\u003eCAF Ad Breaks functionality is used for communication, eliminating the need for custom message systems.\u003c/p\u003e\n"],["\u003cp\u003eTo enable CAF DAI, include DAI stream data within the CAF MediaInfo object sent from the sender to the receiver.\u003c/p\u003e\n"],["\u003cp\u003eThe MediaInfo object should follow a structure that uses \u003ccode\u003econtentId\u003c/code\u003e, \u003ccode\u003econtentUrl\u003c/code\u003e, \u003ccode\u003estreamType\u003c/code\u003e, and \u003ccode\u003ecustomData\u003c/code\u003e fields with specific values for live and VOD streams.\u003c/p\u003e\n"],["\u003cp\u003eSender apps might require minor code additions, like skippable ad support for web senders, for full CAF Ad Breaks compatibility.\u003c/p\u003e\n"]]],[],null,["# Write sender apps for the CAF DAI SDK\n\nUnlike previous integrations between Chromecast and DAI, the CAF DAI SDK focuses heavily on maintaining the standards and expectations set by the [Cast Application Framework](https://developers.google.com/cast/docs/developers). As such, there are no requirements to heavily customize your sender apps to manage bidirectional communications between the IMA and the sender app. These communications are now managed via the integrated [CAF Ad Breaks](https://developers.google.com/cast/docs/web_receiver/ad_breaks) functionality, rather than requiring custom message systems to communicate between the sender app and receiver.\n\nDepending on your sender, you may still need to add some limited code to your senders to fully enable CAF Ad Breaks support, such as [adding support for skippable ads to web senders](https://developers.google.com/cast/docs/web_sender/advanced#sending_media_messages_to_the_receiver).\n\nAll that is required now, aside from support for CAF Ad Breaks, is to include the DAI stream data in the [CAF MediaInfo object](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.MediaInfo) that is sent from the sender to the receiver. You can choose to send this data in many different ways, for example, you could hard code the contentSourceID on your receiver and only send videoID with the MediaInfo object, or you could send an arbitrary identifier to the receiver, and from there query an online database for the actual DAI parameters.\n\nHowever, for the purpose of simplicity, all our samples will assume that you follow this simple structure and naming convention for your MediaInfo objects:\n\n|----------------|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|\n| **contentId** || A unique identifier for this media item |\n| **contentUrl** || The fallback stream url to load if the DAI StreamRequest fails for any reason |\n| **streamType** || For live streams this value should be set to 'LIVE'. For VOD streams, this value should be set to 'BUFFERED' |\n| **customData** | **assetKey** | **Live streams only.** Identifies the live stream to be loaded |\n| **customData** | **contentSourceId** | **VOD streams only.** Identifies the media feed that contains the requested stream. |\n| **customData** | **videoId** | **VOD streams only.** Identifies the requested stream within the specified media feed. |\n| **customData** | **ApiKey** | An optional API key that can be required to retrieve the stream url from the IMA DAI SDK. |\n| **customData** | **senderCanSkip** | A boolean value to let the receiver know whether the sending device has the ability to display a skip button, enabling support for skippable ads |\n\n**Example LIVE Stream:** \n\n {\n \"media\": {\n \"contentId\": \"bbb\",\n \"contentUrl\": \"https://storage.googleapis.com/interactive-media-ads/media/bbb.m3u8\",\n \"streamType\": \"LIVE\",\n \"customData\": {\n \"assetKey\": \"sN_IYUG8STe1ZzhIIE_ksA\",\n \"ApiKey\": \"\",\n \"senderCanSkip\": true\n }\n },\n \"credentials\": \"testCredentials\"\n }\n\n**Example VOD Stream:** \n\n {\n \"media\": {\n \"contentId\": \"tos\",\n \"contentUrl\": \"https://storage.googleapis.com/interactive-media-ads/media/tos.m3u8\",\n \"streamType\": \"BUFFERED\",\n \"customData\": {\n \"contentSourceId\": \"2548831\",\n \"videoId\": \"tears-of-steel\",\n \"ApiKey\": \"\",\n \"senderCanSkip\": true\n }\n },\n \"credentials\": \"testCredentials\"\n }"]]