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.
@@ -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();
@@ -12761,7 +12761,7 @@ class BaseStreamController extends TaskLoop {
12761
12761
  // If backtracking, always remove from the tracker without reducing max buffer length
12762
12762
  const backtrackFragment = this.backtrackFragment;
12763
12763
  const backtracked = backtrackFragment ? frag.sn - backtrackFragment.sn : 0;
12764
- if (backtracked === 1 || this.reduceMaxBufferLength(minForwardBufferLength)) {
12764
+ if (backtracked === 1 || this.reduceMaxBufferLength(minForwardBufferLength, frag.duration)) {
12765
12765
  fragmentTracker.removeFragment(frag);
12766
12766
  }
12767
12767
  } else if (((_this$mediaBuffer = this.mediaBuffer) == null ? void 0 : _this$mediaBuffer.buffered.length) === 0) {
@@ -13262,10 +13262,10 @@ class BaseStreamController extends TaskLoop {
13262
13262
  }
13263
13263
  return Math.min(maxBufLen, config.maxMaxBufferLength);
13264
13264
  }
13265
- reduceMaxBufferLength(threshold) {
13265
+ reduceMaxBufferLength(threshold, fragDuration) {
13266
13266
  const config = this.config;
13267
- const minLength = threshold || config.maxBufferLength;
13268
- const reducedLength = config.maxMaxBufferLength / 2;
13267
+ const minLength = Math.max(Math.min(threshold, config.maxBufferLength), fragDuration);
13268
+ const reducedLength = Math.max(threshold - fragDuration * 3, config.maxMaxBufferLength / 2);
13269
13269
  if (reducedLength >= minLength) {
13270
13270
  // reduce max buffer length as it might be too high. we do this to avoid loop flushing ...
13271
13271
  config.maxMaxBufferLength = reducedLength;
@@ -13655,13 +13655,14 @@ class BaseStreamController extends TaskLoop {
13655
13655
  reduceLengthAndFlushBuffer(data) {
13656
13656
  // if in appending state
13657
13657
  if (this.state === State.PARSING || this.state === State.PARSED) {
13658
+ const frag = data.frag;
13658
13659
  const playlistType = data.parent;
13659
13660
  const bufferedInfo = this.getFwdBufferInfo(this.mediaBuffer, playlistType);
13660
13661
  // 0.5 : tolerance needed as some browsers stalls playback before reaching buffered end
13661
13662
  // reduce max buf len if current position is buffered
13662
13663
  const buffered = bufferedInfo && bufferedInfo.len > 0.5;
13663
13664
  if (buffered) {
13664
- this.reduceMaxBufferLength(bufferedInfo.len);
13665
+ this.reduceMaxBufferLength(bufferedInfo.len, (frag == null ? void 0 : frag.duration) || 10);
13665
13666
  }
13666
13667
  const flushBuffer = !buffered;
13667
13668
  if (flushBuffer) {
@@ -13670,9 +13671,9 @@ class BaseStreamController extends TaskLoop {
13670
13671
  // in that case flush the whole audio buffer to recover
13671
13672
  this.warn(`Buffer full error while media.currentTime is not buffered, flush ${playlistType} buffer`);
13672
13673
  }
13673
- if (data.frag) {
13674
- this.fragmentTracker.removeFragment(data.frag);
13675
- this.nextLoadPosition = data.frag.start;
13674
+ if (frag) {
13675
+ this.fragmentTracker.removeFragment(frag);
13676
+ this.nextLoadPosition = frag.start;
13676
13677
  }
13677
13678
  this.resetLoadingState();
13678
13679
  return flushBuffer;
@@ -20664,7 +20665,7 @@ class Hls {
20664
20665
  * Get the video-dev/hls.js package version.
20665
20666
  */
20666
20667
  static get version() {
20667
- return "1.5.12-0.canary.10398";
20668
+ return "1.5.12-0.canary.10399";
20668
20669
  }
20669
20670
 
20670
20671
  /**