Ima Dai SDK
GoogleOfficialCreated by Google LLC
- Skill
- Tool integration
- Software development
- Apache-2.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The ima-dai-sdk provides the necessary implementation patterns to integrate Google's Dynamic Ad Insertion (DAI) technology into various platforms, including web, Android, iOS, tvOS, Cast, and Roku. It enables developers to load and play HLS or DASH streams with server-side ad insertion for both livestream events and video-on-demand (VOD) content managed via Google Ad Manager.
What it does
- Initializes the IMA DAI SDK for platform-specific video players.
- Supports livestream event requests using asset keys.
- Supports VOD stream requests using CMS IDs and video IDs.
- Provides event listeners for stream management and ad playback tracking.
- Handles timed metadata forwarding for seamless ad transitions.
- Facilitates resource cleanup to ensure stable application performance.
When to use it
- When implementing server-side ad insertion for HLS or DASH video streams.
- When managing ad-supported livestreams configured in Google Ad Manager.
- When integrating VOD content with dynamic ads into mobile, web, or TV applications.
- When building custom video player experiences that require Google DAI functionality.
Advantages
- Enables seamless, server-side ad insertion for improved playback stability.
- Provides consistent integration patterns across multiple platforms.
- Supports both live and on-demand video content workflows.
- Integrates directly with Google Ad Manager infrastructure.
Usage examples
- “How do I initialize the IMA DAI SDK in an Android application?”
- The agent provides the steps to use ImaSdkFactory to create and initialize ImaSdkSettings, followed by building an AdsLoader for the ExoPlayer instance.
- “What parameters are needed to request a VOD stream on a Cast receiver?”
- The agent explains that a VODStreamRequest requires the network code, content source ID (CMS ID), and video ID from Google Ad Manager.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/google/ima-dai-sdk/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip ima-dai-sdk.zip -d .agents/skills
Documentation by Google LLC
IMA DAI SDK
Use the IMA DAI SDK to load HLS or DASH streams into the app for:
Livestream events configured in Google Ad Manager.
Video on demand (VOD) content ingested into Google Ad Manager.
Prerequisites
Review the platform-specific integration guides for the target platforms:
Web/HTML5/ReactJs/NodeJs/Angular: Read StreamManager guide for loading stream URL from Google full-service DAI into
<video>element.ChromeCast: Read StreamManager guide for integrating the IMA DAI SDK into a ChromeCast Web Receiver.
Android: Read ImaServerSideAdInsertionMediaSource guide for integrating Media3 Exoplayer IMA extension.
iOS/tvOS: Read IMAStreamRequest guide for playing streams with
AVPlayer.Roku: Read StreamManager guide for implementing DAI on Roku SceneGraph.
Quick start (general workflow)
Import the SDK
Initialize the SDK
Add stream event listeners
Set up timed metadata forwarding
Make a stream request
Clean up SDK resources when the stream fails or the user leaves the stream.
Files
- ATTRIBUTION.mdAdded by AutoGineer896 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md1.9 KiB
- references/android-ImaServerSideAdInsertionMediaSource-guide.md8.0 KiB
- references/cast-StreamManager-guide.md4.4 KiB
- references/ios-IMAStreamRequest-guide.md5.7 KiB
- references/roku-StreamManager-guide.md7.2 KiB
- references/web-StreamManager-guide.md7.9 KiB
references/cast-StreamManager-guide.md
Google IMA DAI SDK Cast - StreamManager Guide
Use StreamManager to request and play a livestream or VOD stream from Google
full-service DAI in a Cast Application Framework (CAF) Web Receiver.
Table of Contents
Import the IMA DAI SDK (Line 17)
SDK Initialization (Line 28)
Make stream requests (Line 43)
Stream Event and Error Handling (Line 95)
DAI session events (Line 103)
Ad break events (Line 108)
Ad events (Line 114)
Cleanup (Line 124)
Import the IMA DAI SDK
Add the script tag for the IMA DAI SDK for CAF immediately after the CAF receiver framework script loader. The CAF DAI SDK is evergreen, so there is no need to set a specific version.
<script src="//www.gstatic.com/cast/sdk/libs/caf_receiver/v3/cast_receiver_framework.js"></script>
<script src="//imasdk.googleapis.com/js/sdkloader/cast_dai.js"></script>SDK Initialization
Obtain the CastReceiverContext and PlayerManager instances.
Initialize the StreamManager so that the IMA DAI SDK can set up timed metadata
event listeners before playback starts.
const castContext: cast.framework.CastReceiverContext =
cast.framework.CastReceiverContext.getInstance();
const playerManager: cast.framework.PlayerManager =
castContext.getPlayerManager();
const streamManager = new google.ima.cast.dai.api.StreamManager();Make stream requests
Create google.ima.cast.dai.api.LiveStreamRequest from sender app's cast
request.
let streamRequest = new google.ima.cast.dai.api.LiveStreamRequest();
streamRequest.networkCode = <NETWORK_CODE_PLACEHOLDER>;
streamRequest.assetKey = <ASSET_KEY_PLACEHOLDER>;Extract the following parameters from
cast.framework.messages.MediaInformation.customData:
<NETWORK_CODE_PLACEHOLDER>: The Google Ad Manager network code.
<ASSET_KEY_PLACEHOLDER>: The livestream asset key configured in Google Ad Manager.
For VOD, create google.ima.cast.dai.api.VODStreamRequest from sender app's
cast request.
let streamRequest = new google.ima.cast.dai.api.VODStreamRequest();
streamRequest.networkCode = <NETWORK_CODE_PLACEHOLDER>;
streamRequest.contentSourceId = <CMS_ID_PLACEHOLDER>;
streamRequest.videoId = <VIDEO_ID_PLACEHOLDER>;Provide the following parameters from
cast.framework.messages.MediaInformation.customData:
<NETWORK_CODE_PLACEHOLDER>: The Google Ad Manager network code.
<CMS_ID_PLACEHOLDER>: The content source ID (CMS ID) in Google Ad Manager.
<VIDEO_ID_PLACEHOLDER>: The video ID in the CMS.
For testing purposes, use values of DAI sample streams from https://developers.google.com/ad-manager/dynamic-ad-insertion/streams.md.txt?utm_source=agent-skills&utm_medium=content&utm_campaign=adr-ss-ai&utm_content=ima-dai-sdk
To play the stream immediately, create a load message interceptor to make stream
requests by calling streamManager.requestStream():
playerManager.setMessageInterceptor(
cast.framework.messages.MessageType.LOAD,
(loadRequestData: cast.framework.messages.LoadRequestData) => {
return streamManager.requestStream(loadRequestData, streamRequest);
}
);Stream Event and Error Handling
Add listeners on google.ima.cast.dai.api.StreamManager for all event types:
DAI session events and errors
Ad break events
Individual ad events
DAI session events
Listen for the google.ima.cast.dai.api.StreamEvent.Type.ERROR event to log the
event.getStreamData().errorMessage string and switch to a fallback stream.
Ad break events
Listen for the google.ima.cast.dai.api.StreamEvent.Type.AD_PERIOD_STARTED and
google.ima.cast.dai.api.StreamEvent.Type.AD_PERIOD_ENDED events to disable and
restore playback controls, such as seeking.
Ad events
Listen for the following events of individual ads to log them:
google.ima.cast.dai.api.StreamEvent.Type.STARTEDgoogle.ima.cast.dai.api.StreamEvent.Type.FIRST_QUARTILEgoogle.ima.cast.dai.api.StreamEvent.Type.MIDPOINTgoogle.ima.cast.dai.api.StreamEvent.Type.THIRD_QUARTILEgoogle.ima.cast.dai.api.StreamEvent.Type.COMPLETE
Cleanup
Reset the StreamManager when a stream is ended, or a fatal error occurs.
streamManager.reset();Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Google LLC
- Publisher
- Google (Official)
- Source
- google/skills · skills/ads/ima-dai-sdk · commit 2194d3b
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Google LLC or Google.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download ima-dai-sdk.zip