hls.js 1.6.0-beta.2.0.canary.10942 → 1.6.0-beta.3.0.canary.10943

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
@@ -402,7 +402,7 @@ function enableLogs(debugConfig, context, id) {
402
402
  // Some browsers don't allow to use bind on console object anyway
403
403
  // fallback to default if needed
404
404
  try {
405
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.2.0.canary.10942"}`);
405
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.3.0.canary.10943"}`);
406
406
  } catch (e) {
407
407
  /* log fn threw an exception. All logger methods are no-ops. */
408
408
  return createLogger();
@@ -9883,7 +9883,7 @@ var eventemitter3 = {exports: {}};
9883
9883
  var eventemitter3Exports = eventemitter3.exports;
9884
9884
  var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
9885
9885
 
9886
- const version = "1.6.0-beta.2.0.canary.10942";
9886
+ const version = "1.6.0-beta.3.0.canary.10943";
9887
9887
 
9888
9888
  // ensure the worker ends up in the bundle
9889
9889
  // If the worker should not be included this gets aliased to empty.js
@@ -30666,7 +30666,7 @@ class LatencyController {
30666
30666
  const {
30667
30667
  media
30668
30668
  } = this;
30669
- const levelDetails = this.hls.latestLevelDetails;
30669
+ const levelDetails = this.levelDetails;
30670
30670
  if (!media || !levelDetails) {
30671
30671
  return;
30672
30672
  }
@@ -30707,23 +30707,26 @@ class LatencyController {
30707
30707
  this.config = hls.config;
30708
30708
  this.registerListeners();
30709
30709
  }
30710
+ get levelDetails() {
30711
+ var _this$hls;
30712
+ return ((_this$hls = this.hls) == null ? undefined : _this$hls.latestLevelDetails) || null;
30713
+ }
30710
30714
  get latency() {
30711
30715
  return this._latency || 0;
30712
30716
  }
30713
30717
  get maxLatency() {
30714
- var _this$hls;
30715
30718
  const {
30716
30719
  config
30717
30720
  } = this;
30718
30721
  if (config.liveMaxLatencyDuration !== undefined) {
30719
30722
  return config.liveMaxLatencyDuration;
30720
30723
  }
30721
- const levelDetails = (_this$hls = this.hls) == null ? undefined : _this$hls.latestLevelDetails;
30724
+ const levelDetails = this.levelDetails;
30722
30725
  return levelDetails ? config.liveMaxLatencyDurationCount * levelDetails.targetduration : 0;
30723
30726
  }
30724
30727
  get targetLatency() {
30725
- const levelDetails = this.hls.latestLevelDetails;
30726
- if (levelDetails === null) {
30728
+ const levelDetails = this.levelDetails;
30729
+ if (levelDetails === null || this.hls === null) {
30727
30730
  return null;
30728
30731
  }
30729
30732
  const {
@@ -30755,7 +30758,7 @@ class LatencyController {
30755
30758
  if (liveEdge === null || targetLatency === null) {
30756
30759
  return null;
30757
30760
  }
30758
- const levelDetails = this.hls.latestLevelDetails;
30761
+ const levelDetails = this.levelDetails;
30759
30762
  if (levelDetails === null) {
30760
30763
  return null;
30761
30764
  }
@@ -30766,14 +30769,14 @@ class LatencyController {
30766
30769
  return Math.min(Math.max(min, syncPosition), max);
30767
30770
  }
30768
30771
  get drift() {
30769
- const levelDetails = this.hls.latestLevelDetails;
30772
+ const levelDetails = this.levelDetails;
30770
30773
  if (levelDetails === null) {
30771
30774
  return 1;
30772
30775
  }
30773
30776
  return levelDetails.drift;
30774
30777
  }
30775
30778
  get edgeStalled() {
30776
- const levelDetails = this.hls.latestLevelDetails;
30779
+ const levelDetails = this.levelDetails;
30777
30780
  if (levelDetails === null) {
30778
30781
  return 0;
30779
30782
  }
@@ -30784,7 +30787,7 @@ class LatencyController {
30784
30787
  const {
30785
30788
  media
30786
30789
  } = this;
30787
- const levelDetails = this.hls.latestLevelDetails;
30790
+ const levelDetails = this.levelDetails;
30788
30791
  if (!media || !levelDetails) {
30789
30792
  return 0;
30790
30793
  }
@@ -30794,22 +30797,33 @@ class LatencyController {
30794
30797
  destroy() {
30795
30798
  this.unregisterListeners();
30796
30799
  this.onMediaDetaching();
30797
- // @ts-ignore
30798
30800
  this.hls = null;
30799
30801
  }
30800
30802
  registerListeners() {
30801
- this.hls.on(Events.MEDIA_ATTACHED, this.onMediaAttached, this);
30802
- this.hls.on(Events.MEDIA_DETACHING, this.onMediaDetaching, this);
30803
- this.hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this);
30804
- this.hls.on(Events.LEVEL_UPDATED, this.onLevelUpdated, this);
30805
- this.hls.on(Events.ERROR, this.onError, this);
30803
+ const {
30804
+ hls
30805
+ } = this;
30806
+ if (!hls) {
30807
+ return;
30808
+ }
30809
+ hls.on(Events.MEDIA_ATTACHED, this.onMediaAttached, this);
30810
+ hls.on(Events.MEDIA_DETACHING, this.onMediaDetaching, this);
30811
+ hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this);
30812
+ hls.on(Events.LEVEL_UPDATED, this.onLevelUpdated, this);
30813
+ hls.on(Events.ERROR, this.onError, this);
30806
30814
  }
30807
30815
  unregisterListeners() {
30808
- this.hls.off(Events.MEDIA_ATTACHED, this.onMediaAttached, this);
30809
- this.hls.off(Events.MEDIA_DETACHING, this.onMediaDetaching, this);
30810
- this.hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this);
30811
- this.hls.off(Events.LEVEL_UPDATED, this.onLevelUpdated, this);
30812
- this.hls.off(Events.ERROR, this.onError, this);
30816
+ const {
30817
+ hls
30818
+ } = this;
30819
+ if (!hls) {
30820
+ return;
30821
+ }
30822
+ hls.off(Events.MEDIA_ATTACHED, this.onMediaAttached, this);
30823
+ hls.off(Events.MEDIA_DETACHING, this.onMediaDetaching, this);
30824
+ hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this);
30825
+ hls.off(Events.LEVEL_UPDATED, this.onLevelUpdated, this);
30826
+ hls.off(Events.ERROR, this.onError, this);
30813
30827
  }
30814
30828
  onMediaAttached(event, data) {
30815
30829
  this.media = data.media;
@@ -30836,17 +30850,17 @@ class LatencyController {
30836
30850
  }
30837
30851
  }
30838
30852
  onError(event, data) {
30839
- var _this$hls$latestLevel;
30853
+ var _this$levelDetails;
30840
30854
  if (data.details !== ErrorDetails.BUFFER_STALLED_ERROR) {
30841
30855
  return;
30842
30856
  }
30843
30857
  this.stallCount++;
30844
- if ((_this$hls$latestLevel = this.hls.latestLevelDetails) != null && _this$hls$latestLevel.live) {
30858
+ if (this.hls && (_this$levelDetails = this.levelDetails) != null && _this$levelDetails.live) {
30845
30859
  this.hls.logger.warn('[latency-controller]: Stall detected, adjusting target latency');
30846
30860
  }
30847
30861
  }
30848
30862
  estimateLiveEdge() {
30849
- const levelDetails = this.hls.latestLevelDetails;
30863
+ const levelDetails = this.levelDetails;
30850
30864
  if (levelDetails === null) {
30851
30865
  return null;
30852
30866
  }