0

我有一个视频播放器。每个视频都可以有不同的附加内容。

根据这个你应该只创建一次adLoader,重复使用。 https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side?hl=en

As a best practice, only maintain one instance of ima.AdsLoader for the entire lifecycle of a page. To make additional ad requests, create a new ima.AdsRequest object, but re-use the same ima.AdsLoader. For more information, see the IMA SDK FAQ.

但据此: https ://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/faq#8

它说

Call destroy() on your AdsManager instance. This prevents any post-rolls from playing when you make the below call to contentComplete(). You get a new AdsManager when you make your next request.

所以如果你销毁 AdsManager,那么你需要在调用 adsLoader.requestAds 之前创建一个新的。但是您只能在创建 AdsLoader 时调用的 adsManagerLoadedEvent 事件中创建 AdsManager。

adsLoader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, onAdsManagerLoaded,false);

4

0 回答 0