Skip to content

Commit

Permalink
Merge pull request #5570 from video-dev/bugfix/patch-switch-on-error-…
Browse files Browse the repository at this point in the history
…with-caps

Keep level switch error actions within player constraints
  • Loading branch information
robwalch committed Jun 15, 2023
2 parents a41088c + 4be1e13 commit bfa3cb6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/controller/error-controller.ts
Expand Up @@ -330,14 +330,16 @@ export default class ErrorController implements NetworkComponentAPI {
if (hls.autoLevelEnabled) {
// Search for next level to retry
let nextLevel = -1;
const levels = hls.levels;
const { levels, loadLevel, minAutoLevel, maxAutoLevel } = hls;
const fragErrorType = data.frag?.type;
const { type: playlistErrorType, groupId: playlistErrorGroupId } =
data.context ?? {};
for (let i = levels.length; i--; ) {
const candidate = (i + hls.loadLevel) % levels.length;
const candidate = (i + loadLevel) % levels.length;
if (
candidate !== hls.loadLevel &&
candidate !== loadLevel &&
candidate >= minAutoLevel &&
candidate <= maxAutoLevel &&
levels[candidate].loadError === 0
) {
const levelCandidate = levels[candidate];
Expand Down

0 comments on commit bfa3cb6

Please sign in to comment.