When playlists are out of sync, seek
Live streams in particular may have variant playlists with content windows that are out of sync. Keep playback rolling in the simplest way possible by seeking into the new buffered region whenever this occurs. This is not an ideal user-experience.
Showing
1 changed file
with
12 additions
and
0 deletions
... | @@ -311,6 +311,8 @@ videojs.Hls.prototype.setupSourceBuffer_ = function() { | ... | @@ -311,6 +311,8 @@ videojs.Hls.prototype.setupSourceBuffer_ = function() { |
311 | return; | 311 | return; |
312 | } | 312 | } |
313 | 313 | ||
314 | // if the codecs were explicitly specified, pass them along to the | ||
315 | // source buffer | ||
314 | mimeType = 'video/mp2t'; | 316 | mimeType = 'video/mp2t'; |
315 | if (media.attributes && media.attributes.CODECS) { | 317 | if (media.attributes && media.attributes.CODECS) { |
316 | mimeType += '; codecs="' + media.attributes.CODECS + '"'; | 318 | mimeType += '; codecs="' + media.attributes.CODECS + '"'; |
... | @@ -324,6 +326,16 @@ videojs.Hls.prototype.setupSourceBuffer_ = function() { | ... | @@ -324,6 +326,16 @@ videojs.Hls.prototype.setupSourceBuffer_ = function() { |
324 | this.mediaIndex === this.playlists.media().segments.length) { | 326 | this.mediaIndex === this.playlists.media().segments.length) { |
325 | this.mediaSource.endOfStream(); | 327 | this.mediaSource.endOfStream(); |
326 | } | 328 | } |
329 | |||
330 | // when switching renditions or seeking, we may misjudge the media | ||
331 | // index to request to continue playback. check after each append | ||
332 | // that our buffering is productive and seek if necessary to | ||
333 | // continue playback | ||
334 | if (this.tech_.buffered().length && | ||
335 | this.tech_.currentTime() < this.tech_.buffered().start(this.tech_.buffered().length - 1)) { | ||
336 | videojs.log('Variants out of sync. Seeking to continue.'); | ||
337 | this.tech_.setCurrentTime(this.tech_.buffered().start(this.tech_.buffered().length - 1)); | ||
338 | } | ||
327 | }.bind(this)); | 339 | }.bind(this)); |
328 | }; | 340 | }; |
329 | 341 | ... | ... |
-
Please register or sign in to post a comment