diff options
author | James Taylor <user234683@users.noreply.github.com> | 2021-08-28 19:04:45 -0700 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2021-08-29 22:55:41 -0500 |
commit | 92bdbf072eebe6d85276e195936efff5b8d5f42c (patch) | |
tree | 9a5753dcb13cde99c19b245015396eff8dcdc4fd /youtube/static/js | |
parent | 77fffee34f3a6d7965d0fe96bec593d4a9639f28 (diff) | |
download | yt-local-92bdbf072eebe6d85276e195936efff5b8d5f42c.tar.lz yt-local-92bdbf072eebe6d85276e195936efff5b8d5f42c.tar.xz yt-local-92bdbf072eebe6d85276e195936efff5b8d5f42c.zip |
av-merge: Fix error when switching qualities after endOfStream
After the video has been buffered to the end and
mediaSource.endOfStream() has been called, the close function
would perform some closing operations on the sourceBuffers
that gave InvalidStateError
Signed-off-by: Jesús <heckyel@hyperbola.info>
Diffstat (limited to 'youtube/static/js')
-rw-r--r-- | youtube/static/js/av-merge.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/youtube/static/js/av-merge.js b/youtube/static/js/av-merge.js index f820927..1d5ada6 100644 --- a/youtube/static/js/av-merge.js +++ b/youtube/static/js/av-merge.js @@ -83,7 +83,8 @@ AVMerge.prototype.close = function() { this.audioStream.close(); this.timeUpdateEvt.remove(); this.seekingEvt.remove(); - this.mediaSource.endOfStream(); + if (this.mediaSource.readyState == 'open') + this.mediaSource.endOfStream(); } AVMerge.prototype.checkBothBuffers = function() { this.audioStream.checkBuffer(); @@ -199,9 +200,10 @@ Stream.prototype.close = function() { // Prevents appendSegment adding to buffer if request finishes // after closing this.closed = true; - this.sourceBuffer.abort(); - this.updateendEvt.remove(); + if (this.sourceBuffer.updating) + this.sourceBuffer.abort(); this.mediaSource.removeSourceBuffer(this.sourceBuffer); + this.updateendEvt.remove(); } Stream.prototype.appendSegment = function(segmentIdx, chunk) { if (this.closed) |