Skip to content

Commit

Permalink
stream-controller: fix fragLoopLoadingError/playback stall on seeking…
Browse files Browse the repository at this point in the history
…/replay

allow seeking to nearest close buffered range while seeking
no frag look up tolerance while seeking

related to https://github.com/dailymotion/hls.js/issues/472
related to https://github.com/dailymotion/hls.js/issues/476
  • Loading branch information
mangui committed Jun 9, 2016
1 parent aea1190 commit dc3bb03
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/controller/stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ class StreamController extends EventHandler {
case State.FRAG_LOADING_WAITING_RETRY:
var now = performance.now();
var retryDate = this.retryDate;
var media = this.media;
var isSeeking = media && media.seeking;
// if current time is gt than retryDate, or if media seeking let's switch to IDLE state to retry loading
if(!retryDate || (now >= retryDate) || isSeeking) {
logger.log(`mediaController: retryDate reached, switch back to IDLE state`);
Expand Down Expand Up @@ -714,8 +712,6 @@ 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 @@ -1042,11 +1038,6 @@ 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 @@ -1105,7 +1096,6 @@ _checkBuffer() {
var bufferInfo = BufferHelper.bufferInfo(media,currentTime,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 @@ -1139,8 +1129,7 @@ _checkBuffer() {
var nextBufferStart = bufferInfo.nextStart, delta = nextBufferStart-currentTime;
if(nextBufferStart &&
(delta < this.config.maxSeekHole) &&
(delta > 0) &&
(!media.seeking || this.fragLoopLoadingErrorOnSeeking)) { // allow adjusting currentTime if we faced a fragLoopLoading error on seeking
(delta > 0)) {
// 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 dc3bb03

Please sign in to comment.