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