Skip to content

Commit

Permalink
stream-controller: allow start level loading retry even if media not …
Browse files Browse the repository at this point in the history
…attached

# Conflicts:
#	src/controller/stream-controller.js
  • Loading branch information
mangui committed Nov 9, 2016
1 parent fa3f26e commit 8db8ea3
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/controller/stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ class StreamController extends EventHandler {
// if video not attached AND
// start fragment already requested OR start frag prefetch disable
// exit loop
// => if media not attached but start frag prefetch is enabled and start frag not requested yet, we will not exit loop
if (!media &&
// => if start level loaded and media not attached but start frag prefetch is enabled and start frag not requested yet, we will not exit loop
if (this.levelLastLoaded !== undefined && !media &&
(this.startFragRequested || !config.startFragPrefetch)) {
return true;
}
Expand All @@ -204,12 +204,14 @@ class StreamController extends EventHandler {
pos = this.nextLoadPosition;
}
// determine next load level
let level = hls.nextLoadLevel;
let level = hls.nextLoadLevel,
levelInfo = this.levels[level],
levelBitrate = levelInfo.bitrate,
maxBufLen;

// compute max Buffer Length that we could get from this load level, based on level bitrate. don't buffer more than 60 MB and more than 30s
let maxBufLen;
if ((this.levels[level]).hasOwnProperty('bitrate')) {
maxBufLen = Math.max(8 * config.maxBufferSize / this.levels[level].bitrate, config.maxBufferLength);
if (levelBitrate) {
maxBufLen = Math.max(8 * config.maxBufferSize / levelBitrate, config.maxBufferLength);
} else {
maxBufLen = config.maxBufferLength;
}
Expand All @@ -229,10 +231,9 @@ class StreamController extends EventHandler {
logger.trace(`buffer length of ${bufferLen.toFixed(3)} is below max of ${maxBufLen.toFixed(3)}. checking for more payload ...`);

// set next load level : this will trigger a playlist load if needed
hls.nextLoadLevel = level;
this.level = level;
this.level = hls.nextLoadLevel = level;

const levelDetails = this.levels[level].details;
const levelDetails = levelInfo.details;
// if level info not retrieved yet, switch state and wait for level retrieval
// if live playlist, ensure that new playlist has been refreshed to avoid loading/try to load
// a useless and outdated fragment (that might even introduce load error if it is already out of the live playlist)
Expand Down

0 comments on commit 8db8ea3

Please sign in to comment.