From 421d0be96a8547897fad05a5d40832d5cc7ed15a Mon Sep 17 00:00:00 2001 From: Rob Walch Date: Tue, 6 Feb 2024 11:47:48 -0800 Subject: [PATCH] Fix regression that removed (unofficial) support for `startLevel` above max level index Fixes #6172 --- docs/API.md | 2 +- src/controller/abr-controller.ts | 5 +++-- src/controller/stream-controller.ts | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/API.md b/docs/API.md index 42c1217fc0f..2868102f12c 100644 --- a/docs/API.md +++ b/docs/API.md @@ -737,7 +737,7 @@ Enable to use JavaScript version AES decryption for fallback of WebCrypto API. (default: `undefined`) -When set, use this level as the default hls.startLevel. Keep in mind that the startLevel set with the API takes precedence over config.startLevel configuration parameter. +When set, use this level as the default `hls.startLevel`. Keep in mind that the `startLevel` set with the API takes precedence over config.startLevel configuration parameter. `startLevel` should be set to value between 0 and the maximum index of `hls.levels`. ### `fragLoadingTimeOut` / `manifestLoadingTimeOut` / `levelLoadingTimeOut` (deprecated) diff --git a/src/controller/abr-controller.ts b/src/controller/abr-controller.ts index 224eb4f092f..3fe07074279 100644 --- a/src/controller/abr-controller.ts +++ b/src/controller/abr-controller.ts @@ -870,8 +870,9 @@ class AbrController implements AbrComponentAPI { } public set nextAutoLevel(nextLevel: number) { - const value = Math.max(this.hls.minAutoLevel, nextLevel); - if (this._nextAutoLevel != value) { + const { maxAutoLevel, minAutoLevel } = this.hls; + const value = Math.min(Math.max(nextLevel, minAutoLevel), maxAutoLevel); + if (this._nextAutoLevel !== value) { this.nextAutoLevelKey = ''; this._nextAutoLevel = value; } diff --git a/src/controller/stream-controller.ts b/src/controller/stream-controller.ts index 51332515e29..b8d4d60be86 100644 --- a/src/controller/stream-controller.ts +++ b/src/controller/stream-controller.ts @@ -140,7 +140,8 @@ export default class StreamController } // set new level to playlist loader : this will trigger start level load // hls.nextLoadLevel remains until it is set to a new value or until a new frag is successfully loaded - this.level = hls.nextLoadLevel = startLevel; + hls.nextLoadLevel = startLevel; + this.level = hls.loadLevel; this.loadedmetadata = false; } // if startPosition undefined but lastCurrentTime set, set startPosition to last currentTime