瞭解 SDK 架構
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本指南會簡要說明 SDK 生命週期,以及影片播放器、IMA SDK 和廣告伺服器之間的互動。
基本互動
下圖說明影片播放器、IMA SDK 和廣告伺服器之間的互動,並附上註解。廣告伺服器可使用 Ad Manager、AdSense 影片廣告 (AFV) 或 Ad Exchange (AdX)。

網頁或應用程式使用下列方式載入 IMA SDK:
- HTML5 的嵌入式指令碼標記
- Android、Google Cast、iOS 或 tvOS 應用程式
IMA SDK 會向廣告伺服器請求特定廣告單元的 VAST 回應。系統會根據廣告代碼網址,判斷要呼叫 Ad Manager、AFV 或 AdX 廣告伺服器。
廣告伺服器會選取最適合的廣告,並將 VAST 回應傳送至 IMA SDK。
系統會使用下列其中一種方法選取廣告:
- Ad Manager 廣告單元會篩除委刊項候選項目
- AdSense 或 Ad Exchange 執行競價
IMA SDK 會剖析 VAST 回應、根據環境判斷正確的媒體類型,並將內嵌影片廣告素材 (如有需要,也會將隨播廣告) 傳送至網頁或應用程式。
影片播放器會與 IMA SDK 協商播放詳細資料,並播放廣告。
IMA SDK 會視需要觸發曝光偵測訊號和 VAST 追蹤事件。
生命週期
這張圖顯示 IMA SDK 的完整生命週期。建構函式和方法呼叫會以藍色醒目顯示,事件會以紅色醒目顯示,錯誤狀況則會以紅色連接器和紅色文字顯示。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\u003cp\u003eThis guide explains the lifecycle of the Interactive Media Ads (IMA) SDK and how it facilitates communication between your video player, the SDK, and an ad server (Ad Manager, AdSense for Video, or Ad Exchange).\u003c/p\u003e\n"],["\u003cp\u003eThe process involves the IMA SDK requesting ads from the ad server based on the provided ad tag URL, the ad server selecting and sending a VAST response, and the SDK parsing this response to display ads within the video player.\u003c/p\u003e\n"],["\u003cp\u003eThe IMA SDK handles playback negotiation with the video player and manages ad impressions and tracking events for accurate reporting.\u003c/p\u003e\n"]]],[],null,["Select platform: [HTML5](/interactive-media-ads/docs/sdks/html5/client-side/architecture \"View this page for the HTML5 platform docs.\") [Android](/interactive-media-ads/docs/sdks/android/client-side/architecture \"View this page for the Android platform docs.\") [iOS](/interactive-media-ads/docs/sdks/ios/client-side/architecture \"View this page for the iOS platform docs.\") [tvOS](/interactive-media-ads/docs/sdks/tvos/client-side/architecture \"View this page for the tvOS platform docs.\")\n\n\u003cbr /\u003e\n\nThis guide provides an overview of the SDK lifecycle and the interactions\nbetween your video player, the IMA SDK, and an ad server.\n\nBasic interactions\n\nThe following diagram illustrates and annotates the interactions between\nyour video player, the IMA SDK, and an ad server. The ad server can use\nAd Manager, AdSense for Video (AFV), or Ad Exchange (AdX).\n\n1. The web page or app loads the IMA SDK using:\n\n - an embedded script tag for HTML5\n - an app for Android, Google Cast, iOS, or tvOS\n2. The IMA SDK requests a VAST Response for the specific Ad Unit on the ad\n server. The ad server called, which can be either Ad Manager versus AFV or\n AdX, is determined by the ad tag URL.\n\n3. The ad server selects the best ad and sends a VAST response to the IMA SDK.\n Ads are selected using one of the following methods:\n\n - Ad Manager Ad Unit filters Line Item candidates\n - AdSense or Ad Exchange runs an auction\n4. The IMA SDK parses the VAST response, determines the correct media type based\n on environment, and delivers the inline video creative (and\n companion ads if needed) to the web page or app.\n\n5. The video player negotiates the playback details with the IMA SDK and plays\n the ads.\n\n6. The IMA SDK fires an impression ping and VAST tracking events, as needed.\n\nLifecycle\n\nThis diagram shows the full lifecycle of the IMA SDK. Constructor and method\ncalls are highlighted in blue, events are highlighted in red, and error\nconditions are shown with red connectors and red text."]]