From 5ff216d1ba30e80859cd9d02b50671d31e1678bb Mon Sep 17 00:00:00 2001 From: James Taylor Date: Wed, 25 Aug 2021 14:29:40 -0700 Subject: avmerge: Fix errors if close is called twice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This can happen if the quality is changed from an avmerge source to an integrated source, and then changed back to an avmerge source Close is called the first change, but on the last change, it's called again because the avMerge object is still present, resulting in InvalidStateError Signed-off-by: Jesús --- youtube/static/js/av-merge.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'youtube') diff --git a/youtube/static/js/av-merge.js b/youtube/static/js/av-merge.js index d05d2c1..13551fb 100644 --- a/youtube/static/js/av-merge.js +++ b/youtube/static/js/av-merge.js @@ -37,6 +37,7 @@ function AVMerge(video, srcPair, startTime){ this.startTime = startTime; this.video = video; this.mediaSource = null; + this.closed = false; this.setup(); } AVMerge.prototype.setup = function() { @@ -67,6 +68,9 @@ AVMerge.prototype.sourceOpen = function(_) { //this.video.onseeked = function() {console.log('seeked')}; } AVMerge.prototype.close = function() { + if (this.closed) + return; + this.closed = true; this.videoStream.close(); this.audioStream.close(); this.timeUpdateEvt.remove(); -- cgit v1.2.3