Skip to content

Commit

Permalink
rename state NONE to NOT_LOADED
Browse files Browse the repository at this point in the history
  • Loading branch information
David Kim authored and David Kim committed Dec 8, 2017
1 parent a91b123 commit e14c9b0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/controller/audio-stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ class AudioStreamController extends EventHandler {
logger.log(`Loading ${frag.sn}, cc: ${frag.cc} of [${trackDetails.startSN} ,${trackDetails.endSN}],track ${trackId}, currentTime:${pos},bufferEnd:${bufferEnd.toFixed(3)}`);
// Check if fragment is not loaded
let ftState = this.fragmentTracker.getState(frag);
if(ftState === FragmentTrackerState.NONE) {
if(ftState === FragmentTrackerState.NOT_LOADED) {
this.fragCurrent = frag;
this.startFragRequested = true;
if (!isNaN(frag.sn)) {
Expand Down
2 changes: 1 addition & 1 deletion src/controller/stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ class StreamController extends EventHandler {
}

// Allow backtracked fragments to load
if(frag.backtracked || ftState === FragmentTrackerState.NONE) {
if(frag.backtracked || ftState === FragmentTrackerState.NOT_LOADED) {
frag.autoLevel = this.hls.autoLevelEnabled;
frag.bitrateTest = this.bitrateTest;

Expand Down
5 changes: 2 additions & 3 deletions src/helper/fragment-tracker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {logger} from '../utils/logger';
import EventHandler from '../event-handler';
import Event from '../events';

Expand All @@ -8,7 +7,7 @@ function getFragmentKey(fragment) {
}

export const FragmentTrackerState = {
NONE: 'NONE',
NOT_LOADED: 'NOT_LOADED',
LOADING_BUFFER: 'LOADING_BUFFER',
PARTIAL: 'PARTIAL',
GOOD: 'GOOD',
Expand Down Expand Up @@ -212,7 +211,7 @@ export class FragmentTracker extends EventHandler {
// Fragment only partially loaded
return FragmentTrackerState.PARTIAL;
}
return FragmentTrackerState.NONE;
return FragmentTrackerState.NOT_LOADED;
}

/**
Expand Down
28 changes: 27 additions & 1 deletion tests/functional/auto/hlsjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,31 @@ describe('testing hls.js playback in the browser on "'+browserDescription+'"', f
}
}

const testSeekStartVOD = function(url) {
return function() {
return this.browser.executeAsyncScript(function(url) {
var callback = arguments[arguments.length - 1];
startStream(url, callback);
video.onloadeddata = function() {
window.setTimeout(function() {
if(video.buffered.length > 0){
let startTime = video.buffered.start(0);
video.currentTime = 0;
video.onseeked = () => {
callback({ code : 'ended', dt : Math.abs(video.currentTime - startTime)});
}
} else {
callback({ code : 'not loaded'});
}
}, 5000);
};
}, url).then(function(result) {
assert.strictEqual(result.code, 'ended');
assert.strictEqual(result.dt < 1, true);
});
}
}

for (var name in streams) {
var stream = streams[name];
var url = stream.url;
Expand All @@ -220,7 +245,8 @@ describe('testing hls.js playback in the browser on "'+browserDescription+'"', f
if (stream.live) {
it('should seek near the end and receive video seeked event for ' + stream.description, testSeekOnLive(url));
} else {
it('should seek 5s from end and receive video ended event for ' + stream.description, testSeekOnVOD(url));
it('should seek to start ' + stream.description, testSeekStartVOD(url));
// it('should seek 5s from end and receive video ended event for ' + stream.description, testSeekOnVOD(url));
//it('should seek on end and receive video ended event for ' + stream.description, testSeekEndVOD(url));
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/helper/fragment-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe('FragmentTracker', () => {
audio: buffered
}
});
assert.strictEqual(fragmentTracker.getState(fragment), FragmentTrackerState.NONE);
assert.strictEqual(fragmentTracker.getState(fragment), FragmentTrackerState.NOT_LOADED);
});
});

Expand Down

0 comments on commit e14c9b0

Please sign in to comment.