Problem with a function of the IMA SDK

Hello everyone!!

I have a problem with a function of the IMA SDK. When loading the page, this function is called, it fails and an error appears that says “Uncaught TypeError: a is undefined”. I leave you a photo of the error and the code of the function.

error

  /**
   * @param {!google.ima.AdsManagerLoadedEvent} adsManagerLoadedEvent
   */

  onAdsManagerLoaded(adsManagerLoadedEvent) {
    const adsRenderingSettings = new window.google.ima.AdsRenderingSettings()
    adsRenderingSettings.restoreCustomPlaybackStateOnAdBreakComplete = true

    adsManager = adsManagerLoadedEvent.getAdsManager(videoplayer, adsRenderingSettings)

    adsManager.addEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR, this.onAdError)

    adsManager.addEventListener(
      window.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,
      this.onContentResumeRequested,
    )

    adsManager.addEventListener(
      window.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,
      this.onContentResumeRequested,
    )

    adsManager.addEventListener(window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED, this.onAdEvent)

    adsManager.addEventListener(window.google.ima.AdEvent.Type.LOADED, this.onAdEvent)
    adsManager.addEventListener(window.google.ima.AdEvent.Type.STARTED, this.onAdEvent)
    adsManager.addEventListener(window.google.ima.AdEvent.Type.COMPLETE, this.onAdEvent)
  }

To implement the functions of the IMA SDK I used the simple example that comes in the official documentation.

I have managed to solve the problem, the function was not the only thing that was wrong :sweat_smile: