hls.js 1.6.0-beta.2.0.canary.10925 → 1.6.0-beta.2.0.canary.10926

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.
@@ -402,7 +402,7 @@ function enableLogs(debugConfig, context, id) {
402
402
  // Some browsers don't allow to use bind on console object anyway
403
403
  // fallback to default if needed
404
404
  try {
405
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.2.0.canary.10925"}`);
405
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.2.0.canary.10926"}`);
406
406
  } catch (e) {
407
407
  /* log fn threw an exception. All logger methods are no-ops. */
408
408
  return createLogger();
@@ -1062,8 +1062,8 @@ function getCodecTiers(levels, audioTracksByGroup, minAutoLevel, maxAutoLevel) {
1062
1062
  }, {});
1063
1063
  }
1064
1064
  function useAlternateAudio(audioTrackUrl, hls) {
1065
- var _hls$levels$hls$loadL;
1066
- return !!audioTrackUrl && audioTrackUrl !== ((_hls$levels$hls$loadL = hls.levels[hls.loadLevel]) == null ? undefined : _hls$levels$hls$loadL.uri);
1065
+ var _hls$loadLevelObj;
1066
+ return !!audioTrackUrl && audioTrackUrl !== ((_hls$loadLevelObj = hls.loadLevelObj) == null ? undefined : _hls$loadLevelObj.uri);
1067
1067
  }
1068
1068
 
1069
1069
  class AbrController extends Logger {
@@ -1557,8 +1557,8 @@ class AbrController extends Logger {
1557
1557
  }
1558
1558
  // If no matching level found, see if min auto level would be a better option
1559
1559
  const minLevel = hls.levels[minAutoLevel];
1560
- const autoLevel = hls.levels[hls.loadLevel];
1561
- if ((minLevel == null ? undefined : minLevel.bitrate) < (autoLevel == null ? undefined : autoLevel.bitrate)) {
1560
+ const autoLevel = hls.loadLevelObj;
1561
+ if (autoLevel && (minLevel == null ? undefined : minLevel.bitrate) < autoLevel.bitrate) {
1562
1562
  return minAutoLevel;
1563
1563
  }
1564
1564
  // or if bitrate is not lower, continue to use loadLevel
@@ -2042,7 +2042,7 @@ class ErrorController extends Logger {
2042
2042
  case ErrorDetails.SUBTITLE_LOAD_ERROR:
2043
2043
  case ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:
2044
2044
  if (context) {
2045
- const level = hls.levels[hls.loadLevel];
2045
+ const level = hls.loadLevelObj;
2046
2046
  if (level && (context.type === PlaylistContextType.AUDIO_TRACK && level.hasAudioGroup(context.groupId) || context.type === PlaylistContextType.SUBTITLE_TRACK && level.hasSubtitleGroup(context.groupId))) {
2047
2047
  // Perform Pathway switch or Redundant failover if possible for fastest recovery
2048
2048
  // otherwise allow playlist retry count to reach max error retries
@@ -2055,7 +2055,7 @@ class ErrorController extends Logger {
2055
2055
  return;
2056
2056
  case ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:
2057
2057
  {
2058
- const level = hls.levels[hls.loadLevel];
2058
+ const level = hls.loadLevelObj;
2059
2059
  const restrictedHdcpLevel = level == null ? undefined : level.attrs['HDCP-LEVEL'];
2060
2060
  if (restrictedHdcpLevel) {
2061
2061
  data.errorAction = {
@@ -8362,7 +8362,8 @@ class BaseStreamController extends TaskLoop {
8362
8362
  if (bufferInfo.len === 0 && bufferInfo.nextStart !== undefined) {
8363
8363
  const bufferedFragAtPos = this.fragmentTracker.getBufferedFrag(pos, type);
8364
8364
  if (bufferedFragAtPos && (bufferInfo.nextStart <= bufferedFragAtPos.end || bufferedFragAtPos.gap)) {
8365
- return BufferHelper.bufferInfo(bufferable, pos, Math.max(bufferInfo.nextStart, maxBufferHole));
8365
+ const gapDuration = Math.max(Math.min(bufferInfo.nextStart, bufferedFragAtPos.end) - pos, maxBufferHole);
8366
+ return BufferHelper.bufferInfo(bufferable, pos, gapDuration);
8366
8367
  }
8367
8368
  }
8368
8369
  return bufferInfo;
@@ -17961,7 +17962,7 @@ class GapController extends TaskLoop {
17961
17962
  const currentTime = media.currentTime;
17962
17963
  const bufferInfo = BufferHelper.bufferInfo(media, currentTime, 0);
17963
17964
  const startTime = currentTime < bufferInfo.start ? bufferInfo.start : bufferInfo.nextStart;
17964
- if (startTime) {
17965
+ if (startTime && this.hls) {
17965
17966
  const bufferStarved = bufferInfo.len <= config.maxBufferHole;
17966
17967
  const waiting = bufferInfo.len > 0 && bufferInfo.len < 1 && media.readyState < 3;
17967
17968
  const gapLength = startTime - currentTime;
@@ -17978,6 +17979,17 @@ class GapController extends TaskLoop {
17978
17979
  if (!startGap) {
17979
17980
  const startProvisioned = partial || fragmentTracker.getAppendedFrag(currentTime, PlaylistLevelType.MAIN);
17980
17981
  if (startProvisioned) {
17982
+ var _this$hls$loadLevelOb;
17983
+ // Do not seek when selected variant playlist is unloaded
17984
+ if (!((_this$hls$loadLevelOb = this.hls.loadLevelObj) != null && _this$hls$loadLevelOb.details)) {
17985
+ return 0;
17986
+ }
17987
+ // Do not seek when required fragments are inflight or appending
17988
+ const inFlightDependency = getInFlightDependency(this.hls.inFlightFragments, startTime);
17989
+ if (inFlightDependency) {
17990
+ return 0;
17991
+ }
17992
+ // Do not seek if we can't walk tracked fragments to end of gap
17981
17993
  let moreToLoad = false;
17982
17994
  let pos = startProvisioned.end;
17983
17995
  while (pos < startTime) {
@@ -17999,7 +18011,7 @@ class GapController extends TaskLoop {
17999
18011
  this.warn(`skipping hole, adjusting currentTime from ${currentTime} to ${targetTime}`);
18000
18012
  this.moved = true;
18001
18013
  media.currentTime = targetTime;
18002
- if (!(partial != null && partial.gap) && this.hls) {
18014
+ if (!(partial != null && partial.gap)) {
18003
18015
  const error = new Error(`fragment loaded with buffer holes, seeking from ${currentTime} to ${targetTime}`);
18004
18016
  this.hls.trigger(Events.ERROR, {
18005
18017
  type: ErrorTypes.MEDIA_ERROR,
@@ -19043,6 +19055,9 @@ class LevelController extends BasePlaylistController {
19043
19055
  }
19044
19056
  return this._levels;
19045
19057
  }
19058
+ get loadLevelObj() {
19059
+ return this.currentLevel;
19060
+ }
19046
19061
  get level() {
19047
19062
  return this.currentLevelIndex;
19048
19063
  }
@@ -19331,7 +19346,7 @@ function assignTrackIdsByGroup(tracks) {
19331
19346
  });
19332
19347
  }
19333
19348
 
19334
- const version = "1.6.0-beta.2.0.canary.10925";
19349
+ const version = "1.6.0-beta.2.0.canary.10926";
19335
19350
 
19336
19351
  // ensure the worker ends up in the bundle
19337
19352
  // If the worker should not be included this gets aliased to empty.js
@@ -19910,7 +19925,7 @@ class StreamController extends BaseStreamController {
19910
19925
  onTickEnd() {
19911
19926
  var _this$media2;
19912
19927
  super.onTickEnd();
19913
- if ((_this$media2 = this.media) != null && _this$media2.readyState) {
19928
+ if ((_this$media2 = this.media) != null && _this$media2.readyState && this.media.seeking === false) {
19914
19929
  this.lastCurrentTime = this.media.currentTime;
19915
19930
  }
19916
19931
  this.checkFragmentChanged();
@@ -22388,10 +22403,21 @@ class Hls {
22388
22403
  const levels = this.levelController.levels;
22389
22404
  return levels ? levels : [];
22390
22405
  }
22406
+
22407
+ /**
22408
+ * @returns LevelDetails of last loaded level (variant) or `null` prior to loading a media playlist.
22409
+ */
22391
22410
  get latestLevelDetails() {
22392
22411
  return this.streamController.getLevelDetails() || null;
22393
22412
  }
22394
22413
 
22414
+ /**
22415
+ * @returns Level object of selected level (variant) or `null` prior to selecting a level or once the level is removed.
22416
+ */
22417
+ get loadLevelObj() {
22418
+ return this.levelController.loadLevelObj;
22419
+ }
22420
+
22395
22421
  /**
22396
22422
  * Index of quality level (variant) currently played
22397
22423
  */