mirror of https://bitbucket.org/ausocean/av.git
Merged in m3u-frag (pull request #359)
mjpeg-player: keeping track of loaded fragments Approved-by: Saxon Milton
This commit is contained in:
commit
8cbaa90cff
|
@ -38,20 +38,30 @@ class StreamController extends EventHandler {
|
||||||
this.audioCodecSwap = false;
|
this.audioCodecSwap = false;
|
||||||
this.stallReported = false;
|
this.stallReported = false;
|
||||||
this.gapController = null;
|
this.gapController = null;
|
||||||
this.currentFrag = 0;
|
this.currentFragIdx = 0;
|
||||||
|
this.lastSN = 0;
|
||||||
|
this.fragments = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
_fetchPayloadOrEos(levelDetails) {
|
_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();
|
this._loadFragment();
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadFragment() {
|
_loadFragment() {
|
||||||
let fragLen = this.fragments.length;
|
let fragLen = this.fragments.length;
|
||||||
if (this.currentFrag >= fragLen) {
|
if (this.currentFragIdx >= fragLen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.hls.trigger(Event.FRAG_LOADING, { frag: this.fragments[this.currentFrag++] });
|
this.hls.trigger(Event.FRAG_LOADING, { frag: this.fragments[this.currentFragIdx++] });
|
||||||
}
|
}
|
||||||
|
|
||||||
onLevelLoaded(data) {
|
onLevelLoaded(data) {
|
||||||
|
@ -63,11 +73,6 @@ class StreamController extends EventHandler {
|
||||||
|
|
||||||
console.log(`level ${newLevelId} loaded [${newDetails.startSN},${newDetails.endSN}],duration:${duration}`);
|
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
|
// override level info
|
||||||
this.levelLastLoaded = newLevelId;
|
this.levelLastLoaded = newLevelId;
|
||||||
this.hls.trigger(Event.LEVEL_UPDATED, { details: newDetails, level: newLevelId });
|
this.hls.trigger(Event.LEVEL_UPDATED, { details: newDetails, level: newLevelId });
|
||||||
|
@ -96,7 +101,6 @@ class StreamController extends EventHandler {
|
||||||
}
|
}
|
||||||
this.nextLoadPosition = this.startPosition;
|
this.nextLoadPosition = this.startPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._fetchPayloadOrEos(levelDetails);
|
this._fetchPayloadOrEos(levelDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue