Skip to content

Commit

Permalink
Fix level loading
Browse files Browse the repository at this point in the history
  • Loading branch information
gena committed Feb 20, 2016
1 parent c493571 commit 8038ac0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 15 deletions.
18 changes: 14 additions & 4 deletions dist/hls.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/hls.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/hls.min.js

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions src/controller/stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class StreamController extends EventHandler {
var curlevel = this.levels[frag.level];
// if subtitle exist
if(!((curlevel.detailsSubt === undefined) || (curlevel.detailsSubt.fragments.length === 0))) {
// find corresponded subtitle fragment
// find corresponded subtitle fragment for VOD wit single subtitle
if(curlevel.detailsSubt.fragments.length === 1) {
if(!frag.subt || (frag.subt.url !== curlevel.detailsSubt.fragments[0].url)) {
var subt = curlevel.detailsSubt.fragments[0];
Expand All @@ -320,6 +320,9 @@ class StreamController extends EventHandler {
}
}
}
if(!frag.subt) {
logger.warn(`streamController: subtitle not found SEQ: ${frag.sn} plst start SEQ: ${curlevel.detailsSubt.fragments[0].sn}`);
}
}
// if audio exist
if(!((curlevel.detailsAudio === undefined) || (curlevel.detailsAudio.fragments.length === 0))) {
Expand All @@ -331,6 +334,9 @@ class StreamController extends EventHandler {
break;
}
}
if(!frag.audio) {
logger.warn(`streamController: audio not found SEQ: ${frag.sn} plst start SEQ: ${curlevel.detailsAudio.fragments[0].sn}`);
}
}

this.fragCurrent = frag;
Expand All @@ -344,10 +350,12 @@ class StreamController extends EventHandler {
case State.WAITING_LEVEL:
level = this.levels[this.level];
// check if playlist is already loaded
if (level && level.details) {
// if (level && level.details) {
if (level && level.ready) {
this.state = State.IDLE;
}
break;

case State.FRAG_LOADING:
/*
monitor fragment retrieval time...
Expand Down Expand Up @@ -789,6 +797,7 @@ class StreamController extends EventHandler {
switch(plstTypeId)
{
case 1: // VIDEO playlist
curLevel.ready = false;
curDetails = curLevel.details;
break;
case 2:
Expand Down Expand Up @@ -862,6 +871,7 @@ class StreamController extends EventHandler {
this.nextLoadPosition = this.startPosition;
}
// only switch batck to IDLE state if we were waiting for level to start downloading a new fragment
curLevel.ready = true;
if (this.state === State.WAITING_LEVEL) {
this.state = State.IDLE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/webvtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class WebVTTSubt

}
// remove old cue for live stream
if(this._textTrack) {
if(this._textTrack && this._textTrack.cues) {
if(this._hls.liveStream && this._textTrack.cues && (this._textTrack.cues.length > 0)) {
var tm = this.lastCueTime - 120;
while(this._textTrack.cues[0].startTime < tm) {
Expand Down

0 comments on commit 8038ac0

Please sign in to comment.