Skip to content

Commit

Permalink
fix(UI): Remove spinner and client side ad container elements when ca…
Browse files Browse the repository at this point in the history
…lling destroy (#7320)

Fixes #7311

Original author: @absidue
  • Loading branch information
avelad committed Sep 18, 2024
1 parent 5b4565e commit 192f9ad
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions ui/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
this.castProxy_ = null;
}

if (this.spinnerContainer_) {
this.videoContainer_.removeChild(this.spinnerContainer_);
this.spinnerContainer_ = null;
}

if (this.clientAdContainer_) {
this.videoContainer_.removeChild(this.clientAdContainer_);
this.clientAdContainer_ = null;
}

if (this.localPlayer_) {
await this.localPlayer_.destroy();
this.localPlayer_ = null;
Expand Down Expand Up @@ -524,6 +534,8 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
* @export
*/
getClientSideAdContainer() {
goog.asserts.assert(
this.clientAdContainer_, 'No client ad container after destruction!');
return this.clientAdContainer_;
}

Expand Down Expand Up @@ -982,7 +994,7 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {

/** @private */
addBufferingSpinner_() {
/** @private {!HTMLElement} */
/** @private {HTMLElement} */
this.spinnerContainer_ = shaka.util.Dom.createHTMLElement('div');
this.spinnerContainer_.classList.add('shaka-spinner-container');
this.videoContainer_.appendChild(this.spinnerContainer_);
Expand Down Expand Up @@ -1139,7 +1151,7 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
* @private
*/
addClientAdContainer_() {
/** @private {!HTMLElement} */
/** @private {HTMLElement} */
this.clientAdContainer_ = shaka.util.Dom.createHTMLElement('div');
this.clientAdContainer_.classList.add('shaka-client-side-ad-container');
shaka.ui.Utils.setDisplay(this.clientAdContainer_, false);
Expand Down

0 comments on commit 192f9ad

Please sign in to comment.