mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update hls playback
This commit is contained in:
parent
7919706532
commit
396b125d66
27 changed files with 438 additions and 728 deletions
|
@ -218,7 +218,7 @@ class StreamController extends EventHandler {
|
|||
// level 1 loaded [182580162,182580168] <============= here we should have bufferEnd > end. in that case break to avoid reloading 182580168
|
||||
// level 1 loaded [182580164,182580171]
|
||||
//
|
||||
if (bufferEnd > end) {
|
||||
if (levelDetails.PTSKnown && bufferEnd > end) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -486,13 +486,11 @@ class StreamController extends EventHandler {
|
|||
fragCurrent.loader.abort();
|
||||
}
|
||||
this.fragCurrent = null;
|
||||
// flush everything
|
||||
this.hls.trigger(Event.BUFFER_FLUSHING, {startOffset: 0, endOffset: Number.POSITIVE_INFINITY});
|
||||
this.state = State.PAUSED;
|
||||
// increase fragment load Index to avoid frag loop loading error after buffer flush
|
||||
this.fragLoadIdx += 2 * this.config.fragLoadingLoopThreshold;
|
||||
// speed up switching, trigger timer function
|
||||
this.tick();
|
||||
this.state = State.PAUSED;
|
||||
// flush everything
|
||||
this.hls.trigger(Event.BUFFER_FLUSHING, {startOffset: 0, endOffset: Number.POSITIVE_INFINITY});
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -515,12 +513,14 @@ class StreamController extends EventHandler {
|
|||
we should take into account new segment fetch time
|
||||
*/
|
||||
var fetchdelay, currentRange, nextRange;
|
||||
// increase fragment load Index to avoid frag loop loading error after buffer flush
|
||||
this.fragLoadIdx += 2 * this.config.fragLoadingLoopThreshold;
|
||||
currentRange = this.getBufferRange(this.media.currentTime);
|
||||
if (currentRange && currentRange.start > 1) {
|
||||
// flush buffer preceding current fragment (flush until current fragment start offset)
|
||||
// minus 1s to avoid video freezing, that could happen if we flush keyframe of current video ...
|
||||
this.hls.trigger(Event.BUFFER_FLUSHING, {startOffset: 0, endOffset: currentRange.start - 1});
|
||||
this.state = State.PAUSED;
|
||||
this.hls.trigger(Event.BUFFER_FLUSHING, {startOffset: 0, endOffset: currentRange.start - 1});
|
||||
}
|
||||
if (!this.media.paused) {
|
||||
// add a safety delay of 1s
|
||||
|
@ -540,17 +540,15 @@ class StreamController extends EventHandler {
|
|||
// we can flush buffer range following this one without stalling playback
|
||||
nextRange = this.followingBufferRange(nextRange);
|
||||
if (nextRange) {
|
||||
// flush position is the start position of this new buffer
|
||||
this.hls.trigger(Event.BUFFER_FLUSHING, {startOffset: nextRange.start, endOffset: Number.POSITIVE_INFINITY});
|
||||
this.state = State.PAUSED;
|
||||
// if we are here, we can also cancel any loading/demuxing in progress, as they are useless
|
||||
var fragCurrent = this.fragCurrent;
|
||||
if (fragCurrent && fragCurrent.loader) {
|
||||
fragCurrent.loader.abort();
|
||||
}
|
||||
this.fragCurrent = null;
|
||||
// increase fragment load Index to avoid frag loop loading error after buffer flush
|
||||
this.fragLoadIdx += 2 * this.config.fragLoadingLoopThreshold;
|
||||
// flush position is the start position of this new buffer
|
||||
this.state = State.PAUSED;
|
||||
this.hls.trigger(Event.BUFFER_FLUSHING, {startOffset: nextRange.start, endOffset: Number.POSITIVE_INFINITY});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1047,8 +1045,9 @@ _checkBuffer() {
|
|||
// 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}`);
|
||||
let hole = nextBufferStart + this.seekHoleNudgeDuration - media.currentTime;
|
||||
media.currentTime = nextBufferStart + this.seekHoleNudgeDuration;
|
||||
this.hls.trigger(Event.ERROR, {type: ErrorTypes.MEDIA_ERROR, details: ErrorDetails.BUFFER_SEEK_OVER_HOLE, fatal: false});
|
||||
this.hls.trigger(Event.ERROR, {type: ErrorTypes.MEDIA_ERROR, details: ErrorDetails.BUFFER_SEEK_OVER_HOLE, fatal: false, hole : hole});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue