Listen for advanced IMA events
The CAF DAI SDK integrates closely with the native CAF Ad Breaks functionality. As such, in most cases, you should use CAF Ad Break events to trigger logging or custom functionality. However, the CAF DAI SDK offers several additional events that are not available directly through CAF Ad Breaks, such as quartile tracking events.
Publishers who want full parity with platforms using the IMA DAI SDK may need to attach event listeners to the StreamManager to handle these additional events. If it is necessary to pass these events on to the attached sender apps, simply forward the event to the sender via castContext.sendCustomMessage().
Example:
...
streamManager.addEventListener(ima.cast.dai.api.StreamEvent.Type.MIDPOINT, (event) => {
// add custom receiver handler code here, if necessary
console.log(event);
// broadcast event to all attached senders, so they can
// run custom handler code, if necessary
const CUSTOM_CHANNEL = 'urn:x-cast:com.example.cast.mynamespace';
castContext.sendCustomMessage(CUSTOM_CHANNEL, null, event);
});
castContext.start();
...
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-03-21 UTC.
[null,null,["Last updated 2025-03-21 UTC."],[[["The CAF DAI SDK leverages CAF Ad Break events for logging and custom functionality, recommending their use over separate implementations."],["For advanced use cases like quartile tracking, the CAF DAI SDK provides additional StreamEvents beyond standard CAF Ad Break events."],["To ensure sender application compatibility, publishers can utilize `castContext.sendCustomMessage()` to relay custom CAF DAI events to sender applications."]]],["The CAF DAI SDK utilizes CAF Ad Break events for most functions, but it also provides additional events like quartile tracking. Publishers needing full parity with the IMA DAI SDK should attach event listeners to the StreamManager to handle these extra events. To pass these events to sender apps, use `castContext.sendCustomMessage()`. An example shows how to add a listener for the `MIDPOINT` event, log it, and then broadcast it to all connected senders via a custom message channel.\n"]]