Skip to content

Commit

Permalink
stream-controller: allow seekOverHole in case of media is seeking and…
Browse files Browse the repository at this point in the history
… fragLoopLoadingError just occured

fix fragLoopLoadingError looping in Firefox
related to https://github.com/dailymotion/hls.js/issues/476
  • Loading branch information
mangui committed Jun 9, 2016
1 parent 93bc1f3 commit aea1190
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/controller/stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,8 @@ class StreamController extends EventHandler {

onMediaSeeked() {
logger.log('media seeked to ' + this.media.currentTime);
// reset flag, used to potentially recover fragLoopLoadingError on seeking
this.fragLoopLoadingErrorOnSeeking = false;
// tick to speed up FRAGMENT_PLAYING triggering
this.tick();
}
Expand Down Expand Up @@ -1040,6 +1042,11 @@ class StreamController extends EventHandler {
}
break;
case ErrorDetails.FRAG_LOOP_LOADING_ERROR:
let media = this.media;
if (media && media.seeking) {
this.fragLoopLoadingErrorOnSeeking = true;
}
/* falls through */
case ErrorDetails.LEVEL_LOAD_ERROR:
case ErrorDetails.LEVEL_LOAD_TIMEOUT:
case ErrorDetails.KEY_LOAD_ERROR:
Expand Down Expand Up @@ -1096,7 +1103,10 @@ _checkBuffer() {
logger.log(`target seek position:${targetSeekPosition}`);
}
var bufferInfo = BufferHelper.bufferInfo(media,currentTime,0),
expectedPlaying = !(media.paused || media.ended || media.seeking || media.buffered.length === 0),
expectedPlaying = !(media.paused || // not playing when media is paused
media.ended || // not playing when media is ended
media.seeking && !this.fragLoopLoadingErrorOnSeeking || // not playing when media is seeking AND no fragLoopLoadingError on seeking
media.buffered.length === 0), // not playing if nothing buffered
jumpThreshold = 0.4, // tolerance needed as some browsers stalls playback before reaching buffered range end
playheadMoving = currentTime > media.playbackRate*this.lastCurrentTime;

Expand Down Expand Up @@ -1130,7 +1140,7 @@ _checkBuffer() {
if(nextBufferStart &&
(delta < this.config.maxSeekHole) &&
(delta > 0) &&
!media.seeking) {
(!media.seeking || this.fragLoopLoadingErrorOnSeeking)) { // allow adjusting currentTime if we faced a fragLoopLoading error on seeking
// next buffer is close ! adjust currentTime to nextBufferStart
// this will ensure effective video decoding
logger.log(`adjust currentTime from ${media.currentTime} to next buffered @ ${nextBufferStart} + nudge ${this.seekHoleNudgeDuration}`);
Expand Down

0 comments on commit aea1190

Please sign in to comment.