hls.js 1.6.3-0.canary.11232 → 1.6.3-0.canary.11234

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
@@ -523,7 +523,7 @@ function enableLogs(debugConfig, context, id) {
523
523
  // Some browsers don't allow to use bind on console object anyway
524
524
  // fallback to default if needed
525
525
  try {
526
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.3-0.canary.11232"}`);
526
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.3-0.canary.11234"}`);
527
527
  } catch (e) {
528
528
  /* log fn threw an exception. All logger methods are no-ops. */
529
529
  return createLogger();
@@ -10237,7 +10237,7 @@ function requireEventemitter3 () {
10237
10237
  var eventemitter3Exports = requireEventemitter3();
10238
10238
  var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
10239
10239
 
10240
- const version = "1.6.3-0.canary.11232";
10240
+ const version = "1.6.3-0.canary.11234";
10241
10241
 
10242
10242
  // ensure the worker ends up in the bundle
10243
10243
  // If the worker should not be included this gets aliased to empty.js
@@ -23458,7 +23458,7 @@ class HlsAssetPlayer {
23458
23458
  this.assetItem = assetItem;
23459
23459
  let uri = assetItem.uri;
23460
23460
  try {
23461
- uri = getInterstitialUrl(uri, hls.sessionId).href;
23461
+ uri = getInterstitialUrl(uri, userConfig.primarySessionId).href;
23462
23462
  } catch (error) {
23463
23463
  // Ignore error parsing ASSET_URI or adding _HLS_primary_id to it. The
23464
23464
  // issue should surface as an INTERSTITIAL_ASSET_ERROR loading the asset.
@@ -24411,7 +24411,7 @@ class InterstitialsController extends Logger {
24411
24411
  const interstitialsUpdated = !!(interstitialEvents.length || removedIds.length);
24412
24412
  if (interstitialsUpdated) {
24413
24413
  this.log(`INTERSTITIALS_UPDATED (${interstitialEvents.length}): ${interstitialEvents}
24414
- Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
24414
+ Schedule: ${scheduleItems.map(seg => segmentToString(seg))} pos: ${this.timelinePos}`);
24415
24415
  }
24416
24416
  if (removedIds.length) {
24417
24417
  this.log(`Removed events ${removedIds}`);
@@ -24434,11 +24434,13 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
24434
24434
 
24435
24435
  // Update schedule item references
24436
24436
  // Do not replace Interstitial playingItem without a match - used for INTERSTITIAL_ASSET_ENDED and INTERSTITIAL_ENDED
24437
+ let trimInPlaceForPlayout = null;
24437
24438
  if (playingItem) {
24438
24439
  const updatedPlayingItem = this.updateItem(playingItem, this.timelinePos);
24439
24440
  if (this.itemsMatch(playingItem, updatedPlayingItem)) {
24440
24441
  this.playingItem = updatedPlayingItem;
24441
24442
  this.waitingItem = this.endedItem = null;
24443
+ trimInPlaceForPlayout = () => this.trimInPlace(updatedPlayingItem, playingItem);
24442
24444
  }
24443
24445
  } else {
24444
24446
  // Clear waitingItem if it has been removed from the schedule
@@ -24451,6 +24453,7 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
24451
24453
  const updatedBufferingItem = this.updateItem(bufferingItem, this.bufferedPos);
24452
24454
  if (this.itemsMatch(bufferingItem, updatedBufferingItem)) {
24453
24455
  this.bufferingItem = updatedBufferingItem;
24456
+ trimInPlaceForPlayout || (trimInPlaceForPlayout = () => this.trimInPlace(updatedBufferingItem, bufferingItem));
24454
24457
  } else if (bufferingItem.event) {
24455
24458
  // Interstitial removed from schedule (Live -> VOD or other scenario where Start Date is outside the range of VOD Playlist)
24456
24459
  this.bufferingItem = this.playingItem;
@@ -24474,6 +24477,9 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
24474
24477
  this.primaryFallback(playingItem.event);
24475
24478
  return;
24476
24479
  }
24480
+ if (trimInPlaceForPlayout) {
24481
+ trimInPlaceForPlayout();
24482
+ }
24477
24483
 
24478
24484
  // Check is buffered to new Interstitial event boundary
24479
24485
  // (Live update publishes Interstitial with new segment)
@@ -25486,6 +25492,21 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
25486
25492
  }
25487
25493
  return null;
25488
25494
  }
25495
+ trimInPlace(updatedItem, itemBeforeUpdate) {
25496
+ if (this.isInterstitial(updatedItem) && updatedItem.event.appendInPlace && itemBeforeUpdate.end - updatedItem.end > 0.25) {
25497
+ updatedItem.event.assetList.forEach((asset, index) => {
25498
+ if (updatedItem.event.isAssetPastPlayoutLimit(index)) {
25499
+ this.clearAssetPlayer(asset.identifier, null);
25500
+ }
25501
+ });
25502
+ const flushStart = updatedItem.end + 0.25;
25503
+ const bufferInfo = BufferHelper.bufferInfo(this.primaryMedia, flushStart, 0);
25504
+ if (bufferInfo.end > flushStart || (bufferInfo.nextStart || 0) > flushStart) {
25505
+ this.attachPrimary(flushStart, null);
25506
+ this.flushFrontBuffer(flushStart);
25507
+ }
25508
+ }
25509
+ }
25489
25510
  itemsMatch(a, b) {
25490
25511
  return !!b && (a === b || a.event && b.event && this.eventItemsMatch(a, b) || !a.event && !b.event && this.findItemIndex(a) === this.findItemIndex(b));
25491
25512
  }
@@ -26094,10 +26115,6 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
26094
26115
  this.updateSchedule();
26095
26116
  if (playingItem) {
26096
26117
  this.log(`Fallback to primary from event "${interstitial.identifier}" start: ${flushStart} pos: ${this.timelinePos} playing: ${playingItem ? segmentToString(playingItem) : '<none>'} error: ${interstitial.error}`);
26097
- if (interstitial.appendInPlace) {
26098
- this.attachPrimary(flushStart, null);
26099
- this.flushFrontBuffer(flushStart);
26100
- }
26101
26118
  let timelinePos = this.timelinePos;
26102
26119
  if (timelinePos === -1) {
26103
26120
  timelinePos = this.hls.startPosition;
@@ -26109,6 +26126,10 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
26109
26126
  } else {
26110
26127
  this.clearInterstitial(interstitial, null);
26111
26128
  }
26129
+ if (interstitial.appendInPlace) {
26130
+ this.attachPrimary(flushStart, null);
26131
+ this.flushFrontBuffer(flushStart);
26132
+ }
26112
26133
  } else {
26113
26134
  this.checkStart();
26114
26135
  }