监听高级 IMA 事件
CAF DAI SDK 与原生 CAF 广告插播时间点功能紧密集成。因此,在大多数情况下,您应使用 CAF 广告插播事件来触发日志记录或自定义功能。不过,CAF DAI SDK 提供了无法直接通过 CAF 广告插播时间点提供的其他几个事件,例如四分位跟踪事件。
想要与使用 IMA DAI SDK 的平台完全对等的发布商可能需要向 StreamManager 附加事件监听器来处理这些额外的事件。如果需要将这些事件传递给附加的发件人应用,只需通过 castContext.sendCustomMessage() 将事件转发给发件人即可。
示例:
...
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();
...
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-10-14。
[null,null,["最后更新时间 (UTC):2024-10-14。"],[[["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"]]