hls.js 1.6.3-0.canary.11251 → 1.6.3-0.canary.11252

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.d.mts CHANGED
@@ -1983,6 +1983,7 @@ export declare class HlsAssetPlayer {
1983
1983
  resumeBuffering(): void;
1984
1984
  pauseBuffering(): void;
1985
1985
  transferMedia(): AttachMediaSourceData | null;
1986
+ resetDetails(): void;
1986
1987
  on<E extends keyof HlsListeners, Context = undefined>(event: E, listener: HlsListeners[E], context?: Context): void;
1987
1988
  once<E extends keyof HlsListeners, Context = undefined>(event: E, listener: HlsListeners[E], context?: Context): void;
1988
1989
  off<E extends keyof HlsListeners, Context = undefined>(event: E, listener: HlsListeners[E], context?: Context): void;
@@ -2468,6 +2469,7 @@ export declare class InterstitialsController extends Logger implements NetworkCo
2468
2469
  private createAsset;
2469
2470
  private createAssetPlayer;
2470
2471
  private clearInterstitial;
2472
+ private resetAssetPlayer;
2471
2473
  private clearAssetPlayer;
2472
2474
  private emptyPlayerQueue;
2473
2475
  private startAssetPlayer;
package/dist/hls.d.ts CHANGED
@@ -1983,6 +1983,7 @@ export declare class HlsAssetPlayer {
1983
1983
  resumeBuffering(): void;
1984
1984
  pauseBuffering(): void;
1985
1985
  transferMedia(): AttachMediaSourceData | null;
1986
+ resetDetails(): void;
1986
1987
  on<E extends keyof HlsListeners, Context = undefined>(event: E, listener: HlsListeners[E], context?: Context): void;
1987
1988
  once<E extends keyof HlsListeners, Context = undefined>(event: E, listener: HlsListeners[E], context?: Context): void;
1988
1989
  off<E extends keyof HlsListeners, Context = undefined>(event: E, listener: HlsListeners[E], context?: Context): void;
@@ -2468,6 +2469,7 @@ export declare class InterstitialsController extends Logger implements NetworkCo
2468
2469
  private createAsset;
2469
2470
  private createAssetPlayer;
2470
2471
  private clearInterstitial;
2472
+ private resetAssetPlayer;
2471
2473
  private clearAssetPlayer;
2472
2474
  private emptyPlayerQueue;
2473
2475
  private startAssetPlayer;
package/dist/hls.js CHANGED
@@ -1165,7 +1165,7 @@
1165
1165
  // Some browsers don't allow to use bind on console object anyway
1166
1166
  // fallback to default if needed
1167
1167
  try {
1168
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.3-0.canary.11251");
1168
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.3-0.canary.11252");
1169
1169
  } catch (e) {
1170
1170
  /* log fn threw an exception. All logger methods are no-ops. */
1171
1171
  return createLogger();
@@ -16677,7 +16677,7 @@
16677
16677
  return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
16678
16678
  }
16679
16679
 
16680
- var version = "1.6.3-0.canary.11251";
16680
+ var version = "1.6.3-0.canary.11252";
16681
16681
 
16682
16682
  // ensure the worker ends up in the bundle
16683
16683
  // If the worker should not be included this gets aliased to empty.js
@@ -23392,14 +23392,18 @@
23392
23392
  // using `schedule.resetErrorsInRange(start, end)`.
23393
23393
  };
23394
23394
  _proto.isAssetPastPlayoutLimit = function isAssetPastPlayoutLimit(assetIndex) {
23395
- if (assetIndex >= this.assetList.length) {
23395
+ var _this$assetList$asset;
23396
+ if (assetIndex > 0 && assetIndex >= this.assetList.length) {
23396
23397
  return true;
23397
23398
  }
23398
23399
  var playoutLimit = this.playoutLimit;
23399
23400
  if (assetIndex <= 0 || isNaN(playoutLimit)) {
23400
23401
  return false;
23401
23402
  }
23402
- var assetOffset = this.assetList[assetIndex].startOffset;
23403
+ if (playoutLimit === 0) {
23404
+ return true;
23405
+ }
23406
+ var assetOffset = ((_this$assetList$asset = this.assetList[assetIndex]) == null ? void 0 : _this$assetList$asset.startOffset) || 0;
23403
23407
  return assetOffset > playoutLimit;
23404
23408
  };
23405
23409
  _proto.findAssetIndex = function findAssetIndex(asset) {
@@ -23582,6 +23586,12 @@
23582
23586
  }
23583
23587
  return url;
23584
23588
  }
23589
+ function getNextAssetIndex(interstitial, assetListIndex) {
23590
+ while ((_interstitial$assetLi = interstitial.assetList[++assetListIndex]) != null && _interstitial$assetLi.error) {
23591
+ var _interstitial$assetLi;
23592
+ } /* no-op */
23593
+ return assetListIndex;
23594
+ }
23585
23595
  function eventToString(interstitial) {
23586
23596
  return "[\"" + interstitial.identifier + "\" " + (interstitial.cue.pre ? '<pre>' : interstitial.cue.post ? '<post>' : '') + interstitial.timelineStart.toFixed(2) + "-" + interstitial.resumeTime.toFixed(2) + "]";
23587
23597
  }
@@ -23712,6 +23722,19 @@
23712
23722
  this.bufferSnapShot();
23713
23723
  return this.hls.transferMedia();
23714
23724
  };
23725
+ _proto.resetDetails = function resetDetails() {
23726
+ var hls = this.hls;
23727
+ if (this.hasDetails) {
23728
+ hls.stopLoad();
23729
+ var deleteDetails = function deleteDetails(obj) {
23730
+ return delete obj.details;
23731
+ };
23732
+ hls.levels.forEach(deleteDetails);
23733
+ hls.allAudioTracks.forEach(deleteDetails);
23734
+ hls.allSubtitleTracks.forEach(deleteDetails);
23735
+ this.hasDetails = false;
23736
+ }
23737
+ };
23715
23738
  _proto.on = function on(event, listener, context) {
23716
23739
  this.hls.on(event, listener);
23717
23740
  };
@@ -24613,7 +24636,7 @@
24613
24636
  return interstitial.identifier;
24614
24637
  });
24615
24638
  var interstitialsUpdated = !!(interstitialEvents.length || removedIds.length);
24616
- if (interstitialsUpdated) {
24639
+ if (interstitialsUpdated || previousItems) {
24617
24640
  _this.log("INTERSTITIALS_UPDATED (" + interstitialEvents.length + "): " + interstitialEvents + "\nSchedule: " + scheduleItems.map(function (seg) {
24618
24641
  return segmentToString(seg);
24619
24642
  }) + " pos: " + _this.timelinePos);
@@ -24974,8 +24997,8 @@
24974
24997
  }
24975
24998
  };
24976
24999
  _proto.advanceAfterAssetEnded = function advanceAfterAssetEnded(interstitial, index, assetListIndex) {
24977
- var nextAssetIndex = assetListIndex + 1;
24978
- if (!interstitial.isAssetPastPlayoutLimit(nextAssetIndex) && !interstitial.assetList[nextAssetIndex].error) {
25000
+ var nextAssetIndex = getNextAssetIndex(interstitial, assetListIndex);
25001
+ if (!interstitial.isAssetPastPlayoutLimit(nextAssetIndex)) {
24979
25002
  // Advance to next asset list item
24980
25003
  this.setSchedulePosition(index, nextAssetIndex);
24981
25004
  } else {
@@ -25005,7 +25028,7 @@
25005
25028
  if (interstitial) {
25006
25029
  var itemIndex = schedule.findEventIndex(parentIdentifier);
25007
25030
  var assetListIndex = schedule.findAssetIndex(interstitial, time);
25008
- this.setSchedulePosition(itemIndex, assetListIndex);
25031
+ this.advanceAfterAssetEnded(interstitial, itemIndex, assetListIndex - 1);
25009
25032
  }
25010
25033
  };
25011
25034
  _proto.setSchedulePosition = function setSchedulePosition(index, assetListIndex) {
@@ -25026,13 +25049,13 @@
25026
25049
  var player = assetId ? this.getAssetPlayer(assetId) : null;
25027
25050
  if (player && assetId && (!this.eventItemsMatch(currentItem, scheduledItem) || assetListIndex !== undefined && assetId !== ((_interstitial$assetLi = interstitial.assetList) == null ? void 0 : _interstitial$assetLi[assetListIndex].identifier))) {
25028
25051
  var _this$detachedData2;
25029
- var _assetListIndex = interstitial.findAssetIndex(playingAsset);
25030
- this.log("INTERSTITIAL_ASSET_ENDED " + (_assetListIndex + 1) + "/" + interstitial.assetList.length + " " + eventAssetToString(playingAsset));
25052
+ var playingAssetListIndex = interstitial.findAssetIndex(playingAsset);
25053
+ this.log("INTERSTITIAL_ASSET_ENDED " + (playingAssetListIndex + 1) + "/" + interstitial.assetList.length + " " + eventAssetToString(playingAsset));
25031
25054
  this.endedAsset = playingAsset;
25032
25055
  this.playingAsset = null;
25033
25056
  this.hls.trigger(Events.INTERSTITIAL_ASSET_ENDED, {
25034
25057
  asset: playingAsset,
25035
- assetListIndex: _assetListIndex,
25058
+ assetListIndex: playingAssetListIndex,
25036
25059
  event: interstitial,
25037
25060
  schedule: scheduleItems.slice(0),
25038
25061
  scheduleIndex: index,
@@ -25091,6 +25114,12 @@
25091
25114
  // find asset index
25092
25115
  if (assetListIndex === undefined) {
25093
25116
  assetListIndex = this.schedule.findAssetIndex(interstitial, this.timelinePos);
25117
+ var assetIndexCandidate = getNextAssetIndex(interstitial, assetListIndex - 1);
25118
+ if (interstitial.isAssetPastPlayoutLimit(assetIndexCandidate)) {
25119
+ this.advanceAfterAssetEnded(interstitial, index, assetListIndex);
25120
+ return;
25121
+ }
25122
+ assetListIndex = assetIndexCandidate;
25094
25123
  }
25095
25124
  // Ensure Interstitial is enqueued
25096
25125
  var waitingItem = this.waitingItem;
@@ -25193,7 +25222,7 @@
25193
25222
  if (!scheduleItems) {
25194
25223
  return;
25195
25224
  }
25196
- this.log("resumed " + segmentToString(scheduledItem));
25225
+ this.log("INTERSTITIALS_PRIMARY_RESUMED " + segmentToString(scheduledItem));
25197
25226
  this.hls.trigger(Events.INTERSTITIALS_PRIMARY_RESUMED, {
25198
25227
  schedule: scheduleItems.slice(0),
25199
25228
  scheduleIndex: index
@@ -25496,9 +25525,9 @@
25496
25525
  var bufferingPlayer = this.getBufferingPlayer();
25497
25526
  this.bufferingItem = item;
25498
25527
  this.bufferedPos = Math.max(item.start, Math.min(item.end, this.timelinePos));
25528
+ var timeRemaining = bufferingPlayer ? bufferingPlayer.remaining : bufferingLast ? bufferingLast.end - this.timelinePos : 0;
25529
+ this.log("INTERSTITIALS_BUFFERED_TO_BOUNDARY " + segmentToString(item) + (bufferingLast ? " (" + timeRemaining.toFixed(2) + " remaining)" : ''));
25499
25530
  if (!this.playbackDisabled) {
25500
- var timeRemaining = bufferingPlayer ? bufferingPlayer.remaining : bufferingLast ? bufferingLast.end - this.timelinePos : 0;
25501
- this.log("buffered to boundary " + segmentToString(item) + (bufferingLast ? " (" + timeRemaining.toFixed(2) + " remaining)" : ''));
25502
25531
  if (isInterstitial) {
25503
25532
  // primary fragment loading will exit early in base-stream-controller while `bufferingItem` is set to an Interstitial block
25504
25533
  item.event.assetList.forEach(function (asset) {
@@ -25682,7 +25711,6 @@
25682
25711
  };
25683
25712
  _proto.createAssetPlayer = function createAssetPlayer(interstitial, assetItem, assetListIndex) {
25684
25713
  var _this8 = this;
25685
- this.log("create HLSAssetPlayer for " + eventAssetToString(assetItem));
25686
25714
  var primary = this.hls;
25687
25715
  var userConfig = primary.userConfig;
25688
25716
  var videoPreference = userConfig.videoPreference;
@@ -25793,11 +25821,11 @@
25793
25821
  }
25794
25822
  // Preload at end of asset
25795
25823
  var scheduleIndex = _this8.schedule.findEventIndex(interstitial.identifier);
25796
- var assetListIndex = interstitial.findAssetIndex(assetItem);
25797
- var nextAssetIndex = assetListIndex + 1;
25798
25824
  var item = (_this8$schedule$items = _this8.schedule.items) == null ? void 0 : _this8$schedule$items[scheduleIndex];
25799
25825
  if (_this8.isInterstitial(item)) {
25800
- if (assetListIndex !== -1 && !interstitial.isAssetPastPlayoutLimit(nextAssetIndex) && !interstitial.assetList[nextAssetIndex].error) {
25826
+ var _assetListIndex = interstitial.findAssetIndex(assetItem);
25827
+ var nextAssetIndex = getNextAssetIndex(interstitial, _assetListIndex);
25828
+ if (!interstitial.isAssetPastPlayoutLimit(nextAssetIndex)) {
25801
25829
  _this8.bufferedToItem(item, nextAssetIndex);
25802
25830
  } else {
25803
25831
  var _this8$schedule$items2;
@@ -25855,6 +25883,7 @@
25855
25883
  };
25856
25884
  _this8.handleAssetItemError(errorData, interstitial, _this8.schedule.findEventIndex(interstitial.identifier), assetListIndex, error.message);
25857
25885
  });
25886
+ this.log("INTERSTITIAL_ASSET_PLAYER_CREATED " + eventAssetToString(assetItem));
25858
25887
  this.hls.trigger(Events.INTERSTITIAL_ASSET_PLAYER_CREATED, {
25859
25888
  asset: assetItem,
25860
25889
  assetListIndex: assetListIndex,
@@ -25871,10 +25900,20 @@
25871
25900
  // Remove asset list and resolved duration
25872
25901
  interstitial.reset();
25873
25902
  };
25903
+ _proto.resetAssetPlayer = function resetAssetPlayer(assetId) {
25904
+ // Reset asset player so that it's timeline can be adjusted without reloading the MVP
25905
+ var playerIndex = this.getAssetPlayerQueueIndex(assetId);
25906
+ if (playerIndex !== -1) {
25907
+ this.log("reset asset player \"" + assetId + "\" after error");
25908
+ var player = this.playerQueue[playerIndex];
25909
+ this.transferMediaFromPlayer(player, null);
25910
+ player.resetDetails();
25911
+ }
25912
+ };
25874
25913
  _proto.clearAssetPlayer = function clearAssetPlayer(assetId, toSegment) {
25875
25914
  var playerIndex = this.getAssetPlayerQueueIndex(assetId);
25876
25915
  if (playerIndex !== -1) {
25877
- this.log("clearAssetPlayer \"" + assetId + "\" toSegment: " + (toSegment ? segmentToString(toSegment) : toSegment));
25916
+ this.log("clear asset player \"" + assetId + "\" toSegment: " + (toSegment ? segmentToString(toSegment) : toSegment));
25878
25917
  var player = this.playerQueue[playerIndex];
25879
25918
  this.transferMediaFromPlayer(player, toSegment);
25880
25919
  this.playerQueue.splice(playerIndex, 1);
@@ -25902,7 +25941,7 @@
25902
25941
  this.clearAssetPlayer(playingAsset.identifier, scheduleItems[scheduleIndex]);
25903
25942
  delete playingAsset.error;
25904
25943
  }
25905
- this.log("INTERSTITIAL_ASSET_STARTED " + (assetListIndex + 1) + "/" + assetListLength + " " + player);
25944
+ this.log("INTERSTITIAL_ASSET_STARTED " + (assetListIndex + 1) + "/" + assetListLength + " " + eventAssetToString(assetItem));
25906
25945
  this.hls.trigger(Events.INTERSTITIAL_ASSET_STARTED, {
25907
25946
  asset: assetItem,
25908
25947
  assetListIndex: assetListIndex,
@@ -25919,8 +25958,8 @@
25919
25958
  _proto.bufferAssetPlayer = function bufferAssetPlayer(player, media) {
25920
25959
  var _this$schedule$items2, _this$detachedData4;
25921
25960
  var interstitial = player.interstitial,
25922
- assetItem = player.assetItem,
25923
- assetId = player.assetId;
25961
+ assetItem = player.assetItem;
25962
+ player.assetId;
25924
25963
  var scheduleIndex = this.schedule.findEventIndex(interstitial.identifier);
25925
25964
  var item = (_this$schedule$items2 = this.schedule.items) == null ? void 0 : _this$schedule$items2[scheduleIndex];
25926
25965
  if (!item) {
@@ -25944,7 +25983,7 @@
25944
25983
  return;
25945
25984
  }
25946
25985
  if (activeTracks && !isCompatibleTrackChange(activeTracks, player.tracks)) {
25947
- var error = new Error("Asset \"" + assetId + "\" SourceBuffer tracks ('" + Object.keys(player.tracks) + "') are not compatible with primary content tracks ('" + Object.keys(activeTracks) + "')");
25986
+ var error = new Error("Asset " + eventAssetToString(assetItem) + " SourceBuffer tracks ('" + Object.keys(player.tracks) + "') are not compatible with primary content tracks ('" + Object.keys(activeTracks) + "')");
25948
25987
  var errorData = {
25949
25988
  fatal: true,
25950
25989
  type: ErrorTypes.OTHER_ERROR,
@@ -25962,12 +26001,11 @@
25962
26001
  if (data.details === ErrorDetails.BUFFER_STALLED_ERROR) {
25963
26002
  return;
25964
26003
  }
25965
- var assetItem = interstitial.assetList[assetListIndex] || null;
25966
- var player = null;
25967
- if (assetItem) {
25968
- var playerIndex = this.getAssetPlayerQueueIndex(assetItem.identifier);
25969
- player = this.playerQueue[playerIndex] || null;
25970
- }
26004
+ var assetItem = interstitial.assetList[assetListIndex];
26005
+ this.warn("INTERSTITIAL_ASSET_ERROR " + (assetItem ? eventAssetToString(assetItem) : assetItem) + " " + data.error);
26006
+ var assetId = assetItem == null ? void 0 : assetItem.identifier;
26007
+ var playerIndex = this.getAssetPlayerQueueIndex(assetId);
26008
+ var player = this.playerQueue[playerIndex] || null;
25971
26009
  var items = this.schedule.items;
25972
26010
  var interstitialAssetError = _extends({}, data, {
25973
26011
  fatal: false,
@@ -25979,16 +26017,14 @@
25979
26017
  scheduleIndex: scheduleIndex,
25980
26018
  player: player
25981
26019
  });
25982
- this.warn("Asset item error: " + data.error);
25983
26020
  this.hls.trigger(Events.INTERSTITIAL_ASSET_ERROR, interstitialAssetError);
25984
26021
  if (!data.fatal) {
25985
26022
  return;
25986
26023
  }
26024
+ var playingAsset = this.playingAsset;
25987
26025
  var error = new Error(errorMessage);
25988
26026
  if (assetItem) {
25989
- if (this.playingAsset !== assetItem) {
25990
- this.clearAssetPlayer(assetItem.identifier, null);
25991
- }
26027
+ this.clearAssetPlayer(assetId, null);
25992
26028
  assetItem.error = error;
25993
26029
  }
25994
26030
 
@@ -25998,10 +26034,17 @@
25998
26034
  })) {
25999
26035
  interstitial.error = error;
26000
26036
  } else if (interstitial.appendInPlace) {
26001
- // Skip entire interstitial since moving up subsequent assets is error prone
26002
- interstitial.error = error;
26037
+ // Reset level details and reload/parse media playlists to align with updated schedule
26038
+ for (var i = assetListIndex; i < interstitial.assetList.length; i++) {
26039
+ this.resetAssetPlayer(interstitial.assetList[i].identifier);
26040
+ }
26041
+ this.updateSchedule();
26042
+ }
26043
+ if (interstitial.error) {
26044
+ this.primaryFallback(interstitial);
26045
+ } else if (playingAsset && playingAsset.identifier === assetId) {
26046
+ this.advanceAfterAssetEnded(interstitial, scheduleIndex, assetListIndex);
26003
26047
  }
26004
- this.primaryFallback(interstitial);
26005
26048
  };
26006
26049
  _proto.primaryFallback = function primaryFallback(interstitial) {
26007
26050
  // Fallback to Primary by on current or future events by updating schedule to skip errored interstitials/assets
@@ -26016,16 +26059,15 @@
26016
26059
  timelinePos = this.hls.startPosition;
26017
26060
  }
26018
26061
  var newPlayingItem = this.updateItem(playingItem, timelinePos);
26019
- if (!this.itemsMatch(playingItem, newPlayingItem)) {
26020
- var scheduleIndex = this.schedule.findItemIndexAtTime(timelinePos);
26021
- this.setSchedulePosition(scheduleIndex);
26022
- } else {
26062
+ if (this.itemsMatch(playingItem, newPlayingItem)) {
26023
26063
  this.clearInterstitial(interstitial, null);
26024
26064
  }
26025
26065
  if (interstitial.appendInPlace) {
26026
26066
  this.attachPrimary(flushStart, null);
26027
26067
  this.flushFrontBuffer(flushStart);
26028
26068
  }
26069
+ var scheduleIndex = this.schedule.findItemIndexAtTime(timelinePos);
26070
+ this.setSchedulePosition(scheduleIndex);
26029
26071
  } else {
26030
26072
  this.checkStart();
26031
26073
  }
package/dist/hls.js.d.ts CHANGED
@@ -1983,6 +1983,7 @@ export declare class HlsAssetPlayer {
1983
1983
  resumeBuffering(): void;
1984
1984
  pauseBuffering(): void;
1985
1985
  transferMedia(): AttachMediaSourceData | null;
1986
+ resetDetails(): void;
1986
1987
  on<E extends keyof HlsListeners, Context = undefined>(event: E, listener: HlsListeners[E], context?: Context): void;
1987
1988
  once<E extends keyof HlsListeners, Context = undefined>(event: E, listener: HlsListeners[E], context?: Context): void;
1988
1989
  off<E extends keyof HlsListeners, Context = undefined>(event: E, listener: HlsListeners[E], context?: Context): void;
@@ -2468,6 +2469,7 @@ export declare class InterstitialsController extends Logger implements NetworkCo
2468
2469
  private createAsset;
2469
2470
  private createAssetPlayer;
2470
2471
  private clearInterstitial;
2472
+ private resetAssetPlayer;
2471
2473
  private clearAssetPlayer;
2472
2474
  private emptyPlayerQueue;
2473
2475
  private startAssetPlayer;