hls.js 1.6.0-beta.3.0.canary.10986 → 1.6.0-beta.3.0.canary.10989

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.3.0.canary.10986"}`);
405
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.3.0.canary.10989"}`);
406
406
  } catch (e) {
407
407
  /* log fn threw an exception. All logger methods are no-ops. */
408
408
  return createLogger();
@@ -9938,7 +9938,7 @@ var eventemitter3 = {exports: {}};
9938
9938
  var eventemitter3Exports = eventemitter3.exports;
9939
9939
  var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
9940
9940
 
9941
- const version = "1.6.0-beta.3.0.canary.10986";
9941
+ const version = "1.6.0-beta.3.0.canary.10989";
9942
9942
 
9943
9943
  // ensure the worker ends up in the bundle
9944
9944
  // If the worker should not be included this gets aliased to empty.js
@@ -22840,8 +22840,16 @@ class InterstitialEvent {
22840
22840
  }
22841
22841
  reset() {
22842
22842
  var _this$assetListLoader;
22843
+ this.appendInPlaceStarted = false;
22843
22844
  (_this$assetListLoader = this.assetListLoader) == null ? void 0 : _this$assetListLoader.destroy();
22844
- this.assetListLoader = this.error = undefined;
22845
+ this.assetListLoader = undefined;
22846
+ if (!this.supplementsPrimary) {
22847
+ this.assetListResponse = null;
22848
+ this.assetList = [];
22849
+ this._duration = null;
22850
+ }
22851
+ // `error?` is reset when seeking back over interstitial `startOffset`
22852
+ // using `schedule.resetErrorsInRange(start, end)`.
22845
22853
  }
22846
22854
  isAssetPastPlayoutLimit(assetIndex) {
22847
22855
  if (assetIndex >= this.assetList.length) {
@@ -23173,6 +23181,18 @@ class InterstitialsSchedule extends Logger {
23173
23181
  }
23174
23182
  this.events = this.items = null;
23175
23183
  }
23184
+ resetErrorsInRange(start, end) {
23185
+ if (this.events) {
23186
+ return this.events.reduce((count, interstitial) => {
23187
+ if (start <= interstitial.startOffset && end > interstitial.startOffset) {
23188
+ delete interstitial.error;
23189
+ return count + 1;
23190
+ }
23191
+ return count;
23192
+ }, 0);
23193
+ }
23194
+ return 0;
23195
+ }
23176
23196
  get duration() {
23177
23197
  const items = this.items;
23178
23198
  return items ? items[items.length - 1].end : 0;
@@ -23800,13 +23820,20 @@ class InterstitialsController extends Logger {
23800
23820
  const backwardSeek = diff <= -0.01;
23801
23821
  this.timelinePos = currentTime;
23802
23822
  this.bufferedPos = currentTime;
23803
- this.checkBuffer();
23804
23823
 
23805
23824
  // Check if seeking out of an item
23806
23825
  const playingItem = this.playingItem;
23807
23826
  if (!playingItem) {
23827
+ this.checkBuffer();
23808
23828
  return;
23809
23829
  }
23830
+ if (backwardSeek) {
23831
+ const resetCount = this.schedule.resetErrorsInRange(currentTime, currentTime - diff);
23832
+ if (resetCount) {
23833
+ this.updateSchedule();
23834
+ }
23835
+ }
23836
+ this.checkBuffer();
23810
23837
  if (backwardSeek && currentTime < playingItem.start || currentTime >= playingItem.end) {
23811
23838
  var _this$media;
23812
23839
  const scheduleIndex = this.schedule.findItemIndexAtTime(this.timelinePos);
@@ -23856,10 +23883,10 @@ class InterstitialsController extends Logger {
23856
23883
  // Only allow timeupdate to advance primary position, seeking is used for jumping back
23857
23884
  // this prevents primaryPos from being reset to 0 after re-attach
23858
23885
  if (currentTime > this.timelinePos) {
23886
+ this.timelinePos = currentTime;
23859
23887
  if (currentTime > this.bufferedPos) {
23860
23888
  this.checkBuffer();
23861
23889
  }
23862
- this.timelinePos = currentTime;
23863
23890
  } else {
23864
23891
  return;
23865
23892
  }
@@ -23940,7 +23967,7 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
23940
23967
  this.bufferingItem = updatedBufferingItem;
23941
23968
  } else if (bufferingItem.event) {
23942
23969
  // Interstitial removed from schedule (Live -> VOD or other scenario where Start Date is outside the range of VOD Playlist)
23943
- this.bufferingItem = null;
23970
+ this.bufferingItem = this.playingItem;
23944
23971
  this.clearInterstitial(bufferingItem.event, null);
23945
23972
  }
23946
23973
  }
@@ -24171,8 +24198,9 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
24171
24198
  const playingItem = c.effectivePlayingItem;
24172
24199
  const targetIndex = c.schedule.findItemIndexAtTime(time, timelineType);
24173
24200
  const targetItem = (_c$schedule$items2 = c.schedule.items) == null ? void 0 : _c$schedule$items2[targetIndex];
24174
- const playingInterstitial = playingItem == null ? void 0 : playingItem.event;
24175
- const appendInPlace = playingInterstitial == null ? void 0 : playingInterstitial.appendInPlace;
24201
+ const bufferingPlayer = c.getBufferingPlayer();
24202
+ const bufferingInterstitial = bufferingPlayer == null ? void 0 : bufferingPlayer.interstitial;
24203
+ const appendInPlace = bufferingInterstitial == null ? void 0 : bufferingInterstitial.appendInPlace;
24176
24204
  const seekInItem = playingItem && c.itemsMatch(playingItem, targetItem);
24177
24205
  if (playingItem && (appendInPlace || seekInItem)) {
24178
24206
  // seek in asset player or primary media (appendInPlace)
@@ -24197,8 +24225,8 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
24197
24225
  seekToTime = targetItem.start + diff;
24198
24226
  }
24199
24227
  const targetIsPrimary = !c.isInterstitial(targetItem);
24200
- if (!c.isInterstitial(playingItem) && (targetIsPrimary || targetItem.event.appendInPlace)) {
24201
- const media = c.hls.media;
24228
+ if ((!c.isInterstitial(playingItem) || playingItem.event.appendInPlace) && (targetIsPrimary || targetItem.event.appendInPlace)) {
24229
+ const media = c.media || (appendInPlace ? bufferingPlayer == null ? void 0 : bufferingPlayer.media : null);
24202
24230
  if (media) {
24203
24231
  media.currentTime = seekToTime;
24204
24232
  }
@@ -24215,6 +24243,7 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
24215
24243
  let assetIndex = 0;
24216
24244
  if (targetIsPrimary) {
24217
24245
  c.timelinePos = seekToTime;
24246
+ c.checkBuffer();
24218
24247
  } else {
24219
24248
  var _targetItem$event;
24220
24249
  const assetList = targetItem == null ? void 0 : (_targetItem$event = targetItem.event) == null ? void 0 : _targetItem$event.assetList;
@@ -24564,6 +24593,7 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
24564
24593
  const resumptionTime = interstitial.resumeTime;
24565
24594
  if (this.timelinePos < resumptionTime) {
24566
24595
  this.timelinePos = resumptionTime;
24596
+ this.checkBuffer();
24567
24597
  }
24568
24598
  this.setSchedulePosition(nextIndex);
24569
24599
  }
@@ -24624,7 +24654,6 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
24624
24654
  scheduleIndex: index
24625
24655
  });
24626
24656
  // Exiting an Interstitial
24627
- this.clearInterstitial(interstitial, scheduledItem);
24628
24657
  if (interstitial.cue.once) {
24629
24658
  // Remove interstitial with CUE attribute value of ONCE after it has played
24630
24659
  this.updateSchedule();
@@ -24803,7 +24832,7 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
24803
24832
  if (item) {
24804
24833
  this.setBufferingItem(item);
24805
24834
  } else {
24806
- this.bufferingItem = null;
24835
+ this.bufferingItem = this.playingItem;
24807
24836
  }
24808
24837
  this.bufferingAsset = null;
24809
24838
  const media = this.primaryMedia;
@@ -25033,7 +25062,7 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
25033
25062
  const timeRemaining = bufferingPlayer ? bufferingPlayer.remaining : bufferingLast ? bufferingLast.end - this.timelinePos : 0;
25034
25063
  this.log(`buffered to boundary ${segmentToString(item)}` + (bufferingLast ? ` (${timeRemaining.toFixed(2)} remaining)` : ''));
25035
25064
  this.bufferingItem = item;
25036
- this.bufferedPos = item.start;
25065
+ this.bufferedPos = Math.max(item.start, Math.min(item.end, this.timelinePos));
25037
25066
  if (!this.playbackDisabled) {
25038
25067
  if (isInterstitial) {
25039
25068
  // primary fragment loading will exit early in base-stream-controller while `bufferingItem` is set to an Interstitial block
@@ -25127,7 +25156,6 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
25127
25156
  liveStartPosition = this.hls.liveSyncPosition || 0;
25128
25157
  }
25129
25158
  }
25130
- interstitial.assetListResponse = null;
25131
25159
  const assetListLoader = this.assetListLoader.loadAssetList(interstitial, liveStartPosition);
25132
25160
  if (assetListLoader) {
25133
25161
  interstitial.assetListLoader = assetListLoader;
@@ -25367,7 +25395,8 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
25367
25395
  interstitial.assetList.forEach(asset => {
25368
25396
  this.clearAssetPlayer(asset.identifier, toSegment);
25369
25397
  });
25370
- interstitial.appendInPlaceStarted = false;
25398
+ // Remove asset list and resolved duration
25399
+ interstitial.reset();
25371
25400
  }
25372
25401
  clearAssetPlayer(assetId, toSegment) {
25373
25402
  const playerIndex = this.getAssetPlayerQueueIndex(assetId);