hls.js 1.6.3-0.canary.11230 → 1.6.3-0.canary.11233

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
@@ -2446,6 +2446,7 @@ export declare class InterstitialsController extends Logger implements NetworkCo
2446
2446
  private onMediaEnded;
2447
2447
  private onScheduleUpdate;
2448
2448
  private updateItem;
2449
+ private trimInPlace;
2449
2450
  private itemsMatch;
2450
2451
  private eventItemsMatch;
2451
2452
  private findItemIndex;
package/dist/hls.d.ts CHANGED
@@ -2446,6 +2446,7 @@ export declare class InterstitialsController extends Logger implements NetworkCo
2446
2446
  private onMediaEnded;
2447
2447
  private onScheduleUpdate;
2448
2448
  private updateItem;
2449
+ private trimInPlace;
2449
2450
  private itemsMatch;
2450
2451
  private eventItemsMatch;
2451
2452
  private findItemIndex;
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.11230");
1168
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.3-0.canary.11233");
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.11230";
16680
+ var version = "1.6.3-0.canary.11233";
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
@@ -24616,7 +24616,7 @@
24616
24616
  if (interstitialsUpdated) {
24617
24617
  _this.log("INTERSTITIALS_UPDATED (" + interstitialEvents.length + "): " + interstitialEvents + "\nSchedule: " + scheduleItems.map(function (seg) {
24618
24618
  return segmentToString(seg);
24619
- }));
24619
+ }) + " pos: " + _this.timelinePos);
24620
24620
  }
24621
24621
  if (removedIds.length) {
24622
24622
  _this.log("Removed events " + removedIds);
@@ -24639,11 +24639,15 @@
24639
24639
 
24640
24640
  // Update schedule item references
24641
24641
  // Do not replace Interstitial playingItem without a match - used for INTERSTITIAL_ASSET_ENDED and INTERSTITIAL_ENDED
24642
+ var trimInPlaceForPlayout = null;
24642
24643
  if (playingItem) {
24643
24644
  var updatedPlayingItem = _this.updateItem(playingItem, _this.timelinePos);
24644
24645
  if (_this.itemsMatch(playingItem, updatedPlayingItem)) {
24645
24646
  _this.playingItem = updatedPlayingItem;
24646
24647
  _this.waitingItem = _this.endedItem = null;
24648
+ trimInPlaceForPlayout = function trimInPlaceForPlayout() {
24649
+ return _this.trimInPlace(updatedPlayingItem, playingItem);
24650
+ };
24647
24651
  }
24648
24652
  } else {
24649
24653
  // Clear waitingItem if it has been removed from the schedule
@@ -24656,6 +24660,9 @@
24656
24660
  var updatedBufferingItem = _this.updateItem(bufferingItem, _this.bufferedPos);
24657
24661
  if (_this.itemsMatch(bufferingItem, updatedBufferingItem)) {
24658
24662
  _this.bufferingItem = updatedBufferingItem;
24663
+ trimInPlaceForPlayout || (trimInPlaceForPlayout = function trimInPlaceForPlayout() {
24664
+ return _this.trimInPlace(updatedBufferingItem, bufferingItem);
24665
+ });
24659
24666
  } else if (bufferingItem.event) {
24660
24667
  // Interstitial removed from schedule (Live -> VOD or other scenario where Start Date is outside the range of VOD Playlist)
24661
24668
  _this.bufferingItem = _this.playingItem;
@@ -24679,6 +24686,9 @@
24679
24686
  _this.primaryFallback(playingItem.event);
24680
24687
  return;
24681
24688
  }
24689
+ if (trimInPlaceForPlayout) {
24690
+ trimInPlaceForPlayout();
24691
+ }
24682
24692
 
24683
24693
  // Check is buffered to new Interstitial event boundary
24684
24694
  // (Live update publishes Interstitial with new segment)
@@ -25369,6 +25379,22 @@
25369
25379
  }
25370
25380
  return null;
25371
25381
  };
25382
+ _proto.trimInPlace = function trimInPlace(updatedItem, itemBeforeUpdate) {
25383
+ var _this4 = this;
25384
+ if (this.isInterstitial(updatedItem) && updatedItem.event.appendInPlace && itemBeforeUpdate.end - updatedItem.end > 0.25) {
25385
+ updatedItem.event.assetList.forEach(function (asset, index) {
25386
+ if (updatedItem.event.isAssetPastPlayoutLimit(index)) {
25387
+ _this4.clearAssetPlayer(asset.identifier, null);
25388
+ }
25389
+ });
25390
+ var flushStart = updatedItem.end + 0.25;
25391
+ var bufferInfo = BufferHelper.bufferInfo(this.primaryMedia, flushStart, 0);
25392
+ if (bufferInfo.end > flushStart || (bufferInfo.nextStart || 0) > flushStart) {
25393
+ this.attachPrimary(flushStart, null);
25394
+ this.flushFrontBuffer(flushStart);
25395
+ }
25396
+ }
25397
+ };
25372
25398
  _proto.itemsMatch = function itemsMatch(a, b) {
25373
25399
  return !!b && (a === b || a.event && b.event && this.eventItemsMatch(a, b) || !a.event && !b.event && this.findItemIndex(a) === this.findItemIndex(b));
25374
25400
  };
@@ -25446,18 +25472,18 @@
25446
25472
  }
25447
25473
  };
25448
25474
  _proto.assetsBuffered = function assetsBuffered(item, media) {
25449
- var _this4 = this;
25475
+ var _this5 = this;
25450
25476
  var assetList = item.event.assetList;
25451
25477
  if (assetList.length === 0) {
25452
25478
  return false;
25453
25479
  }
25454
25480
  return !item.event.assetList.some(function (asset) {
25455
- var player = _this4.getAssetPlayer(asset.identifier);
25481
+ var player = _this5.getAssetPlayer(asset.identifier);
25456
25482
  return !(player != null && player.bufferedInPlaceToEnd(media));
25457
25483
  });
25458
25484
  };
25459
25485
  _proto.setBufferingItem = function setBufferingItem(item) {
25460
- var _this5 = this;
25486
+ var _this6 = this;
25461
25487
  var bufferingLast = this.bufferingItem;
25462
25488
  var schedule = this.schedule;
25463
25489
  if (!this.itemsMatch(item, bufferingLast)) {
@@ -25476,7 +25502,7 @@
25476
25502
  if (isInterstitial) {
25477
25503
  // primary fragment loading will exit early in base-stream-controller while `bufferingItem` is set to an Interstitial block
25478
25504
  item.event.assetList.forEach(function (asset) {
25479
- var player = _this5.getAssetPlayer(asset.identifier);
25505
+ var player = _this6.getAssetPlayer(asset.identifier);
25480
25506
  if (player) {
25481
25507
  player.resumeBuffering();
25482
25508
  }
@@ -25599,7 +25625,7 @@
25599
25625
  return null;
25600
25626
  };
25601
25627
  _proto.flushFrontBuffer = function flushFrontBuffer(startOffset) {
25602
- var _this6 = this;
25628
+ var _this7 = this;
25603
25629
  // Force queued flushing of all buffers
25604
25630
  var requiredTracks = this.requiredTracks;
25605
25631
  if (!requiredTracks) {
@@ -25608,7 +25634,7 @@
25608
25634
  this.log("Removing front buffer starting at " + startOffset);
25609
25635
  var sourceBufferNames = Object.keys(requiredTracks);
25610
25636
  sourceBufferNames.forEach(function (type) {
25611
- _this6.hls.trigger(Events.BUFFER_FLUSHING, {
25637
+ _this7.hls.trigger(Events.BUFFER_FLUSHING, {
25612
25638
  startOffset: startOffset,
25613
25639
  endOffset: Infinity,
25614
25640
  type: type
@@ -25655,7 +25681,7 @@
25655
25681
  return this.createAssetPlayer(interstitial, assetItem, assetListIndex);
25656
25682
  };
25657
25683
  _proto.createAssetPlayer = function createAssetPlayer(interstitial, assetItem, assetListIndex) {
25658
- var _this7 = this;
25684
+ var _this8 = this;
25659
25685
  this.log("create HLSAssetPlayer for " + eventAssetToString(assetItem));
25660
25686
  var primary = this.hls;
25661
25687
  var userConfig = primary.userConfig;
@@ -25725,17 +25751,17 @@
25725
25751
  details: ErrorDetails.INTERSTITIAL_ASSET_ITEM_ERROR,
25726
25752
  error: error
25727
25753
  };
25728
- _this7.handleAssetItemError(errorData, interstitial, _this7.schedule.findEventIndex(interstitial.identifier), assetListIndex, error.message);
25754
+ _this8.handleAssetItemError(errorData, interstitial, _this8.schedule.findEventIndex(interstitial.identifier), assetListIndex, error.message);
25729
25755
  return;
25730
25756
  }
25731
25757
  // Get time at end of last fragment
25732
25758
  var duration = details.edge - details.fragmentStart;
25733
25759
  var currentAssetDuration = assetItem.duration;
25734
25760
  if (currentAssetDuration === null || duration > currentAssetDuration) {
25735
- _this7.log("Interstitial asset \"" + assetId + "\" duration change " + currentAssetDuration + " > " + duration);
25761
+ _this8.log("Interstitial asset \"" + assetId + "\" duration change " + currentAssetDuration + " > " + duration);
25736
25762
  assetItem.duration = duration;
25737
25763
  // Update schedule with new event and asset duration
25738
- _this7.updateSchedule();
25764
+ _this8.updateSchedule();
25739
25765
  }
25740
25766
  };
25741
25767
  player.on(Events.LEVEL_UPDATED, function (event, _ref) {
@@ -25747,37 +25773,37 @@
25747
25773
  return updateAssetPlayerDetails(details);
25748
25774
  });
25749
25775
  var _onBufferCodecs = function onBufferCodecs(event, data) {
25750
- var inQueuPlayer = _this7.getAssetPlayer(assetId);
25776
+ var inQueuPlayer = _this8.getAssetPlayer(assetId);
25751
25777
  if (inQueuPlayer && data.tracks) {
25752
25778
  inQueuPlayer.off(Events.BUFFER_CODECS, _onBufferCodecs);
25753
25779
  inQueuPlayer.tracks = data.tracks;
25754
- var media = _this7.primaryMedia;
25755
- if (_this7.bufferingAsset === inQueuPlayer.assetItem && media && !inQueuPlayer.media) {
25756
- _this7.bufferAssetPlayer(inQueuPlayer, media);
25780
+ var media = _this8.primaryMedia;
25781
+ if (_this8.bufferingAsset === inQueuPlayer.assetItem && media && !inQueuPlayer.media) {
25782
+ _this8.bufferAssetPlayer(inQueuPlayer, media);
25757
25783
  }
25758
25784
  }
25759
25785
  };
25760
25786
  player.on(Events.BUFFER_CODECS, _onBufferCodecs);
25761
25787
  var bufferedToEnd = function bufferedToEnd() {
25762
- var _this7$schedule$items;
25763
- var inQueuPlayer = _this7.getAssetPlayer(assetId);
25764
- _this7.log("buffered to end of asset " + inQueuPlayer);
25788
+ var _this8$schedule$items;
25789
+ var inQueuPlayer = _this8.getAssetPlayer(assetId);
25790
+ _this8.log("buffered to end of asset " + inQueuPlayer);
25765
25791
  if (!inQueuPlayer) {
25766
25792
  return;
25767
25793
  }
25768
25794
  // Preload at end of asset
25769
- var scheduleIndex = _this7.schedule.findEventIndex(interstitial.identifier);
25795
+ var scheduleIndex = _this8.schedule.findEventIndex(interstitial.identifier);
25770
25796
  var assetListIndex = interstitial.findAssetIndex(assetItem);
25771
25797
  var nextAssetIndex = assetListIndex + 1;
25772
- var item = (_this7$schedule$items = _this7.schedule.items) == null ? void 0 : _this7$schedule$items[scheduleIndex];
25773
- if (_this7.isInterstitial(item)) {
25798
+ var item = (_this8$schedule$items = _this8.schedule.items) == null ? void 0 : _this8$schedule$items[scheduleIndex];
25799
+ if (_this8.isInterstitial(item)) {
25774
25800
  if (assetListIndex !== -1 && !interstitial.isAssetPastPlayoutLimit(nextAssetIndex) && !interstitial.assetList[nextAssetIndex].error) {
25775
- _this7.bufferedToItem(item, nextAssetIndex);
25801
+ _this8.bufferedToItem(item, nextAssetIndex);
25776
25802
  } else {
25777
- var _this7$schedule$items2;
25778
- var nextItem = (_this7$schedule$items2 = _this7.schedule.items) == null ? void 0 : _this7$schedule$items2[scheduleIndex + 1];
25803
+ var _this8$schedule$items2;
25804
+ var nextItem = (_this8$schedule$items2 = _this8.schedule.items) == null ? void 0 : _this8$schedule$items2[scheduleIndex + 1];
25779
25805
  if (nextItem) {
25780
- _this7.bufferedToItem(nextItem);
25806
+ _this8.bufferedToItem(nextItem);
25781
25807
  }
25782
25808
  }
25783
25809
  }
@@ -25785,38 +25811,38 @@
25785
25811
  player.on(Events.BUFFERED_TO_END, bufferedToEnd);
25786
25812
  var endedWithAssetIndex = function endedWithAssetIndex(assetIndex) {
25787
25813
  return function () {
25788
- var inQueuPlayer = _this7.getAssetPlayer(assetId);
25814
+ var inQueuPlayer = _this8.getAssetPlayer(assetId);
25789
25815
  if (!inQueuPlayer) {
25790
25816
  return;
25791
25817
  }
25792
- _this7.shouldPlay = true;
25793
- var scheduleIndex = _this7.schedule.findEventIndex(interstitial.identifier);
25794
- _this7.advanceAfterAssetEnded(interstitial, scheduleIndex, assetIndex);
25818
+ _this8.shouldPlay = true;
25819
+ var scheduleIndex = _this8.schedule.findEventIndex(interstitial.identifier);
25820
+ _this8.advanceAfterAssetEnded(interstitial, scheduleIndex, assetIndex);
25795
25821
  };
25796
25822
  };
25797
25823
  player.once(Events.MEDIA_ENDED, endedWithAssetIndex(assetListIndex));
25798
25824
  player.once(Events.PLAYOUT_LIMIT_REACHED, endedWithAssetIndex(Infinity));
25799
25825
  player.on(Events.ERROR, function (event, data) {
25800
- var inQueuPlayer = _this7.getAssetPlayer(assetId);
25826
+ var inQueuPlayer = _this8.getAssetPlayer(assetId);
25801
25827
  if (data.details === ErrorDetails.BUFFER_STALLED_ERROR) {
25802
25828
  if (inQueuPlayer != null && inQueuPlayer.media) {
25803
25829
  var assetCurrentTime = inQueuPlayer.currentTime;
25804
25830
  var distanceFromEnd = inQueuPlayer.duration - assetCurrentTime;
25805
25831
  if (assetCurrentTime && interstitial.appendInPlace && distanceFromEnd / inQueuPlayer.media.playbackRate < 0.5) {
25806
- _this7.log("Advancing buffer past end of asset " + assetId + " " + interstitial + " at " + inQueuPlayer.media.currentTime);
25832
+ _this8.log("Advancing buffer past end of asset " + assetId + " " + interstitial + " at " + inQueuPlayer.media.currentTime);
25807
25833
  bufferedToEnd();
25808
25834
  } else {
25809
- _this7.warn("Stalled at " + assetCurrentTime + " of " + (assetCurrentTime + distanceFromEnd) + " in asset " + assetId + " " + interstitial);
25810
- _this7.onTimeupdate();
25811
- _this7.checkBuffer(true);
25835
+ _this8.warn("Stalled at " + assetCurrentTime + " of " + (assetCurrentTime + distanceFromEnd) + " in asset " + assetId + " " + interstitial);
25836
+ _this8.onTimeupdate();
25837
+ _this8.checkBuffer(true);
25812
25838
  }
25813
25839
  }
25814
25840
  return;
25815
25841
  }
25816
- _this7.handleAssetItemError(data, interstitial, _this7.schedule.findEventIndex(interstitial.identifier), assetListIndex, "Asset player error " + data.error + " " + interstitial);
25842
+ _this8.handleAssetItemError(data, interstitial, _this8.schedule.findEventIndex(interstitial.identifier), assetListIndex, "Asset player error " + data.error + " " + interstitial);
25817
25843
  });
25818
25844
  player.on(Events.DESTROYING, function () {
25819
- var inQueuPlayer = _this7.getAssetPlayer(assetId);
25845
+ var inQueuPlayer = _this8.getAssetPlayer(assetId);
25820
25846
  if (!inQueuPlayer) {
25821
25847
  return;
25822
25848
  }
@@ -25827,7 +25853,7 @@
25827
25853
  details: ErrorDetails.INTERSTITIAL_ASSET_ITEM_ERROR,
25828
25854
  error: error
25829
25855
  };
25830
- _this7.handleAssetItemError(errorData, interstitial, _this7.schedule.findEventIndex(interstitial.identifier), assetListIndex, error.message);
25856
+ _this8.handleAssetItemError(errorData, interstitial, _this8.schedule.findEventIndex(interstitial.identifier), assetListIndex, error.message);
25831
25857
  });
25832
25858
  this.hls.trigger(Events.INTERSTITIAL_ASSET_PLAYER_CREATED, {
25833
25859
  asset: assetItem,
@@ -25838,9 +25864,9 @@
25838
25864
  return player;
25839
25865
  };
25840
25866
  _proto.clearInterstitial = function clearInterstitial(interstitial, toSegment) {
25841
- var _this8 = this;
25867
+ var _this9 = this;
25842
25868
  interstitial.assetList.forEach(function (asset) {
25843
- _this8.clearAssetPlayer(asset.identifier, toSegment);
25869
+ _this9.clearAssetPlayer(asset.identifier, toSegment);
25844
25870
  });
25845
25871
  // Remove asset list and resolved duration
25846
25872
  interstitial.reset();
@@ -25985,10 +26011,6 @@
25985
26011
  this.updateSchedule();
25986
26012
  if (playingItem) {
25987
26013
  this.log("Fallback to primary from event \"" + interstitial.identifier + "\" start: " + flushStart + " pos: " + this.timelinePos + " playing: " + (playingItem ? segmentToString(playingItem) : '<none>') + " error: " + interstitial.error);
25988
- if (interstitial.appendInPlace) {
25989
- this.attachPrimary(flushStart, null);
25990
- this.flushFrontBuffer(flushStart);
25991
- }
25992
26014
  var timelinePos = this.timelinePos;
25993
26015
  if (timelinePos === -1) {
25994
26016
  timelinePos = this.hls.startPosition;
@@ -26000,6 +26022,10 @@
26000
26022
  } else {
26001
26023
  this.clearInterstitial(interstitial, null);
26002
26024
  }
26025
+ if (interstitial.appendInPlace) {
26026
+ this.attachPrimary(flushStart, null);
26027
+ this.flushFrontBuffer(flushStart);
26028
+ }
26003
26029
  } else {
26004
26030
  this.checkStart();
26005
26031
  }
@@ -26008,7 +26034,7 @@
26008
26034
  // Asset List loading
26009
26035
  ;
26010
26036
  _proto.onAssetListLoaded = function onAssetListLoaded(event, data) {
26011
- var _this9 = this,
26037
+ var _this0 = this,
26012
26038
  _this$bufferingItem;
26013
26039
  var interstitial = data.event;
26014
26040
  var interstitialId = interstitial.identifier;
@@ -26022,7 +26048,7 @@
26022
26048
  var sumDuration = 0;
26023
26049
  assets.forEach(function (asset, assetListIndex) {
26024
26050
  var duration = parseFloat(asset.DURATION);
26025
- _this9.createAsset(interstitial, assetListIndex, sumDuration, eventStart + sumDuration, duration, asset.URI);
26051
+ _this0.createAsset(interstitial, assetListIndex, sumDuration, eventStart + sumDuration, duration, asset.URI);
26026
26052
  sumDuration += duration;
26027
26053
  });
26028
26054
  interstitial.duration = sumDuration;
package/dist/hls.js.d.ts CHANGED
@@ -2446,6 +2446,7 @@ export declare class InterstitialsController extends Logger implements NetworkCo
2446
2446
  private onMediaEnded;
2447
2447
  private onScheduleUpdate;
2448
2448
  private updateItem;
2449
+ private trimInPlace;
2449
2450
  private itemsMatch;
2450
2451
  private eventItemsMatch;
2451
2452
  private findItemIndex;