hls.js 1.6.3-0.canary.11252 → 1.6.3-0.canary.11254

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.
@@ -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.11252"}`);
526
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.3-0.canary.11254"}`);
527
527
  } catch (e) {
528
528
  /* log fn threw an exception. All logger methods are no-ops. */
529
529
  return createLogger();
@@ -3707,7 +3707,6 @@ function findFragmentByPDT(fragments, PDTValue, maxFragLookUpTolerance) {
3707
3707
  if (PDTValue >= (endPDT || 0)) {
3708
3708
  return null;
3709
3709
  }
3710
- maxFragLookUpTolerance = maxFragLookUpTolerance || 0;
3711
3710
  for (let seg = 0; seg < fragments.length; ++seg) {
3712
3711
  const frag = fragments[seg];
3713
3712
  if (pdtWithinToleranceTest(PDTValue, maxFragLookUpTolerance, frag)) {
@@ -3818,16 +3817,37 @@ function pdtWithinToleranceTest(pdtBufferEnd, maxFragLookUpTolerance, candidate)
3818
3817
  const endProgramDateTime = candidate.endProgramDateTime || 0;
3819
3818
  return endProgramDateTime - candidateLookupTolerance > pdtBufferEnd;
3820
3819
  }
3821
- function findFragWithCC(fragments, cc) {
3822
- return BinarySearch.search(fragments, candidate => {
3823
- if (candidate.cc < cc) {
3824
- return 1;
3825
- } else if (candidate.cc > cc) {
3826
- return -1;
3827
- } else {
3828
- return 0;
3820
+ function findNearestWithCC(details, cc, pos) {
3821
+ if (details) {
3822
+ if (details.startCC <= cc && details.endCC >= cc) {
3823
+ let fragments = details.fragments;
3824
+ const {
3825
+ fragmentHint
3826
+ } = details;
3827
+ if (fragmentHint) {
3828
+ fragments = fragments.concat(fragmentHint);
3829
+ }
3830
+ let closest;
3831
+ BinarySearch.search(fragments, candidate => {
3832
+ if (candidate.cc < cc) {
3833
+ return 1;
3834
+ }
3835
+ if (candidate.cc > cc) {
3836
+ return -1;
3837
+ }
3838
+ closest = candidate;
3839
+ if (candidate.end <= pos) {
3840
+ return 1;
3841
+ }
3842
+ if (candidate.start > pos) {
3843
+ return -1;
3844
+ }
3845
+ return 0;
3846
+ });
3847
+ return closest || null;
3829
3848
  }
3830
- });
3849
+ }
3850
+ return null;
3831
3851
  }
3832
3852
 
3833
3853
  function isTimeoutError(error) {
@@ -4115,7 +4135,7 @@ class ErrorController extends Logger {
4115
4135
  minAutoLevel,
4116
4136
  maxAutoLevel
4117
4137
  } = hls;
4118
- if (!hls.autoLevelEnabled) {
4138
+ if (!hls.autoLevelEnabled && !hls.config.preserveManualLevelOnError) {
4119
4139
  hls.loadLevel = -1;
4120
4140
  }
4121
4141
  const fragErrorType = (_data$frag2 = data.frag) == null ? void 0 : _data$frag2.type;
@@ -8771,7 +8791,7 @@ class BaseStreamController extends TaskLoop {
8771
8791
  this.log(`LL-Part loading ON for initial live fragment`);
8772
8792
  this.loadingParts = true;
8773
8793
  }
8774
- frag = this.getInitialLiveFragment(levelDetails, fragments);
8794
+ frag = this.getInitialLiveFragment(levelDetails);
8775
8795
  const mainStart = this.hls.startPosition;
8776
8796
  const liveSyncPosition = this.hls.liveSyncPosition;
8777
8797
  const startPosition = frag ? (mainStart !== -1 && mainStart >= start ? mainStart : liveSyncPosition) || frag.start : pos;
@@ -8868,7 +8888,8 @@ class BaseStreamController extends TaskLoop {
8868
8888
  "sliding" of the playlist, which is its offset from the start of playback. After sliding we can compute the real
8869
8889
  start and end times for each fragment in the playlist (after which this method will not need to be called).
8870
8890
  */
8871
- getInitialLiveFragment(levelDetails, fragments) {
8891
+ getInitialLiveFragment(levelDetails) {
8892
+ const fragments = levelDetails.fragments;
8872
8893
  const fragPrevious = this.fragPrevious;
8873
8894
  let frag = null;
8874
8895
  if (fragPrevious) {
@@ -8891,7 +8912,7 @@ class BaseStreamController extends TaskLoop {
8891
8912
  // It's important to stay within the continuity range if available; otherwise the fragments in the playlist
8892
8913
  // will have the wrong start times
8893
8914
  if (!frag) {
8894
- frag = findFragWithCC(fragments, fragPrevious.cc);
8915
+ frag = findNearestWithCC(levelDetails, fragPrevious.cc, fragPrevious.end);
8895
8916
  if (frag) {
8896
8917
  this.log(`Live playlist, switching playlist, load frag with same CC: ${frag.sn}`);
8897
8918
  }
@@ -17775,6 +17796,7 @@ const hlsDefaultConfig = _objectSpread2(_objectSpread2({
17775
17796
  interstitialAppendInPlace: true,
17776
17797
  interstitialLiveLookAhead: 10,
17777
17798
  useMediaCapabilities: false,
17799
+ preserveManualLevelOnError: false,
17778
17800
  certLoadPolicy: {
17779
17801
  default: defaultLoadPolicy
17780
17802
  },
@@ -19870,7 +19892,7 @@ function assignTrackIdsByGroup(tracks) {
19870
19892
  });
19871
19893
  }
19872
19894
 
19873
- const version = "1.6.3-0.canary.11252";
19895
+ const version = "1.6.3-0.canary.11254";
19874
19896
 
19875
19897
  // ensure the worker ends up in the bundle
19876
19898
  // If the worker should not be included this gets aliased to empty.js