hls.js 1.6.0-beta.1.0.canary.10764 → 1.6.0-beta.1.0.canary.10765

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
@@ -400,7 +400,7 @@ function enableLogs(debugConfig, context, id) {
400
400
  // Some browsers don't allow to use bind on console object anyway
401
401
  // fallback to default if needed
402
402
  try {
403
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.1.0.canary.10764"}`);
403
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.1.0.canary.10765"}`);
404
404
  } catch (e) {
405
405
  /* log fn threw an exception. All logger methods are no-ops. */
406
406
  return createLogger();
@@ -1884,8 +1884,10 @@ class AbrController extends Logger {
1884
1884
  continue;
1885
1885
  }
1886
1886
  if (config.useMediaCapabilities && !levelInfo.supportedResult && !levelInfo.supportedPromise) {
1887
+ var _levelInfo$videoCodec;
1887
1888
  const mediaCapabilities = navigator.mediaCapabilities;
1888
- if (typeof (mediaCapabilities == null ? void 0 : mediaCapabilities.decodingInfo) === 'function' && requiresMediaCapabilitiesDecodingInfo(levelInfo, audioTracksByGroup, currentVideoRange, currentFrameRate, currentBw, audioPreference)) {
1889
+ if (typeof (mediaCapabilities == null ? void 0 : mediaCapabilities.decodingInfo) === 'function' && (requiresMediaCapabilitiesDecodingInfo(levelInfo, audioTracksByGroup, currentVideoRange, currentFrameRate, currentBw, audioPreference) || ((_levelInfo$videoCodec = levelInfo.videoCodec) == null ? void 0 : _levelInfo$videoCodec.substring(0, 4)) === 'hvc1') // Force media capabilities check for HEVC to avoid failure on Windows
1890
+ ) {
1889
1891
  levelInfo.supportedPromise = getMediaDecodingInfoPromise(levelInfo, audioTracksByGroup, mediaCapabilities);
1890
1892
  levelInfo.supportedPromise.then(decodingInfo => {
1891
1893
  if (!this.hls) {
@@ -1901,6 +1903,9 @@ class AbrController extends Logger {
1901
1903
  if (index > -1 && levels.length > 1) {
1902
1904
  this.log(`Removing unsupported level ${index}`);
1903
1905
  this.hls.removeLevel(index);
1906
+ if (this.hls.loadLevel === -1) {
1907
+ this.hls.nextLoadLevel = 0;
1908
+ }
1904
1909
  }
1905
1910
  }
1906
1911
  });
@@ -9769,7 +9774,7 @@ var eventemitter3 = {exports: {}};
9769
9774
  var eventemitter3Exports = eventemitter3.exports;
9770
9775
  var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
9771
9776
 
9772
- const version = "1.6.0-beta.1.0.canary.10764";
9777
+ const version = "1.6.0-beta.1.0.canary.10765";
9773
9778
 
9774
9779
  // ensure the worker ends up in the bundle
9775
9780
  // If the worker should not be included this gets aliased to empty.js
@@ -17379,7 +17384,8 @@ class AudioTrackController extends BasePlaylistController {
17379
17384
  url,
17380
17385
  id,
17381
17386
  groupId,
17382
- deliveryDirectives: hlsUrlParameters || null
17387
+ deliveryDirectives: hlsUrlParameters || null,
17388
+ track: audioTrack
17383
17389
  });
17384
17390
  }
17385
17391
  }
@@ -22420,7 +22426,8 @@ class SubtitleTrackController extends BasePlaylistController {
22420
22426
  url,
22421
22427
  id,
22422
22428
  groupId,
22423
- deliveryDirectives: hlsUrlParameters || null
22429
+ deliveryDirectives: hlsUrlParameters || null,
22430
+ track: currentTrack
22424
22431
  });
22425
22432
  }
22426
22433
  }
@@ -30495,7 +30502,7 @@ class LevelController extends BasePlaylistController {
30495
30502
  level,
30496
30503
  details
30497
30504
  } = data;
30498
- const curLevel = this._levels[level];
30505
+ const curLevel = data.levelInfo;
30499
30506
  if (!curLevel) {
30500
30507
  var _data$deliveryDirecti;
30501
30508
  this.warn(`Invalid level index ${level}`);
@@ -30506,7 +30513,7 @@ class LevelController extends BasePlaylistController {
30506
30513
  }
30507
30514
 
30508
30515
  // only process level loaded events matching with expected level
30509
- if (level === this.currentLevelIndex) {
30516
+ if (curLevel === this.currentLevel) {
30510
30517
  // reset level load error counter on successful level loaded only if there is no issues with fragments
30511
30518
  if (curLevel.fragmentError === 0) {
30512
30519
  curLevel.loadError = 0;
@@ -30544,6 +30551,7 @@ class LevelController extends BasePlaylistController {
30544
30551
  this.hls.trigger(Events.LEVEL_LOADING, {
30545
30552
  url,
30546
30553
  level: currentLevelIndex,
30554
+ levelInfo: currentLevel,
30547
30555
  pathwayId: currentLevel.attrs['PATHWAY-ID'],
30548
30556
  id: 0,
30549
30557
  // Deprecated Level urlId
@@ -31477,7 +31485,7 @@ class StreamController extends BaseStreamController {
31477
31485
  if (!levels || this.state !== State.IDLE) {
31478
31486
  return;
31479
31487
  }
31480
- const level = levels[data.level];
31488
+ const level = data.levelInfo;
31481
31489
  if (!level.details || level.details.live && this.levelLastLoaded !== level || this.waitForCdnTuneIn(level.details)) {
31482
31490
  this.state = State.WAITING_LEVEL;
31483
31491
  }
@@ -31496,7 +31504,7 @@ class StreamController extends BaseStreamController {
31496
31504
  return;
31497
31505
  }
31498
31506
  this.log(`Level ${newLevelId} loaded [${newDetails.startSN},${newDetails.endSN}]${newDetails.lastPartSn ? `[part-${newDetails.lastPartSn}-${newDetails.lastPartIndex}]` : ''}, cc [${newDetails.startCC}, ${newDetails.endCC}] duration:${duration}`);
31499
- const curLevel = levels[newLevelId];
31507
+ const curLevel = data.levelInfo;
31500
31508
  const fragCurrent = this.fragCurrent;
31501
31509
  if (fragCurrent && (this.state === State.FRAG_LOADING || this.state === State.FRAG_LOADING_WAITING_RETRY)) {
31502
31510
  if (fragCurrent.level !== data.level && fragCurrent.loader) {
@@ -32569,6 +32577,7 @@ class PlaylistLoader {
32569
32577
  hls.on(Events.LEVEL_LOADING, this.onLevelLoading, this);
32570
32578
  hls.on(Events.AUDIO_TRACK_LOADING, this.onAudioTrackLoading, this);
32571
32579
  hls.on(Events.SUBTITLE_TRACK_LOADING, this.onSubtitleTrackLoading, this);
32580
+ hls.on(Events.LEVELS_UPDATED, this.onLevelsUpdated, this);
32572
32581
  }
32573
32582
  unregisterListeners() {
32574
32583
  const {
@@ -32578,6 +32587,7 @@ class PlaylistLoader {
32578
32587
  hls.off(Events.LEVEL_LOADING, this.onLevelLoading, this);
32579
32588
  hls.off(Events.AUDIO_TRACK_LOADING, this.onAudioTrackLoading, this);
32580
32589
  hls.off(Events.SUBTITLE_TRACK_LOADING, this.onSubtitleTrackLoading, this);
32590
+ hls.off(Events.LEVELS_UPDATED, this.onLevelsUpdated, this);
32581
32591
  }
32582
32592
 
32583
32593
  /**
@@ -32629,7 +32639,8 @@ class PlaylistLoader {
32629
32639
  responseType: 'text',
32630
32640
  type: PlaylistContextType.MANIFEST,
32631
32641
  url,
32632
- deliveryDirectives: null
32642
+ deliveryDirectives: null,
32643
+ levelOrTrack: null
32633
32644
  });
32634
32645
  }
32635
32646
  onLevelLoading(event, data) {
@@ -32638,7 +32649,8 @@ class PlaylistLoader {
32638
32649
  level,
32639
32650
  pathwayId,
32640
32651
  url,
32641
- deliveryDirectives
32652
+ deliveryDirectives,
32653
+ levelInfo
32642
32654
  } = data;
32643
32655
  this.load({
32644
32656
  id,
@@ -32647,7 +32659,8 @@ class PlaylistLoader {
32647
32659
  responseType: 'text',
32648
32660
  type: PlaylistContextType.LEVEL,
32649
32661
  url,
32650
- deliveryDirectives
32662
+ deliveryDirectives,
32663
+ levelOrTrack: levelInfo
32651
32664
  });
32652
32665
  }
32653
32666
  onAudioTrackLoading(event, data) {
@@ -32655,7 +32668,8 @@ class PlaylistLoader {
32655
32668
  id,
32656
32669
  groupId,
32657
32670
  url,
32658
- deliveryDirectives
32671
+ deliveryDirectives,
32672
+ track
32659
32673
  } = data;
32660
32674
  this.load({
32661
32675
  id,
@@ -32664,7 +32678,8 @@ class PlaylistLoader {
32664
32678
  responseType: 'text',
32665
32679
  type: PlaylistContextType.AUDIO_TRACK,
32666
32680
  url,
32667
- deliveryDirectives
32681
+ deliveryDirectives,
32682
+ levelOrTrack: track
32668
32683
  });
32669
32684
  }
32670
32685
  onSubtitleTrackLoading(event, data) {
@@ -32672,7 +32687,8 @@ class PlaylistLoader {
32672
32687
  id,
32673
32688
  groupId,
32674
32689
  url,
32675
- deliveryDirectives
32690
+ deliveryDirectives,
32691
+ track
32676
32692
  } = data;
32677
32693
  this.load({
32678
32694
  id,
@@ -32681,9 +32697,21 @@ class PlaylistLoader {
32681
32697
  responseType: 'text',
32682
32698
  type: PlaylistContextType.SUBTITLE_TRACK,
32683
32699
  url,
32684
- deliveryDirectives
32700
+ deliveryDirectives,
32701
+ levelOrTrack: track
32685
32702
  });
32686
32703
  }
32704
+ onLevelsUpdated(event, data) {
32705
+ // abort and delete loader of removed levels
32706
+ const loader = this.loaders[PlaylistContextType.LEVEL];
32707
+ if (loader) {
32708
+ const context = loader.context;
32709
+ if (context && !data.levels.some(lvl => lvl === context.levelOrTrack)) {
32710
+ loader.abort();
32711
+ delete this.loaders[PlaylistContextType.LEVEL];
32712
+ }
32713
+ }
32714
+ }
32687
32715
  load(context) {
32688
32716
  var _context$deliveryDire;
32689
32717
  const config = this.hls.config;
@@ -32694,7 +32722,7 @@ class PlaylistLoader {
32694
32722
  let loader = this.getInternalLoader(context);
32695
32723
  if (loader) {
32696
32724
  const loaderContext = loader.context;
32697
- if (loaderContext && loaderContext.url === context.url && loaderContext.level === context.level) {
32725
+ if (loaderContext && loaderContext.url === context.url && loaderContext.levelOrTrack === context.levelOrTrack) {
32698
32726
  // same URL can't overlap
32699
32727
  this.hls.logger.trace('[playlist-loader]: playlist request ongoing');
32700
32728
  return;
@@ -33016,6 +33044,7 @@ class PlaylistLoader {
33016
33044
  case PlaylistContextType.LEVEL:
33017
33045
  hls.trigger(Events.LEVEL_LOADED, {
33018
33046
  details: levelDetails,
33047
+ levelInfo: context.levelOrTrack || hls.levels[0],
33019
33048
  level: levelIndex || 0,
33020
33049
  id: id || 0,
33021
33050
  stats,
@@ -33026,6 +33055,7 @@ class PlaylistLoader {
33026
33055
  case PlaylistContextType.AUDIO_TRACK:
33027
33056
  hls.trigger(Events.AUDIO_TRACK_LOADED, {
33028
33057
  details: levelDetails,
33058
+ track: context.levelOrTrack,
33029
33059
  id: id || 0,
33030
33060
  groupId: groupId || '',
33031
33061
  stats,
@@ -33036,6 +33066,7 @@ class PlaylistLoader {
33036
33066
  case PlaylistContextType.SUBTITLE_TRACK:
33037
33067
  hls.trigger(Events.SUBTITLE_TRACK_LOADED, {
33038
33068
  details: levelDetails,
33069
+ track: context.levelOrTrack,
33039
33070
  id: id || 0,
33040
33071
  groupId: groupId || '',
33041
33072
  stats,