From 3ac11d0463da239dfdbeca31afe8f7ce3236958a Mon Sep 17 00:00:00 2001 From: Brandon Casey <2381475+brandonocasey@users.noreply.github.com> Date: Mon, 13 Apr 2020 12:00:04 -0400 Subject: [PATCH] fix: update being called on seekbar during dispose (#6576) --- .../control-bar/progress-control/seek-bar.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/js/control-bar/progress-control/seek-bar.js b/src/js/control-bar/progress-control/seek-bar.js index 2d4d5ccb84..90bdfbfdd3 100644 --- a/src/js/control-bar/progress-control/seek-bar.js +++ b/src/js/control-bar/progress-control/seek-bar.js @@ -92,7 +92,7 @@ class SeekBar extends Slider { } disableInterval_(e) { - if (this.player_.liveTracker && this.player_.liveTracker.isLive() && e.type !== 'ended') { + if (this.player_.liveTracker && this.player_.liveTracker.isLive() && e && e.type !== 'ended') { return; } @@ -428,6 +428,26 @@ class SeekBar extends Slider { super.handleKeyDown(event); } } + + dispose() { + this.disableInterval_(); + + this.off(this.player_, ['ended', 'durationchange', 'timeupdate'], this.update); + if (this.player_.liveTracker) { + this.on(this.player_.liveTracker, 'liveedgechange', this.update); + } + + this.off(this.player_, ['playing'], this.enableInterval_); + this.off(this.player_, ['ended', 'pause', 'waiting'], this.disableInterval_); + + // we don't need to update the play progress if the document is hidden, + // also, this causes the CPU to spike and eventually crash the page on IE11. + if ('hidden' in document && 'visibilityState' in document) { + this.off(document, 'visibilitychange', this.toggleVisibility_); + } + + super.dispose(); + } } /**