監聽進階 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();
...
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-21 (世界標準時間)。
[null,null,["上次更新時間:2025-08-21 (世界標準時間)。"],[],["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"],null,[]]