了解 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)由广告代码网址决定。
广告服务器选择最佳广告,并向 IMA SDK 发送 VAST 响应。
系统会使用以下方法之一来选择广告:
- Ad Manager 广告单元过滤订单项候选对象
- AdSense 或 Ad Exchange 会进行竞价
IMA SDK 会解析 VAST 响应,根据环境确定正确的媒体类型,并将内嵌视频广告素材(以及随播广告,如果需要的话)投放到网页或应用中。
视频播放器与 IMA SDK 协商播放详情,然后播放广告。
IMA SDK 会根据需要触发展示 ping 和 VAST 跟踪事件。
Lifecycle
此图显示了 IMA SDK 的完整生命周期。构造函数和方法调用以蓝色突出显示,事件以红色突出显示,错误情况以红色连接线和红色文字显示。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):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."]]