hls.js 1.5.2-0.canary.9969 → 1.5.2-0.canary.9970

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
@@ -431,7 +431,7 @@ function enableLogs(debugConfig, context, id) {
431
431
  // Some browsers don't allow to use bind on console object anyway
432
432
  // fallback to default if needed
433
433
  try {
434
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.2-0.canary.9969"}`);
434
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.2-0.canary.9970"}`);
435
435
  } catch (e) {
436
436
  /* log fn threw an exception. All logger methods are no-ops. */
437
437
  return createLogger();
@@ -9180,6 +9180,7 @@ class BaseStreamController extends TaskLoop {
9180
9180
  this.startFragRequested = false;
9181
9181
  this.decrypter = void 0;
9182
9182
  this.initPTS = [];
9183
+ this.buffering = true;
9183
9184
  this.onMediaSeeking = () => {
9184
9185
  const {
9185
9186
  config,
@@ -9285,6 +9286,12 @@ class BaseStreamController extends TaskLoop {
9285
9286
  this.clearNextTick();
9286
9287
  this.state = State.STOPPED;
9287
9288
  }
9289
+ pauseBuffering() {
9290
+ this.buffering = false;
9291
+ }
9292
+ resumeBuffering() {
9293
+ this.buffering = true;
9294
+ }
9288
9295
  _streamEnded(bufferInfo, levelDetails) {
9289
9296
  // If playlist is live, there is another buffered range after the current range, nothing buffered, media is detached,
9290
9297
  // of nothing loading/loaded return false
@@ -15962,12 +15969,13 @@ class AudioStreamController extends BaseStreamController {
15962
15969
  } = this;
15963
15970
  const config = hls.config;
15964
15971
 
15965
- // 1. if video not attached AND
15972
+ // 1. if buffering is suspended
15973
+ // 2. if video not attached AND
15966
15974
  // start fragment already requested OR start frag prefetch not enabled
15967
- // 2. if tracks or track not loaded and selected
15975
+ // 3. if tracks or track not loaded and selected
15968
15976
  // then exit loop
15969
15977
  // => if media not attached but start frag prefetch is enabled and start frag not requested yet, we will not exit loop
15970
- if (!media && (this.startFragRequested || !config.startFragPrefetch) || !(levels != null && levels[trackId])) {
15978
+ if (!this.buffering || !media && (this.startFragRequested || !config.startFragPrefetch) || !(levels != null && levels[trackId])) {
15971
15979
  return;
15972
15980
  }
15973
15981
  const levelInfo = levels[trackId];
@@ -18006,6 +18014,7 @@ class BufferController extends Logger {
18006
18014
  this.resetBuffer(type);
18007
18015
  });
18008
18016
  this._initSourceBuffer();
18017
+ this.hls.resumeBuffering();
18009
18018
  }
18010
18019
  resetBuffer(type) {
18011
18020
  const sb = this.sourceBuffer[type];
@@ -26844,7 +26853,7 @@ class StreamController extends BaseStreamController {
26844
26853
  if (this.altAudio && this.audioOnly) {
26845
26854
  return;
26846
26855
  }
26847
- if (!(levels != null && levels[level])) {
26856
+ if (!this.buffering || !(levels != null && levels[level])) {
26848
26857
  return;
26849
26858
  }
26850
26859
  const levelInfo = levels[level];
@@ -27804,7 +27813,7 @@ class Hls {
27804
27813
  * Get the video-dev/hls.js package version.
27805
27814
  */
27806
27815
  static get version() {
27807
- return "1.5.2-0.canary.9969";
27816
+ return "1.5.2-0.canary.9970";
27808
27817
  }
27809
27818
 
27810
27819
  /**
@@ -27873,7 +27882,6 @@ class Hls {
27873
27882
  this.logger = void 0;
27874
27883
  this.coreComponents = void 0;
27875
27884
  this.networkControllers = void 0;
27876
- this.started = false;
27877
27885
  this._emitter = new EventEmitter();
27878
27886
  this._autoLevelCapping = -1;
27879
27887
  this._maxHdcpLevel = null;
@@ -28088,7 +28096,6 @@ class Hls {
28088
28096
  */
28089
28097
  startLoad(startPosition = -1) {
28090
28098
  this.logger.log(`startLoad(${startPosition})`);
28091
- this.started = true;
28092
28099
  this.networkControllers.forEach(controller => {
28093
28100
  controller.startLoad(startPosition);
28094
28101
  });
@@ -28099,33 +28106,30 @@ class Hls {
28099
28106
  */
28100
28107
  stopLoad() {
28101
28108
  this.logger.log('stopLoad');
28102
- this.started = false;
28103
28109
  this.networkControllers.forEach(controller => {
28104
28110
  controller.stopLoad();
28105
28111
  });
28106
28112
  }
28107
28113
 
28108
28114
  /**
28109
- * Resumes stream controller segment loading if previously started.
28115
+ * Resumes stream controller segment loading after `pauseBuffering` has been called.
28110
28116
  */
28111
28117
  resumeBuffering() {
28112
- if (this.started) {
28113
- this.networkControllers.forEach(controller => {
28114
- if ('fragmentLoader' in controller) {
28115
- controller.startLoad(-1);
28116
- }
28117
- });
28118
- }
28118
+ this.networkControllers.forEach(controller => {
28119
+ if (controller.resumeBuffering) {
28120
+ controller.resumeBuffering();
28121
+ }
28122
+ });
28119
28123
  }
28120
28124
 
28121
28125
  /**
28122
- * Stops stream controller segment loading without changing 'started' state like stopLoad().
28126
+ * Prevents stream controller from loading new segments until `resumeBuffering` is called.
28123
28127
  * This allows for media buffering to be paused without interupting playlist loading.
28124
28128
  */
28125
28129
  pauseBuffering() {
28126
28130
  this.networkControllers.forEach(controller => {
28127
- if ('fragmentLoader' in controller) {
28128
- controller.stopLoad();
28131
+ if (controller.pauseBuffering) {
28132
+ controller.pauseBuffering();
28129
28133
  }
28130
28134
  });
28131
28135
  }