preload multiple adsManager instances

358 views
Skip to first unread message

amirgr

unread,
Apr 10, 2023, 10:18:48 AM4/10/23
to Interactive Media Ads SDK
Hey IMA team,
I am trying to preload multiple ads, i am not sure if my approach is correct.
I am using one adsLoader instance. For an ad that I want to preload, I am only loading the adsManager, and I will only call the init and start on the ads manager just before playing the ad. This can happen for a few ads, before playing a single ad. I am using getUserRequestContext to differentiate between the requests.
Is this the right approach? Also, is it possible to also init the adsManager during the preloading, or could it be bad to init multiple adsManager instances on a single adsLoader instance before trying to play them? 

Thanks

IMA SDK

unread,
Apr 11, 2023, 7:58:46 AM4/11/23
to amirgre...@gmail.com, ima...@googlegroups.com

Hello,

Thank you for raising your concern to the IMA SDK forum.

As a best practice, it is recommended to 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. When ads are loaded successfully, the ima.AdsLoader emits an ADS_MANAGER_LOADED event. Parse the event passed to the callback to initialize the AdsManager object. The AdsManager loads the individual ads as defined by the response to the ad tag URL.

For your concern, we recommend that your follow the SDK lifecycle, kindly refer to this document: https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/architecture#lifecycle where it shows the lifecycle diagram of the function calls made by you and events fired by the SDK.

Let me know if you have any questions and specify the IMA SDK implementation and platform you are using.

Regards,

Google Logo IMA SDK Team


ref:_00D1U1174p._5004Q2kTiYa:ref

amirgr

unread,
Apr 26, 2023, 7:23:03 AM4/26/23
to Interactive Media Ads SDK
Hey again, I am not sure if I need the preloading, and I am trying something slightly different.
I am trying to init one adsLoader, and use it to make multiple requests. For some reason, the second ad is not starting when it is the first one to have an adsManager instance. This is the general flow:
- init the adsLoader instance
- request first ad: adsLoader.requestAds(adsRequestA, contextA). adsManager loaded.
- request second ad: adsLoader.requestAds(adsRequestB, contextB). adsManager loaded
- play the second ad.
- second ad ends. destroy adsManager of the second ad.
- try to play the first ad (fails)
I am trying to understand why the ad is not starting. Can it be that because the ad is loaded first, but played second, something is disrupted in the process?

thanks

IMA SDK

unread,
Apr 26, 2023, 1:55:29 PM4/26/23
to amirgre...@gmail.com, ima...@googlegroups.com

Hello,

Thank you for getting back to us.

I understand that your implementation is different. With this, would you be able to specify the IMA SDK implementation and platform you are using as mentioned in our previous response? This is so we could provide appropriate guidance and insights for your use case.

If it helps, you may check the following links for handling multiple ad requests in different platforms. Please let us know if this fits your use case.

Reply all
Reply to author
Forward
0 new messages