hls.js 1.6.0-beta.1.0.canary.10812 → 1.6.0-beta.1.0.canary.10813

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.
@@ -1151,9 +1151,6 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`,
1151
1151
  this.waitingItem = null;
1152
1152
 
1153
1153
  this.bufferedToItem(scheduledItem);
1154
- if (!fromItem) {
1155
- return;
1156
- }
1157
1154
 
1158
1155
  this.log(`resuming ${segmentToString(scheduledItem)}`);
1159
1156
 
@@ -1169,6 +1166,10 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`,
1169
1166
  this.attachPrimary(timelinePos, scheduledItem);
1170
1167
  }
1171
1168
 
1169
+ if (!fromItem) {
1170
+ return;
1171
+ }
1172
+
1172
1173
  const scheduleItems = this.schedule.items;
1173
1174
  if (!scheduleItems) {
1174
1175
  return;
@@ -1434,14 +1435,6 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))}`,
1434
1435
  if (removedIds.length) {
1435
1436
  this.log(`Removed events ${removedIds}`);
1436
1437
  }
1437
- if (
1438
- this.isInterstitial(playingItem) &&
1439
- removedIds.includes(playingItem.event.identifier)
1440
- ) {
1441
- this.warn(
1442
- `Interstitial "${playingItem.event.identifier}" removed while playing`,
1443
- );
1444
- }
1445
1438
 
1446
1439
  this.playerQueue.forEach((player) => {
1447
1440
  if (player.interstitial.appendInPlace) {
@@ -1474,7 +1467,7 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))}`,
1474
1467
  } else if (!this.updateItem(bufferingItem)) {
1475
1468
  // Interstitial removed from schedule (Live -> VOD or other scenario where Start Date is outside the range of VOD Playlist)
1476
1469
  this.bufferingItem = null;
1477
- this.clearInterstitial(bufferingItem.event);
1470
+ this.clearInterstitial(bufferingItem.event, null);
1478
1471
  }
1479
1472
  }
1480
1473
  // Clear waitingItem if it has been removed from the schedule
@@ -1482,7 +1475,7 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))}`,
1482
1475
 
1483
1476
  removedInterstitials.forEach((interstitial) => {
1484
1477
  interstitial.assetList.forEach((asset) => {
1485
- this.clearAssetPlayer(asset.identifier);
1478
+ this.clearAssetPlayer(asset.identifier, null);
1486
1479
  });
1487
1480
  });
1488
1481
 
@@ -1494,6 +1487,17 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))}`,
1494
1487
  removedIds,
1495
1488
  });
1496
1489
 
1490
+ if (
1491
+ this.isInterstitial(playingItem) &&
1492
+ removedIds.includes(playingItem.event.identifier)
1493
+ ) {
1494
+ this.warn(
1495
+ `Interstitial "${playingItem.event.identifier}" removed while playing`,
1496
+ );
1497
+ this.primaryFallback(playingItem.event);
1498
+ return;
1499
+ }
1500
+
1497
1501
  // Check is buffered to new Interstitial event boundary
1498
1502
  // (Live update publishes Interstitial with new segment)
1499
1503
  this.checkBuffer();
@@ -2065,7 +2069,7 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))}`,
2065
2069
 
2066
2070
  private clearInterstitial(
2067
2071
  interstitial: InterstitialEvent,
2068
- toSegment?: InterstitialScheduleItem | null,
2072
+ toSegment: InterstitialScheduleItem | null,
2069
2073
  ) {
2070
2074
  interstitial.assetList.forEach((asset) => {
2071
2075
  this.clearAssetPlayer(asset.identifier, toSegment);
@@ -2075,7 +2079,7 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))}`,
2075
2079
 
2076
2080
  private clearAssetPlayer(
2077
2081
  assetId: InterstitialAssetId,
2078
- toSegment?: InterstitialScheduleItem | null,
2082
+ toSegment: InterstitialScheduleItem | null,
2079
2083
  ) {
2080
2084
  if (toSegment === null) {
2081
2085
  return;
@@ -2228,7 +2232,7 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))}`,
2228
2232
  const error = new Error(errorMessage);
2229
2233
  if (assetItem) {
2230
2234
  if (this.playingAsset !== assetItem) {
2231
- this.clearAssetPlayer(assetItem.identifier);
2235
+ this.clearAssetPlayer(assetItem.identifier, null);
2232
2236
  }
2233
2237
  assetItem.error = error;
2234
2238
  }
@@ -2251,6 +2255,13 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))}`,
2251
2255
  // Update schedule now that interstitial/assets are flagged with `error` for fallback
2252
2256
  this.updateSchedule();
2253
2257
  if (playingItem) {
2258
+ this.log(
2259
+ `Fallback to primary from event "${interstitial.identifier}" start: ${
2260
+ flushStart
2261
+ } pos: ${this.timelinePos} playing: ${
2262
+ playingItem ? segmentToString(playingItem) : '<none>'
2263
+ } error: ${interstitial.error}`,
2264
+ );
2254
2265
  if (interstitial.appendInPlace) {
2255
2266
  interstitial.appendInPlace = false;
2256
2267
  this.attachPrimary(flushStart, null);
@@ -11,6 +11,7 @@ import { ErrorDetails, ErrorTypes } from '../errors';
11
11
  import { Events } from '../events';
12
12
  import { PlaylistContextType, PlaylistLevelType } from '../types/loader';
13
13
  import { AttrList } from '../utils/attr-list';
14
+ import { computeReloadInterval } from '../utils/level-helper';
14
15
  import type { LevelDetails } from './level-details';
15
16
  import type { LoaderConfig, RetryConfig } from '../config';
16
17
  import type Hls from '../hls';
@@ -19,7 +20,6 @@ import type {
19
20
  ErrorData,
20
21
  LevelLoadingData,
21
22
  LevelsUpdatedData,
22
- ManifestLoadedData,
23
23
  ManifestLoadingData,
24
24
  TrackLoadingData,
25
25
  } from '../types/events';
@@ -70,6 +70,7 @@ class PlaylistLoader implements NetworkComponentAPI {
70
70
  [key: string]: Loader<LoaderContext>;
71
71
  } = Object.create(null);
72
72
  private variableList: VariableMap | null = null;
73
+ public onManifestLoaded = this.checkAutostartLoad;
73
74
 
74
75
  constructor(hls: Hls) {
75
76
  this.hls = hls;
@@ -498,12 +499,6 @@ class PlaylistLoader implements NetworkComponentAPI {
498
499
  });
499
500
  }
500
501
 
501
- onManifestLoaded(event: Events.MANIFEST_LOADED, data: ManifestLoadedData) {
502
- if (!data.isMediaPlaylist) {
503
- this.checkAutostartLoad();
504
- }
505
- }
506
-
507
502
  private handleTrackOrLevelPlaylist(
508
503
  response: LoaderResponse,
509
504
  stats: LoaderStats,
@@ -542,6 +537,8 @@ class PlaylistLoader implements NetworkComponentAPI {
542
537
  name: '',
543
538
  url,
544
539
  };
540
+ levelDetails.requestScheduled =
541
+ stats.loading.start + computeReloadInterval(levelDetails, 0);
545
542
 
546
543
  hls.trigger(Events.MANIFEST_LOADED, {
547
544
  levels: [singleLevel],
@@ -554,7 +551,6 @@ class PlaylistLoader implements NetworkComponentAPI {
554
551
  contentSteering: null,
555
552
  startTimeOffset: null,
556
553
  variableList: null,
557
- isMediaPlaylist: true,
558
554
  });
559
555
  }
560
556
 
@@ -572,14 +568,6 @@ class PlaylistLoader implements NetworkComponentAPI {
572
568
  networkDetails,
573
569
  loader,
574
570
  );
575
-
576
- if (
577
- type === PlaylistContextType.MANIFEST &&
578
- (!levelDetails.playlistParsingError ||
579
- (!levelDetails.fragments.length && levelDetails.live))
580
- ) {
581
- this.checkAutostartLoad();
582
- }
583
571
  }
584
572
 
585
573
  private handleManifestParsingError(
@@ -138,7 +138,6 @@ export interface ManifestLoadedData {
138
138
  subtitles?: MediaPlaylist[];
139
139
  url: string;
140
140
  variableList: VariableMap | null;
141
- isMediaPlaylist?: boolean;
142
141
  }
143
142
 
144
143
  export interface ManifestParsedData {