update auto level stuff

This commit is contained in:
Pas 2025-12-24 09:27:46 -07:00
parent 4143e97047
commit f4f2f9196e
2 changed files with 8 additions and 4 deletions

View file

@ -169,8 +169,12 @@ export function makeVideoElementDisplayInterface(): DisplayInterface {
hls.currentLevel = -1;
hls.loadLevel = -1;
}
const quality = hlsLevelToQuality(hls.levels[hls.currentLevel]);
emit("changedquality", quality);
// Only emit quality when we have a valid level index (>= 0)
// When automaticQuality is true, currentLevel is -1, so we wait for LEVEL_SWITCHED event
if (hls.currentLevel >= 0) {
const quality = hlsLevelToQuality(hls.levels[hls.currentLevel]);
emit("changedquality", quality);
}
}
function setupSource(vid: HTMLVideoElement, src: LoadableSource) {
@ -189,6 +193,7 @@ export function makeVideoElementDisplayInterface(): DisplayInterface {
autoStartLoad: true,
maxBufferLength: 120, // 120 seconds
maxMaxBufferLength: 240,
abrEwmaDefaultEstimate: 5 * 1000 * 1000, // 5 Mbps default bandwidth estimate for better ABR decisions
fragLoadPolicy: {
default: {
maxLoadTimeMs: 30 * 1000, // allow it load extra long, fragments are slow if requested for the first time on an origin

View file

@ -253,12 +253,11 @@ export const createSourceSlice: MakeSlice<SourceSlice> = (set, get) => ({
},
redisplaySource(startAt: number) {
const store = get();
const quality = store.currentQuality;
if (!store.source) return;
const qualityPreferences = useQualityStore.getState();
const loadableStream = selectQuality(store.source, {
automaticQuality: qualityPreferences.quality.automaticQuality,
lastChosenQuality: quality,
lastChosenQuality: qualityPreferences.quality.lastChosenQuality,
});
set((s) => {
s.interface.error = undefined;