降低延时
如需缩短启用了 IMA 的网页中的延迟时间,关键在于尽早进行尽可能多的与 IMA 相关的设置。在投放广告之前,您可以提前在网页上完成以下所有操作:
- 创建
AdDisplayContainer
。
- 创建
AdsLoader
。
- 创建
AdsRequest
。
- 请求广告。
- 获取
AdsManager
实例并注册事件处理脚本。
完成上述所有操作后,系统会初始化 IMA SDK 并请求和解析您的广告响应,所有这一切都在用户甚至点击播放您的视频之前完成。当您准备好播放广告时,请调用
AdDisplayContainer.initialize()
(始终根据用户操作执行),然后调用
AdsManager.init
和
AdsManager.start
。如需详细了解如何提高整个网页的响应速度,请参阅 Chrome 文档中的
评估网络性能提示。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-02-28。
[null,null,["最后更新时间 (UTC):2025-02-28。"],[[["To minimize latency in IMA-enabled web pages, perform IMA setup tasks like creating `AdDisplayContainer`, `AdsLoader`, `AdsRequest`, requesting ads, and obtaining the `AdsManager` instance early in the page lifecycle."],["By initializing the IMA SDK and handling ad responses before user interaction, you ensure smoother ad playback when the user initiates it."],["Before playing ads, call `AdDisplayContainer.initialize()` (triggered by user action), followed by `AdsManager.init` and `AdsManager.start` to begin ad playback."],["For broader page performance enhancements, consult Chrome's network performance evaluation resources."]]],[]]