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-02-28。
[null,null,["最后更新时间 (UTC):2025-02-28。"],[[["This 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)."],["The 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 deliver ads to the player."],["The video player then plays the ads, and the IMA SDK manages tracking events like impressions and VAST events for ad performance monitoring."],["The guide also details the full lifecycle of the IMA SDK, including constructor and method calls, events, and potential error conditions for comprehensive understanding and troubleshooting."]]],[]]