Listen for advanced IMA events

  • 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 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();

...