開始使用 SGAI

伺服器引導式廣告插播 (SGAI) 會提供 用戶端裝置。如果您在 Google 帳戶中啟用了「廣告連播放送 DAI」 Ad Manager 聯播網 即可存取 SGAI如果沒有 Pod Serving DAI 已啟用,請與您的客戶經理聯絡。

透過 SGAI,您可以使用 Pod 提供 API 端點建立串流 擷取廣告中繼資料與廣告連播資訊清單。

如果您有資訊清單操控伺服器,可以產生廣告連播 資訊清單網址,以及插入包含廣告連播資訊清單資訊的廣告標記 相符。

或者,您也可以使用其他機制排定廣告插播時間點 而不是串流資訊清單中的廣告標記在這些情況下,您的應用程式可以監聽 與其他事件互動,例如使用者與串流互動、應用程式本身 或推播通知發生這些事件後,應用程式就能產生廣告 ,並指示播放器開始載入廣告連播資訊清單。

必要條件

繼續操作之前,請先確認您具備以下項目:

  • 已啟用您 Google Ad Manager 聯播網的 DAI 廣告連播放送功能。
  • 類型為 Pod 放送資訊清單的直播活動。如要建立事件,請按照下列步驟操作: 看 為 DAI 設定直播

追蹤建議

使用前 產生廣告連播資訊清單網址,我們建議 呼叫 Early Ad Break Notification (EABN) API 來指定預期時間長度、指定目標資訊 每個廣告插播的參數

如果是實際工作環境和測試串流,請呼叫 EABN API,尤其是在廣告 是否有任何程式輔助廣告活動若需更多資訊,請參閲 程式輔助直接交易功能與指南

提出串流註冊要求

當使用者在您的影片播放器應用程式中開始內容串流時,您就可以製作串流 以及用來建立串流工作階段的註冊要求 到此告一段落如要進一步瞭解如何提出串流註冊要求,請參閱 Method:stream。 之後,您會收到 回應資料

下列範例可提出串流註冊要求:

純文字 HTTP

  • 要求:
authority: dai.google.com
method: POST
path: /ssai/pods/api/v1/network/51636543/custom_asset/hls-podserving-manifest/stream
scheme: https
content-type: application/x-www-form-urlencoded

cust_params=customID%253D1543216789%2526anotherKey%253Dvalue1%252Cvalue2
  • 回應:
{
    "manifest_format": "hls",
    "media_verification_url": "https://dai.google.com/view/p/service/linear/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/loc/TUL/network/51636543/event/TFyZF0IoSpqvCLtLv8JdCw/media/",
    "metadata_url": "https://dai.google.com/linear/pods/hls/pa/event/TFyZF0IoSpqvCLtLv8JdCw/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/metadata",
    "polling_frequency": 10,
    "session_update_url": "https://dai.google.com/linear/v1/pa/event/TFyZF0IoSpqvCLtLv8JdCw/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/session",
    "stream_id": "24fd4e7c-95a0-42be-8874-00625139b9db:TUL"
}

Shell

  • 指令列:
curl \
-H "Host: dai.google.com" \
-H "content-type: application/x-www-form-urlencoded" \
  --data-binary "cust_params=channelID%253D1543216789%2526anotherKey%253Dvalue1%252Cvalue2" \
  --compressed "https://dai.google.com/ssai/pods/api/v1/network/51636543/custom_asset/hls-podserving-manifest/stream"
  • 輸出:
{
    "manifest_format": "hls",
    "media_verification_url": "https://dai.google.com/view/p/service/linear/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/loc/TUL/network/51636543/event/TFyZF0IoSpqvCLtLv8JdCw/media/",
    "metadata_url": "https://dai.google.com/linear/pods/hls/pa/event/TFyZF0IoSpqvCLtLv8JdCw/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/metadata",
    "pod_manifest_url": "https://dai.google.com/linear/pods/v1/hls/event/TFyZF0IoSpqvCLtLv8JdCw/pod/$pod-id$.m3u8?stream_id=24fd4e7c-95a0-42be-8874-00625139b9db%3ATUL",
    "polling_frequency": 10,
    "session_update_url": "https://dai.google.com/linear/v1/pa/event/TFyZF0IoSpqvCLtLv8JdCw/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/session",
    "stream_id": "24fd4e7c-95a0-42be-8874-00625139b9db:TUL"
}

JavaScript

  • 使用 Fetch API:
const response = await fetch("https://dai.google.com/ssai/pods/api/v1/network/51636543/custom_asset/hls-podserving-manifest/stream", {
  "headers": {
    "content-type": "application/x-www-form-urlencoded",
  },
  "body": "cust_params=channelID%3D1543216789%26anotherKey%3Dvalue1%2Cvalue2",
  "method": "POST",
});

  const stream = await response.json();
  console.log(stream);
  • 控制台記錄:
{
    "stream_id": "24fd4e7c-95a0-42be-8874-00625139b9db:TUL",
    "media_verification_url": "https://dai.google.com/view/p/service/linear/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/loc/TUL/network/51636543/event/TFyZF0IoSpqvCLtLv8JdCw/media/",
    "metadata_url": "https://dai.google.com/linear/pods/hls/pa/event/TFyZF0IoSpqvCLtLv8JdCw/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/metadata",
    "session_update_url": "https://dai.google.com/linear/v1/pa/event/TFyZF0IoSpqvCLtLv8JdCw/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/session",
    "polling_frequency": 10,
    "pod_manifest_url": "https://dai.google.com/linear/pods/v1/hls/event/TFyZF0IoSpqvCLtLv8JdCw/pod/$pod-id$.m3u8?stream_id=24fd4e7c-95a0-42be-8874-00625139b9db%3ATUL",
    "manifest_format": "hls"
}

廣告插播中繼資料意見調查

提出串流註冊要求後,系統會輪詢廣告中繼資料。目的地: 意見調查,請使用在以下位置的串流回應中,使用 polling_frequence 設定計時器: 呼叫廣告 中繼資料。 針對每項意見調查,你可能會收到一部分廣告,含有相關中繼資料 可供使用。

產生廣告連播資訊清單網址

為 Pod Serving API 的Pod 資源建構網址。接著將網址傳遞給影片播放器 載入廣告連播

以下範例說明廣告連播資訊清單網址的結構:

https://dai.google.com/linear/pods/v1/hls/network/51636543/custom_asset/pod_serving_hls_manifest_mp4/pod/101.m3u8?stream_id=24fd4e7c-95a0-42be-8874-00625139b9db:TUL&pd=120000

您可以根據廣告插播時間點計算廣告連播資訊清單網址參數 擷取自影片播放器或伺服器通知適用對象 需要這些參數的需求條件,請參閱 方法:Pod 資訊清單

播放廣告連播資訊清單

在用戶端影片播放器應用程式中,必須有一個主要的 並按照影片播放器的說明文件操作 播放和廣告時段 (如有需要)。

如果您產生了廣告連播資訊清單網址,並將網址插入 觀察影片播放器即將進行的廣告插播事件,並確保 訂閱每個廣告插播期間的 id3 事件。如果排定廣告時段 中斷事件,並在建立時訂閱 id3 事件。

回報曝光和廣告事件

當影片播放器播放廣告連播,並收到 ID 為 3 時序的中繼資料時 會監聽廣告事件 影片播放器會觸發並處理 傳送媒體驗證連線偵測 (ping)