mirror of https://bitbucket.org/ausocean/av.git
mjpeg-player: keeping track of loaded fragments
This commit is contained in:
parent
4e4eaf95d4
commit
445fc6bc71
|
@ -38,20 +38,30 @@ class StreamController extends EventHandler {
|
|||
this.audioCodecSwap = false;
|
||||
this.stallReported = false;
|
||||
this.gapController = null;
|
||||
this.currentFrag = 0;
|
||||
this.currentFragIndex = 0;
|
||||
this.lastSN = 0;
|
||||
this.fragments = [];
|
||||
}
|
||||
|
||||
_fetchPayloadOrEos(levelDetails) {
|
||||
this.fragments = levelDetails.fragments;
|
||||
// Keep track of any new frags and load them.
|
||||
for (let i = 0; i < levelDetails.fragments.length; i++) {
|
||||
let frag = levelDetails.fragments[i];
|
||||
if (frag.sn > this.lastSN) {
|
||||
console.log("adding fragment: " + frag.sn);
|
||||
this.fragments.push(frag);
|
||||
this.lastSN = frag.sn;
|
||||
}
|
||||
}
|
||||
this._loadFragment();
|
||||
}
|
||||
|
||||
_loadFragment() {
|
||||
let fragLen = this.fragments.length;
|
||||
if (this.currentFrag >= fragLen) {
|
||||
if (this.currentFragIndex >= fragLen) {
|
||||
return;
|
||||
}
|
||||
this.hls.trigger(Event.FRAG_LOADING, { frag: this.fragments[this.currentFrag++] });
|
||||
this.hls.trigger(Event.FRAG_LOADING, { frag: this.fragments[this.currentFragIndex++] });
|
||||
}
|
||||
|
||||
onLevelLoaded(data) {
|
||||
|
@ -63,11 +73,6 @@ class StreamController extends EventHandler {
|
|||
|
||||
console.log(`level ${newLevelId} loaded [${newDetails.startSN},${newDetails.endSN}],duration:${duration}`);
|
||||
|
||||
if (newDetails.live) {
|
||||
console.log("handling of this case is not implemented");
|
||||
} else {
|
||||
newDetails.PTSKnown = false;
|
||||
}
|
||||
// override level info
|
||||
this.levelLastLoaded = newLevelId;
|
||||
this.hls.trigger(Event.LEVEL_UPDATED, { details: newDetails, level: newLevelId });
|
||||
|
@ -96,7 +101,6 @@ class StreamController extends EventHandler {
|
|||
}
|
||||
this.nextLoadPosition = this.startPosition;
|
||||
}
|
||||
|
||||
this._fetchPayloadOrEos(levelDetails);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue