When loading a segment, use the time we spend on an XHR to remove data in buffer before seekable
Showing
1 changed file
with
20 additions
and
1 deletions
... | @@ -982,7 +982,26 @@ videojs.HlsHandler.prototype.blacklistCurrentPlaylist_ = function(error) { | ... | @@ -982,7 +982,26 @@ videojs.HlsHandler.prototype.blacklistCurrentPlaylist_ = function(error) { |
982 | videojs.HlsHandler.prototype.loadSegment = function(segmentInfo) { | 982 | videojs.HlsHandler.prototype.loadSegment = function(segmentInfo) { |
983 | var | 983 | var |
984 | self = this, | 984 | self = this, |
985 | segment = segmentInfo.playlist.segments[segmentInfo.mediaIndex]; | 985 | segment = segmentInfo.playlist.segments[segmentInfo.mediaIndex], |
986 | removeToTime = 0, | ||
987 | seekable = this.seekable(); | ||
988 | |||
989 | // Chrome has a hard limit of 150mb of buffer and a very conservative "garbage collector" | ||
990 | // We manually clear out the old buffer to ensure we don't trigger the QuotaExceeded error | ||
991 | // on the source buffer during subsequent appends | ||
992 | if (this.sourceBuffer) { | ||
993 | // If we have a seekable range use that as the limit for what can be removed safely | ||
994 | // otherwise remove anything older than 1 minute before the current play head | ||
995 | if (seekable.length && seekable.start(0) > 0) { | ||
996 | removeToTime = seekable.start(0); | ||
997 | } else { | ||
998 | removeToTime = this.tech_.currentTime() - 60; | ||
999 | } | ||
1000 | |||
1001 | if (removeToTime > 0) { | ||
1002 | this.sourceBuffer.remove(0, removeToTime); | ||
1003 | } | ||
1004 | } | ||
986 | 1005 | ||
987 | // if the segment is encrypted, request the key | 1006 | // if the segment is encrypted, request the key |
988 | if (segment.key) { | 1007 | if (segment.key) { | ... | ... |
-
Please register or sign in to post a comment