diff --git a/externs/ima.js b/externs/ima.js index b23fb10bd3..bfdbab68f9 100644 --- a/externs/ima.js +++ b/externs/ima.js @@ -204,6 +204,8 @@ google.ima.AdDisplayContainer = class { constructor(adContainer, video) {} initialize() {} + + destroy() {} }; diff --git a/lib/ads/client_side_ad_manager.js b/lib/ads/client_side_ad_manager.js index 976e9b5675..7dbef48a73 100644 --- a/lib/ads/client_side_ad_manager.js +++ b/lib/ads/client_side_ad_manager.js @@ -63,16 +63,17 @@ shaka.ads.ClientSideAdManager = class { google.ima.settings.setDisableCustomPlaybackForIOS10Plus(true); - const adDisplayContainer = new google.ima.AdDisplayContainer( + /** @private {!google.ima.AdDisplayContainer} */ + this.adDisplayContainer_ = new google.ima.AdDisplayContainer( this.adContainer_, this.video_); // TODO: IMA: Must be done as the result of a user action on mobile - adDisplayContainer.initialize(); + this.adDisplayContainer_.initialize(); // IMA: This instance should be re-used for the entire lifecycle of // the page. - this.adsLoader_ = new google.ima.AdsLoader(adDisplayContainer); + this.adsLoader_ = new google.ima.AdsLoader(this.adDisplayContainer_); this.adsLoader_.getSettings().setPlayerType('shaka-player'); this.adsLoader_.getSettings().setPlayerVersion(shaka.Player.version); @@ -176,6 +177,7 @@ shaka.ads.ClientSideAdManager = class { this.imaAdsManager_.destroy(); } this.adsLoader_.destroy(); + this.adDisplayContainer_.destroy(); } /**