hls.js 1.5.12-0.canary.10398 → 1.5.12-0.canary.10399

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hls.mjs CHANGED
@@ -420,7 +420,7 @@ function enableLogs(debugConfig, context, id) {
420
420
  // Some browsers don't allow to use bind on console object anyway
421
421
  // fallback to default if needed
422
422
  try {
423
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.12-0.canary.10398"}`);
423
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.12-0.canary.10399"}`);
424
424
  } catch (e) {
425
425
  /* log fn threw an exception. All logger methods are no-ops. */
426
426
  return createLogger();
@@ -9915,7 +9915,7 @@ class BaseStreamController extends TaskLoop {
9915
9915
  // If backtracking, always remove from the tracker without reducing max buffer length
9916
9916
  const backtrackFragment = this.backtrackFragment;
9917
9917
  const backtracked = backtrackFragment ? frag.sn - backtrackFragment.sn : 0;
9918
- if (backtracked === 1 || this.reduceMaxBufferLength(minForwardBufferLength)) {
9918
+ if (backtracked === 1 || this.reduceMaxBufferLength(minForwardBufferLength, frag.duration)) {
9919
9919
  fragmentTracker.removeFragment(frag);
9920
9920
  }
9921
9921
  } else if (((_this$mediaBuffer = this.mediaBuffer) == null ? void 0 : _this$mediaBuffer.buffered.length) === 0) {
@@ -10416,10 +10416,10 @@ class BaseStreamController extends TaskLoop {
10416
10416
  }
10417
10417
  return Math.min(maxBufLen, config.maxMaxBufferLength);
10418
10418
  }
10419
- reduceMaxBufferLength(threshold) {
10419
+ reduceMaxBufferLength(threshold, fragDuration) {
10420
10420
  const config = this.config;
10421
- const minLength = threshold || config.maxBufferLength;
10422
- const reducedLength = config.maxMaxBufferLength / 2;
10421
+ const minLength = Math.max(Math.min(threshold, config.maxBufferLength), fragDuration);
10422
+ const reducedLength = Math.max(threshold - fragDuration * 3, config.maxMaxBufferLength / 2);
10423
10423
  if (reducedLength >= minLength) {
10424
10424
  // reduce max buffer length as it might be too high. we do this to avoid loop flushing ...
10425
10425
  config.maxMaxBufferLength = reducedLength;
@@ -10809,13 +10809,14 @@ class BaseStreamController extends TaskLoop {
10809
10809
  reduceLengthAndFlushBuffer(data) {
10810
10810
  // if in appending state
10811
10811
  if (this.state === State.PARSING || this.state === State.PARSED) {
10812
+ const frag = data.frag;
10812
10813
  const playlistType = data.parent;
10813
10814
  const bufferedInfo = this.getFwdBufferInfo(this.mediaBuffer, playlistType);
10814
10815
  // 0.5 : tolerance needed as some browsers stalls playback before reaching buffered end
10815
10816
  // reduce max buf len if current position is buffered
10816
10817
  const buffered = bufferedInfo && bufferedInfo.len > 0.5;
10817
10818
  if (buffered) {
10818
- this.reduceMaxBufferLength(bufferedInfo.len);
10819
+ this.reduceMaxBufferLength(bufferedInfo.len, (frag == null ? void 0 : frag.duration) || 10);
10819
10820
  }
10820
10821
  const flushBuffer = !buffered;
10821
10822
  if (flushBuffer) {
@@ -10824,9 +10825,9 @@ class BaseStreamController extends TaskLoop {
10824
10825
  // in that case flush the whole audio buffer to recover
10825
10826
  this.warn(`Buffer full error while media.currentTime is not buffered, flush ${playlistType} buffer`);
10826
10827
  }
10827
- if (data.frag) {
10828
- this.fragmentTracker.removeFragment(data.frag);
10829
- this.nextLoadPosition = data.frag.start;
10828
+ if (frag) {
10829
+ this.fragmentTracker.removeFragment(frag);
10830
+ this.nextLoadPosition = frag.start;
10830
10831
  }
10831
10832
  this.resetLoadingState();
10832
10833
  return flushBuffer;
@@ -29279,7 +29280,7 @@ class Hls {
29279
29280
  * Get the video-dev/hls.js package version.
29280
29281
  */
29281
29282
  static get version() {
29282
- return "1.5.12-0.canary.10398";
29283
+ return "1.5.12-0.canary.10399";
29283
29284
  }
29284
29285
 
29285
29286
  /**