mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-14 15:56:38 +03:00
655493f441
Previously, the client-side ad container was put inside the controls container, which was cleared when the UI was configured. This meant that re-configuring the UI made client-side ads go away, basically. This moves client-side ads to go into their own container, which is never re-made or uprooted, even when the DOM is recreated, in order to not break the IMA SDK. This has the side-effect of fixing a bug where client-side ads were not always cleared upon loading a new asset, and could show up unexpectedly in future playbacks. Fixes #2869 Fixes #2943 Change-Id: I3cf67b0b278764c10c6ff2f678316dc9cc85929e
104 lines
2.1 KiB
JavaScript
104 lines
2.1 KiB
JavaScript
/*! @license
|
|
* Shaka Player
|
|
* Copyright 2016 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
|
|
goog.provide('shaka.ui.Element');
|
|
|
|
goog.require('shaka.ads.AdManager');
|
|
goog.require('shaka.util.EventManager');
|
|
goog.requireType('shaka.Player');
|
|
goog.requireType('shaka.ui.Controls');
|
|
goog.requireType('shaka.ui.Localization');
|
|
|
|
|
|
/**
|
|
* @implements {shaka.extern.IUIElement}
|
|
* @abstract
|
|
* @export
|
|
*/
|
|
shaka.ui.Element = class {
|
|
/**
|
|
* @param {!HTMLElement} parent
|
|
* @param {!shaka.ui.Controls} controls
|
|
*/
|
|
constructor(parent, controls) {
|
|
/**
|
|
* @protected {HTMLElement}
|
|
* @exportInterface
|
|
*/
|
|
this.parent = parent;
|
|
|
|
/**
|
|
* @protected {shaka.ui.Controls}
|
|
* @exportInterface
|
|
*/
|
|
this.controls = controls;
|
|
|
|
/**
|
|
* @protected {shaka.util.EventManager}
|
|
* @exportInterface
|
|
*/
|
|
this.eventManager = new shaka.util.EventManager();
|
|
|
|
/**
|
|
* @protected {shaka.ui.Localization}
|
|
* @exportInterface
|
|
*/
|
|
this.localization = this.controls.getLocalization();
|
|
|
|
/**
|
|
* @protected {shaka.Player}
|
|
* @exportInterface
|
|
*/
|
|
this.player = this.controls.getPlayer();
|
|
|
|
/**
|
|
* @protected {HTMLMediaElement}
|
|
* @exportInterface
|
|
*/
|
|
this.video = this.controls.getVideo();
|
|
|
|
/**
|
|
* @protected {shaka.extern.IAdManager}
|
|
* @exportInterface
|
|
*/
|
|
this.adManager = this.player.getAdManager();
|
|
|
|
/**
|
|
* @protected {?shaka.extern.IAd}
|
|
* @exportInterface
|
|
*/
|
|
this.ad = controls.getAd();
|
|
|
|
const AD_STARTED = shaka.ads.AdManager.AD_STARTED;
|
|
this.eventManager.listen(this.adManager, AD_STARTED, (e) => {
|
|
this.ad = (/** @type {!Object} */ (e))['ad'];
|
|
});
|
|
|
|
const AD_STOPPED = shaka.ads.AdManager.AD_STOPPED;
|
|
this.eventManager.listen(this.adManager, AD_STOPPED, () => {
|
|
this.ad = null;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @export
|
|
*/
|
|
release() {
|
|
this.eventManager.release();
|
|
|
|
this.parent = null;
|
|
this.controls = null;
|
|
this.eventManager = null;
|
|
this.localization = null;
|
|
this.player = null;
|
|
this.video = null;
|
|
this.adManager = null;
|
|
this.ad = null;
|
|
}
|
|
};
|