hls.js 1.6.0-beta.1.0.canary.10766 → 1.6.0-beta.1.0.canary.10768

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.light.js CHANGED
@@ -1028,7 +1028,7 @@
1028
1028
  // Some browsers don't allow to use bind on console object anyway
1029
1029
  // fallback to default if needed
1030
1030
  try {
1031
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.1.0.canary.10766");
1031
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.1.0.canary.10768");
1032
1032
  } catch (e) {
1033
1033
  /* log fn threw an exception. All logger methods are no-ops. */
1034
1034
  return createLogger();
@@ -5915,6 +5915,15 @@
5915
5915
  }
5916
5916
  return this.endSN;
5917
5917
  }
5918
+ }, {
5919
+ key: "expired",
5920
+ get: function get() {
5921
+ if (this.live && this.age) {
5922
+ var playlistWindowDuration = this.partEnd - this.fragmentStart;
5923
+ return this.age > Math.max(playlistWindowDuration, this.totalduration) + this.levelTargetDuration;
5924
+ }
5925
+ return false;
5926
+ }
5918
5927
  }]);
5919
5928
  }();
5920
5929
 
@@ -16927,7 +16936,9 @@
16927
16936
  }
16928
16937
  }
16929
16938
  var pathwayId = currentLevel.attrs['PATHWAY-ID'];
16930
- this.log("Loading level index " + currentLevelIndex + ((hlsUrlParameters == null ? void 0 : hlsUrlParameters.msn) !== undefined ? ' at sn ' + hlsUrlParameters.msn + ' part ' + hlsUrlParameters.part : '') + " with" + (pathwayId ? ' Pathway ' + pathwayId : '') + " " + url);
16939
+ var details = currentLevel.details;
16940
+ var age = details == null ? void 0 : details.age;
16941
+ this.log("Loading level index " + currentLevelIndex + ((hlsUrlParameters == null ? void 0 : hlsUrlParameters.msn) !== undefined ? ' at sn ' + hlsUrlParameters.msn + ' part ' + hlsUrlParameters.part : '') + (pathwayId ? ' Pathway ' + pathwayId : '') + (age && details.live ? ' age ' + age.toFixed(1) + (details.type ? ' ' + details.type || '' : '') : '') + " " + url);
16931
16942
 
16932
16943
  // console.log('Current audio track group ID:', this.hls.audioTracks[this.hls.audioTrack].groupId);
16933
16944
  // console.log('New video quality level audio group id:', levelObject.attrs.AUDIO, level);
@@ -18168,6 +18179,10 @@
18168
18179
  details.deltaUpdateFailed = true;
18169
18180
  }
18170
18181
  };
18182
+ _proto.waitForLive = function waitForLive(levelInfo) {
18183
+ var details = levelInfo.details;
18184
+ return (details == null ? void 0 : details.live) && details.type !== 'EVENT' && (this.levelLastLoaded !== levelInfo || details.expired);
18185
+ };
18171
18186
  _proto.flushMainBuffer = function flushMainBuffer(startOffset, endOffset, type) {
18172
18187
  if (type === void 0) {
18173
18188
  type = null;
@@ -18529,7 +18544,7 @@
18529
18544
  sn = chunkMeta.sn,
18530
18545
  partIndex = chunkMeta.part;
18531
18546
  if (!(levels != null && levels[levelIndex])) {
18532
- this.warn("Levels object was unset while buffering fragment " + sn + " of level " + levelIndex + ". The current chunk will not be buffered.");
18547
+ this.warn("Levels object was unset while buffering fragment " + sn + " of " + this.playlistLabel() + " " + levelIndex + ". The current chunk will not be buffered.");
18533
18548
  return null;
18534
18549
  }
18535
18550
  var level = levels[levelIndex];
@@ -18903,6 +18918,7 @@
18903
18918
  // Leave this.startPosition at -1, so that we can use `getInitialLiveFragment` logic when startPosition has
18904
18919
  // not been specified via the config or an as an argument to startLoad (#3736).
18905
18920
  startPosition = this.hls.liveSyncPosition || sliding;
18921
+ this.startPosition = -1;
18906
18922
  } else {
18907
18923
  this.log("setting startPosition to 0 by default");
18908
18924
  this.startPosition = startPosition = 0;
@@ -18923,8 +18939,8 @@
18923
18939
  return pos;
18924
18940
  };
18925
18941
  _proto.handleFragLoadAborted = function handleFragLoadAborted(frag, part) {
18926
- if (this.transmuxer && isMediaFragment(frag) && frag.stats.aborted) {
18927
- this.warn("Fragment " + frag.sn + (part ? ' part ' + part.index : '') + " of level " + frag.level + " was aborted");
18942
+ if (this.transmuxer && frag.type === this.playlistType && isMediaFragment(frag) && frag.stats.aborted) {
18943
+ this.warn("Fragment " + frag.sn + (part ? ' part ' + part.index : '') + " of " + this.playlistLabel() + " " + frag.level + " was aborted");
18928
18944
  this.resetFragmentLoading(frag);
18929
18945
  }
18930
18946
  };
@@ -19075,7 +19091,7 @@
19075
19091
  }
19076
19092
  };
19077
19093
  _proto.resetWhenMissingContext = function resetWhenMissingContext(chunkMeta) {
19078
- this.warn("The loading context changed while buffering fragment " + chunkMeta.sn + " of level " + chunkMeta.level + ". This chunk will not be buffered.");
19094
+ this.warn("The loading context changed while buffering fragment " + chunkMeta.sn + " of " + this.playlistLabel() + " " + chunkMeta.level + ". This chunk will not be buffered.");
19079
19095
  this.removeUnbufferedFrags();
19080
19096
  this.resetStartWhenNotLoaded(this.levelLastLoaded);
19081
19097
  this.resetLoadingState();
@@ -19120,7 +19136,7 @@
19120
19136
  return result;
19121
19137
  }, false);
19122
19138
  if (!parsed && ((_this$transmuxer = this.transmuxer) == null ? void 0 : _this$transmuxer.error) === null) {
19123
- var error = new Error("Found no media in fragment " + frag.sn + " of level " + frag.level + " resetting transmuxer to fallback to playlist timing");
19139
+ var error = new Error("Found no media in fragment " + frag.sn + " of " + this.playlistLabel() + " " + frag.level + " resetting transmuxer to fallback to playlist timing");
19124
19140
  if (level.fragmentError === 0) {
19125
19141
  // Mark and track the odd empty segment as a gap to avoid reloading
19126
19142
  this.treatAsGap(frag, level);
@@ -19132,7 +19148,7 @@
19132
19148
  fatal: false,
19133
19149
  error: error,
19134
19150
  frag: frag,
19135
- reason: "Found no media in msn " + frag.sn + " of level \"" + level.url + "\""
19151
+ reason: "Found no media in msn " + frag.sn + " of " + this.playlistLabel() + " \"" + level.url + "\""
19136
19152
  });
19137
19153
  if (!this.hls) {
19138
19154
  return;
@@ -19709,7 +19725,7 @@
19709
19725
  return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
19710
19726
  }
19711
19727
 
19712
- var version = "1.6.0-beta.1.0.canary.10766";
19728
+ var version = "1.6.0-beta.1.0.canary.10768";
19713
19729
 
19714
19730
  // ensure the worker ends up in the bundle
19715
19731
  // If the worker should not be included this gets aliased to empty.js
@@ -20218,7 +20234,7 @@
20218
20234
  this._hasEnoughToStart = false;
20219
20235
  }
20220
20236
  // if startPosition undefined but lastCurrentTime set, set startPosition to last currentTime
20221
- if (lastCurrentTime > 0 && startPosition === -1) {
20237
+ if (lastCurrentTime > 0 && startPosition === -1 && !skipSeekToStartPosition) {
20222
20238
  this.log("Override startPosition with lastCurrentTime @" + lastCurrentTime.toFixed(3));
20223
20239
  startPosition = lastCurrentTime;
20224
20240
  }
@@ -20243,7 +20259,7 @@
20243
20259
  level = this.level;
20244
20260
  var currentLevel = levels == null ? void 0 : levels[level];
20245
20261
  var details = currentLevel == null ? void 0 : currentLevel.details;
20246
- if (details && (!details.live || this.levelLastLoaded === currentLevel)) {
20262
+ if (details && (!details.live || this.levelLastLoaded === currentLevel && !this.waitForLive(currentLevel))) {
20247
20263
  if (this.waitForCdnTuneIn(details)) {
20248
20264
  break;
20249
20265
  }
@@ -20333,9 +20349,10 @@
20333
20349
  // if level info not retrieved yet, switch state and wait for level retrieval
20334
20350
  // if live playlist, ensure that new playlist has been refreshed to avoid loading/try to load
20335
20351
  // a useless and outdated fragment (that might even introduce load error if it is already out of the live playlist)
20336
- if (!levelDetails || this.state === State.WAITING_LEVEL || levelDetails.live && this.levelLastLoaded !== levelInfo) {
20352
+ if (!levelDetails || this.state === State.WAITING_LEVEL || this.waitForLive(levelInfo)) {
20337
20353
  this.level = level;
20338
20354
  this.state = State.WAITING_LEVEL;
20355
+ this.startFragRequested = false;
20339
20356
  return;
20340
20357
  }
20341
20358
  var bufferLen = bufferInfo.len;
@@ -20579,7 +20596,7 @@
20579
20596
  return;
20580
20597
  }
20581
20598
  var level = data.levelInfo;
20582
- if (!level.details || level.details.live && this.levelLastLoaded !== level || this.waitForCdnTuneIn(level.details)) {
20599
+ if (!level.details || level.details.live && (this.levelLastLoaded !== level || level.details.expired) || this.waitForCdnTuneIn(level.details)) {
20583
20600
  this.state = State.WAITING_LEVEL;
20584
20601
  }
20585
20602
  };
@@ -21794,13 +21811,18 @@
21794
21811
  // Check if a loader for this context already exists
21795
21812
  var loader = this.getInternalLoader(context);
21796
21813
  if (loader) {
21814
+ var logger = this.hls.logger;
21797
21815
  var loaderContext = loader.context;
21798
- if (loaderContext && loaderContext.url === context.url && loaderContext.levelOrTrack === context.levelOrTrack) {
21799
- // same URL can't overlap
21800
- this.hls.logger.trace('[playlist-loader]: playlist request ongoing');
21816
+ if (loaderContext && loaderContext.levelOrTrack === context.levelOrTrack && (loaderContext.url === context.url || loaderContext.deliveryDirectives && !context.deliveryDirectives)) {
21817
+ // same URL can't overlap, or wait for blocking request
21818
+ if (loaderContext.url === context.url) {
21819
+ logger.log("[playlist-loader]: playlist request ongoing");
21820
+ } else {
21821
+ logger.log("[playlist-loader]: ignore " + context.url + " in favor of " + loaderContext.url);
21822
+ }
21801
21823
  return;
21802
21824
  }
21803
- this.hls.logger.log("[playlist-loader]: aborting previous loader for type: " + context.type);
21825
+ logger.log("[playlist-loader]: aborting previous loader for type: " + context.type);
21804
21826
  loader.abort();
21805
21827
  }
21806
21828
 
@@ -22497,6 +22519,10 @@
22497
22519
  return;
22498
22520
  }
22499
22521
  this.logger.log("attachMedia");
22522
+ if (this._media) {
22523
+ this.logger.warn("media must be detached before attaching");
22524
+ this.detachMedia();
22525
+ }
22500
22526
  var attachMediaSource = 'media' in data;
22501
22527
  var media = attachMediaSource ? data.media : data;
22502
22528
  var attachingData = attachMediaSource ? data : {