AdsManager is undefined when trying to play ads

13 views
Skip to first unread message

Abilash G

unread,
Oct 4, 2024, 3:58:15 PMOct 4
to Interactive Media Ads SDK
Hi,
I am trying to play a video ad with vast tag 4.0 but when I try to play an ad the adsManager is undefined.

function playAds()
{
    // Initialize the container. Must be done via a user action on mobile devices.
    adDisplayContainer.initialize();
    console.log("playADinit");

    try
    {
        // Initialize the ads manager. Ad rules playlist will start at this time.
        console.log("initializing adsmanager");
        adsManager.init(
            document.getElementById("videoadcontainer").clientWidth,
            document.getElementById("videoadcontainer").clientHeight,
            Google.ima.ViewMode.FULLSCREEN
        );


        // Call play to start showing the ad. Single video and overlay ads will start at this time
        //the call will be ignored for ad rules.

        adsManager.start();
        console.log("playADstart");
    } catch (adError)
    {
        console.error("playAds adError: ", adError);
        // An error may be thrown if there was a problem with the VAST response.
        onADCompletedCallBack(false);
        setUpAdsContainer();
        //console.log("playADerror");
    }
}

Could you help Me with this issue?

IMA SDK

unread,
Oct 7, 2024, 6:22:22 AMOct 7
to kavithagan...@gmail.com, ima...@googlegroups.com

Hi Abilash,

The undefined error in Ad Manager generally indicates an issue with the initialization of the ads manager object. When initializing the ad manager, you have provided document.getElementById("videoadcontainer").clientWidth and document.getElementById("videoadcontainer").clientHeight as arguments. These expressions return null, which is why you are getting the “adsManager is undefined” error.

Please check the function playAds() in Google HTML Sample Application for your reference.

Kindly reach out to us, if you need any further assistance.

This message is in relation to case "ref:!00D1U01174p.!5004Q02vGcNo:ref" (ADR-00270691)

Thanks,
 
Google Logo IMA SDK Team

 

Reply all
Reply to author
Forward
0 new messages