hls.js 1.6.0-beta.1.0.canary.10811 → 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);
package/src/hls.ts CHANGED
@@ -300,6 +300,12 @@ export default class Hls implements HlsEventEmitter {
300
300
  if (typeof onErrorOut === 'function') {
301
301
  this.on(Events.ERROR, onErrorOut, errorController);
302
302
  }
303
+ // Autostart load handler
304
+ this.on(
305
+ Events.MANIFEST_LOADED,
306
+ playListLoader.onManifestLoaded,
307
+ playListLoader,
308
+ );
303
309
  }
304
310
 
305
311
  createController(ControllerClass, components) {
@@ -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';
@@ -69,6 +70,7 @@ class PlaylistLoader implements NetworkComponentAPI {
69
70
  [key: string]: Loader<LoaderContext>;
70
71
  } = Object.create(null);
71
72
  private variableList: VariableMap | null = null;
73
+ public onManifestLoaded = this.checkAutostartLoad;
72
74
 
73
75
  constructor(hls: Hls) {
74
76
  this.hls = hls;
@@ -495,8 +497,6 @@ class PlaylistLoader implements NetworkComponentAPI {
495
497
  startTimeOffset,
496
498
  variableList,
497
499
  });
498
-
499
- this.checkAutostartLoad();
500
500
  }
501
501
 
502
502
  private handleTrackOrLevelPlaylist(
@@ -537,6 +537,8 @@ class PlaylistLoader implements NetworkComponentAPI {
537
537
  name: '',
538
538
  url,
539
539
  };
540
+ levelDetails.requestScheduled =
541
+ stats.loading.start + computeReloadInterval(levelDetails, 0);
540
542
 
541
543
  hls.trigger(Events.MANIFEST_LOADED, {
542
544
  levels: [singleLevel],
@@ -566,14 +568,6 @@ class PlaylistLoader implements NetworkComponentAPI {
566
568
  networkDetails,
567
569
  loader,
568
570
  );
569
-
570
- if (
571
- type === PlaylistContextType.MANIFEST &&
572
- (!levelDetails.playlistParsingError ||
573
- (!levelDetails.fragments.length && levelDetails.live))
574
- ) {
575
- this.checkAutostartLoad();
576
- }
577
571
  }
578
572
 
579
573
  private handleManifestParsingError(
@@ -7,8 +7,6 @@ import type {
7
7
  SourceBufferName,
8
8
  SourceBufferTrackSet,
9
9
  } from './buffer';
10
- import type { ChunkMetadata } from './transmuxer';
11
- import type { ErrorDetails, ErrorTypes } from '../errors';
12
10
  import type { MetadataSample, UserdataSample } from './demuxer';
13
11
  import type {
14
12
  HdcpLevel,
@@ -27,6 +25,7 @@ import type {
27
25
  PlaylistLoaderContext,
28
26
  } from './loader';
29
27
  import type { MediaPlaylist, MediaPlaylistType } from './media-playlist';
28
+ import type { ChunkMetadata } from './transmuxer';
30
29
  import type { SteeringManifest } from '../controller/content-steering-controller';
31
30
  import type { IErrorAction } from '../controller/error-controller';
32
31
  import type { HlsAssetPlayer } from '../controller/interstitial-player';
@@ -34,6 +33,7 @@ import type {
34
33
  InterstitialScheduleDurations,
35
34
  InterstitialScheduleItem,
36
35
  } from '../controller/interstitials-schedule';
36
+ import type { ErrorDetails, ErrorTypes } from '../errors';
37
37
  import type { HlsListeners } from '../events';
38
38
  import type { Fragment, MediaFragment, Part } from '../loader/fragment';
39
39
  import type {