hls.js 1.6.0-rc.2.0.canary.11081 → 1.6.0

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
@@ -19,6 +19,7 @@ export declare class AbrController extends Logger implements AbrComponentAPI {
19
19
  private fragCurrent;
20
20
  private partCurrent;
21
21
  private bitrateTestDelay;
22
+ private rebufferNotice;
22
23
  bwEstimator: EwmaBandWidthEstimator;
23
24
  constructor(hls: Hls);
24
25
  resetEstimator(abrEwmaDefaultEstimate?: number): void;
package/dist/hls.d.ts CHANGED
@@ -19,6 +19,7 @@ export declare class AbrController extends Logger implements AbrComponentAPI {
19
19
  private fragCurrent;
20
20
  private partCurrent;
21
21
  private bitrateTestDelay;
22
+ private rebufferNotice;
22
23
  bwEstimator: EwmaBandWidthEstimator;
23
24
  constructor(hls: Hls);
24
25
  resetEstimator(abrEwmaDefaultEstimate?: number): void;
package/dist/hls.js CHANGED
@@ -1073,7 +1073,7 @@
1073
1073
  // Some browsers don't allow to use bind on console object anyway
1074
1074
  // fallback to default if needed
1075
1075
  try {
1076
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-rc.2.0.canary.11081");
1076
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0");
1077
1077
  } catch (e) {
1078
1078
  /* log fn threw an exception. All logger methods are no-ops. */
1079
1079
  return createLogger();
@@ -3899,6 +3899,7 @@
3899
3899
  _this.fragCurrent = null;
3900
3900
  _this.partCurrent = null;
3901
3901
  _this.bitrateTestDelay = 0;
3902
+ _this.rebufferNotice = -1;
3902
3903
  _this.bwEstimator = void 0;
3903
3904
  /*
3904
3905
  This method monitors the download rate of the current fragment, and will downswitch if that fragment will not load
@@ -4289,6 +4290,7 @@
4289
4290
  if (bufferStarvationDelay) {
4290
4291
  var _bestLevel = this.findBestLevel(avgbw, minAutoLevel, maxAutoLevel, bufferStarvationDelay, 0, bwFactor, bwUpFactor);
4291
4292
  if (_bestLevel >= 0) {
4293
+ this.rebufferNotice = -1;
4292
4294
  return _bestLevel;
4293
4295
  }
4294
4296
  }
@@ -4311,7 +4313,10 @@
4311
4313
  }
4312
4314
  }
4313
4315
  var bestLevel = this.findBestLevel(avgbw, minAutoLevel, maxAutoLevel, bufferStarvationDelay, maxStarvationDelay, bwFactor, bwUpFactor);
4314
- this.info((bufferStarvationDelay ? 'rebuffering expected' : 'buffer is empty') + ", optimal quality level " + bestLevel);
4316
+ if (this.rebufferNotice !== bestLevel) {
4317
+ this.rebufferNotice = bestLevel;
4318
+ this.info((bufferStarvationDelay ? 'rebuffering expected' : 'buffer is empty') + ", optimal quality level " + bestLevel);
4319
+ }
4315
4320
  if (bestLevel > -1) {
4316
4321
  return bestLevel;
4317
4322
  }
@@ -9887,6 +9892,10 @@
9887
9892
  frag = this.getFragmentAtPosition(pos, end, levelDetails);
9888
9893
  }
9889
9894
  var programFrag = this.filterReplacedPrimary(frag, levelDetails);
9895
+ if (!programFrag && frag) {
9896
+ var curSNIdx = frag.sn - levelDetails.startSN;
9897
+ programFrag = this.filterReplacedPrimary(fragments[curSNIdx + 1] || null, levelDetails);
9898
+ }
9890
9899
  return this.mapToInitFragWhenRequired(programFrag);
9891
9900
  };
9892
9901
  _proto.isLoopLoading = function isLoopLoading(frag, targetBufferTime) {
@@ -16586,7 +16595,7 @@
16586
16595
  return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
16587
16596
  }
16588
16597
 
16589
- var version = "1.6.0-rc.2.0.canary.11081";
16598
+ var version = "1.6.0";
16590
16599
 
16591
16600
  // ensure the worker ends up in the bundle
16592
16601
  // If the worker should not be included this gets aliased to empty.js
@@ -24080,7 +24089,7 @@
24080
24089
  return !playlists.some(function (playlistType) {
24081
24090
  var details = mediaSelection[playlistType].details;
24082
24091
  var playlistEnd = details.edge;
24083
- if (resumeTime > playlistEnd) {
24092
+ if (resumeTime >= playlistEnd) {
24084
24093
  // Live playback - resumption segments are not yet available
24085
24094
  _this4.log("\"" + interstitial.identifier + "\" resumption " + resumeTime + " past " + playlistType + " playlist end " + playlistEnd);
24086
24095
  // Assume alignment is possible (or reset can take place)
@@ -25187,14 +25196,18 @@
25187
25196
 
25188
25197
  // Schedule buffer control
25189
25198
  ;
25190
- _proto.checkBuffer = function checkBuffer() {
25199
+ _proto.checkBuffer = function checkBuffer(starved) {
25191
25200
  var items = this.schedule.items;
25192
25201
  if (!items) {
25193
25202
  return;
25194
25203
  }
25195
25204
  // Find when combined forward buffer change reaches next schedule segment
25196
25205
  var bufferInfo = BufferHelper.bufferInfo(this.primaryMedia, this.timelinePos, 0);
25197
- this.updateBufferedPos(bufferInfo.end, items, bufferInfo.len === 0);
25206
+ if (starved) {
25207
+ this.bufferedPos = this.timelinePos;
25208
+ }
25209
+ starved || (starved = bufferInfo.len < 1);
25210
+ this.updateBufferedPos(bufferInfo.end, items, starved);
25198
25211
  };
25199
25212
  _proto.updateBufferedPos = function updateBufferedPos(bufferEnd, items, bufferIsEmpty) {
25200
25213
  var schedule = this.schedule;
@@ -25231,8 +25244,12 @@
25231
25244
  this.preloadAssets(nextItemToBuffer.event, 0);
25232
25245
  }
25233
25246
  }
25234
- } else if (bufferIsEmpty && playingItem && !this.itemsMatch(playingItem, bufferingItem) && bufferEndIndex === playingIndex) {
25235
- this.bufferedToItem(playingItem);
25247
+ } else if (bufferIsEmpty && playingItem && !this.itemsMatch(playingItem, bufferingItem)) {
25248
+ if (bufferEndIndex === playingIndex) {
25249
+ this.bufferedToItem(playingItem);
25250
+ } else if (bufferEndIndex === playingIndex + 1) {
25251
+ this.bufferedToItem(items[bufferEndIndex]);
25252
+ }
25236
25253
  }
25237
25254
  };
25238
25255
  _proto.assetsBuffered = function assetsBuffered(item, media) {
@@ -25347,7 +25364,11 @@
25347
25364
  if (neverLoaded) {
25348
25365
  var timelineStart = interstitial.timelineStart;
25349
25366
  if (interstitial.appendInPlace) {
25350
- this.flushFrontBuffer(timelineStart + 0.25);
25367
+ var _playingItem$nextEven;
25368
+ var playingItem = this.playingItem;
25369
+ if (!this.isInterstitial(playingItem) && (playingItem == null ? void 0 : (_playingItem$nextEven = playingItem.nextEvent) == null ? void 0 : _playingItem$nextEven.identifier) === interstitial.identifier) {
25370
+ this.flushFrontBuffer(timelineStart + 0.25);
25371
+ }
25351
25372
  }
25352
25373
  var hlsStartOffset;
25353
25374
  var liveStartPosition = 0;
@@ -25391,6 +25412,7 @@
25391
25412
  if (!requiredTracks) {
25392
25413
  return;
25393
25414
  }
25415
+ this.log("Removing front buffer starting at " + startOffset);
25394
25416
  var sourceBufferNames = Object.keys(requiredTracks);
25395
25417
  sourceBufferNames.forEach(function (type) {
25396
25418
  _this6.hls.trigger(Events.BUFFER_FLUSHING, {
@@ -25467,11 +25489,12 @@
25467
25489
  }
25468
25490
  }
25469
25491
  }
25492
+ var assetId = assetItem.identifier;
25470
25493
  var playerConfig = _objectSpread2(_objectSpread2({}, userConfig), {}, {
25471
25494
  autoStartLoad: true,
25472
25495
  startFragPrefetch: true,
25473
25496
  primarySessionId: primary.sessionId,
25474
- assetPlayerId: assetItem.identifier,
25497
+ assetPlayerId: assetId,
25475
25498
  abrEwmaDefaultEstimate: primary.bandwidthEstimate,
25476
25499
  interstitialsController: undefined,
25477
25500
  startPosition: startPosition,
@@ -25493,10 +25516,12 @@
25493
25516
  contentId: hash(assetItem.uri)
25494
25517
  });
25495
25518
  }
25519
+ if (this.getAssetPlayer(assetId)) {
25520
+ this.warn("Duplicate date range identifier " + interstitial + " and asset " + assetId);
25521
+ }
25496
25522
  var player = new HlsAssetPlayer(this.HlsPlayerClass, playerConfig, interstitial, assetItem);
25497
25523
  this.playerQueue.push(player);
25498
25524
  interstitial.assetList[assetListIndex] = assetItem;
25499
- var assetId = assetItem.identifier;
25500
25525
  // Listen for LevelDetails and PTS change to update duration
25501
25526
  var updateAssetPlayerDetails = function updateAssetPlayerDetails(details) {
25502
25527
  if (details.live) {
@@ -25540,15 +25565,13 @@
25540
25565
  }
25541
25566
  };
25542
25567
  player.on(Events.BUFFER_CODECS, _onBufferCodecs);
25543
- var _bufferedToEnd = function bufferedToEnd(name) {
25568
+ var bufferedToEnd = function bufferedToEnd() {
25544
25569
  var _this7$schedule$items;
25545
25570
  var inQueuPlayer = _this7.getAssetPlayer(assetId);
25546
25571
  _this7.log("buffered to end of asset " + inQueuPlayer);
25547
25572
  if (!inQueuPlayer) {
25548
25573
  return;
25549
25574
  }
25550
- inQueuPlayer.off(Events.BUFFERED_TO_END, _bufferedToEnd);
25551
-
25552
25575
  // Preload at end of asset
25553
25576
  var scheduleIndex = _this7.schedule.findEventIndex(interstitial.identifier);
25554
25577
  var assetListIndex = interstitial.findAssetIndex(assetItem);
@@ -25556,7 +25579,7 @@
25556
25579
  var item = (_this7$schedule$items = _this7.schedule.items) == null ? void 0 : _this7$schedule$items[scheduleIndex];
25557
25580
  if (_this7.isInterstitial(item)) {
25558
25581
  if (assetListIndex !== -1 && !interstitial.isAssetPastPlayoutLimit(nextAssetIndex) && !interstitial.assetList[nextAssetIndex].error) {
25559
- _this7.bufferedToItem(item, assetListIndex + 1);
25582
+ _this7.bufferedToItem(item, nextAssetIndex);
25560
25583
  } else {
25561
25584
  var _this7$schedule$items2;
25562
25585
  var nextItem = (_this7$schedule$items2 = _this7.schedule.items) == null ? void 0 : _this7$schedule$items2[scheduleIndex + 1];
@@ -25566,7 +25589,7 @@
25566
25589
  }
25567
25590
  }
25568
25591
  };
25569
- player.on(Events.BUFFERED_TO_END, _bufferedToEnd);
25592
+ player.on(Events.BUFFERED_TO_END, bufferedToEnd);
25570
25593
  var endedWithAssetIndex = function endedWithAssetIndex(assetIndex) {
25571
25594
  return function () {
25572
25595
  var inQueuPlayer = _this7.getAssetPlayer(assetId);
@@ -25581,6 +25604,22 @@
25581
25604
  player.once(Events.MEDIA_ENDED, endedWithAssetIndex(assetListIndex));
25582
25605
  player.once(Events.PLAYOUT_LIMIT_REACHED, endedWithAssetIndex(Infinity));
25583
25606
  player.on(Events.ERROR, function (event, data) {
25607
+ var inQueuPlayer = _this7.getAssetPlayer(assetId);
25608
+ if (data.details === ErrorDetails.BUFFER_STALLED_ERROR) {
25609
+ if (inQueuPlayer != null && inQueuPlayer.media) {
25610
+ var assetCurrentTime = inQueuPlayer.currentTime;
25611
+ var distanceFromEnd = inQueuPlayer.duration - assetCurrentTime;
25612
+ if (assetCurrentTime && interstitial.appendInPlace && distanceFromEnd / inQueuPlayer.media.playbackRate < 0.5) {
25613
+ _this7.log("Advancing buffer past end of asset " + assetId + " " + interstitial + " at " + inQueuPlayer.media.currentTime);
25614
+ bufferedToEnd();
25615
+ } else {
25616
+ _this7.warn("Stalled at " + assetCurrentTime + " of " + (assetCurrentTime + distanceFromEnd) + " in asset " + assetId + " " + interstitial);
25617
+ _this7.onTimeupdate();
25618
+ _this7.checkBuffer(true);
25619
+ }
25620
+ }
25621
+ return;
25622
+ }
25584
25623
  _this7.handleAssetItemError(data, interstitial, _this7.schedule.findEventIndex(interstitial.identifier), assetListIndex, "Asset player error " + data.error + " " + interstitial);
25585
25624
  });
25586
25625
  player.on(Events.DESTROYING, function () {
@@ -25654,10 +25693,9 @@
25654
25693
  player: player
25655
25694
  });
25656
25695
  }
25657
- if (!player.bufferedInPlaceToEnd(media)) {
25658
- // detach media and attach to interstitial player if it does not have another element attached
25659
- this.bufferAssetPlayer(player, media);
25660
- }
25696
+
25697
+ // detach media and attach to interstitial player if it does not have another element attached
25698
+ this.bufferAssetPlayer(player, media);
25661
25699
  };
25662
25700
  _proto.bufferAssetPlayer = function bufferAssetPlayer(player, media) {
25663
25701
  var _this$schedule$items2, _this$detachedData4;
@@ -25842,6 +25880,13 @@
25842
25880
  if (interstitial) {
25843
25881
  this.primaryFallback(interstitial);
25844
25882
  }
25883
+ break;
25884
+ }
25885
+ case ErrorDetails.BUFFER_STALLED_ERROR:
25886
+ {
25887
+ this.onTimeupdate();
25888
+ this.checkBuffer(true);
25889
+ break;
25845
25890
  }
25846
25891
  }
25847
25892
  };
package/dist/hls.js.d.ts CHANGED
@@ -19,6 +19,7 @@ export declare class AbrController extends Logger implements AbrComponentAPI {
19
19
  private fragCurrent;
20
20
  private partCurrent;
21
21
  private bitrateTestDelay;
22
+ private rebufferNotice;
22
23
  bwEstimator: EwmaBandWidthEstimator;
23
24
  constructor(hls: Hls);
24
25
  resetEstimator(abrEwmaDefaultEstimate?: number): void;