fix transcoding restart on explicit quality selection

pull/28312/head
mertalev 2026-05-21 16:35:36 -04:00
parent 18b0ff127d
commit afaf3cbb4f
No known key found for this signature in database
GPG Key ID: 0603AE056AA39037
1 changed files with 9 additions and 0 deletions

View File

@ -140,6 +140,15 @@
return;
}
// This is a hack to make the rendition menu use `api.currentLevel` instead of `api.nextLevel`.
// `api.nextLevel` makes the player request the next segment followed by the current segment.
// That backward request causes the server to restart transcoding for no reason.
Object.defineProperty(api, 'nextLevel', {
configurable: true,
get: () => api.currentLevel,
set: (level: number) => (api.currentLevel = level)
});
// eslint-disable-next-line @typescript-eslint/no-misused-promises
api.on(Hls.Events.MANIFEST_PARSED, async () => {
// Defer hls.js's first fragment load until we filter out suboptimal variants