mirror of
https://github.com/p-stream/p-stream.git
synced 2026-05-15 13:52:02 +00:00
Update base.ts
This commit is contained in:
parent
93b5971f1f
commit
215cf9e367
1 changed files with 10 additions and 26 deletions
|
|
@ -170,12 +170,9 @@ export function makeVideoElementDisplayInterface(): DisplayInterface {
|
||||||
hls.currentLevel = -1;
|
hls.currentLevel = -1;
|
||||||
hls.loadLevel = -1;
|
hls.loadLevel = -1;
|
||||||
}
|
}
|
||||||
// Only emit quality when we have a valid level index (>= 0)
|
// For manual quality selection, wait for LEVEL_SWITCHED to emit quality
|
||||||
// When automaticQuality is true, currentLevel is -1, so we wait for LEVEL_SWITCHED event
|
// to avoid showing intermediate states when HLS switches away from unplayable levels
|
||||||
if (hls.currentLevel >= 0) {
|
// For automatic quality, currentLevel is -1, so we wait for LEVEL_SWITCHED event
|
||||||
const quality = hlsLevelToQuality(hls.levels[hls.currentLevel]);
|
|
||||||
emit("changedquality", quality);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupSource(vid: HTMLVideoElement, src: LoadableSource) {
|
function setupSource(vid: HTMLVideoElement, src: LoadableSource) {
|
||||||
|
|
@ -313,29 +310,16 @@ export function makeVideoElementDisplayInterface(): DisplayInterface {
|
||||||
// Don't process level switched events during debounced quality changes
|
// Don't process level switched events during debounced quality changes
|
||||||
if (qualityChangeTimeout) return;
|
if (qualityChangeTimeout) return;
|
||||||
|
|
||||||
|
const currentLevel = hls.levels[hls.currentLevel];
|
||||||
|
const currentQuality = hlsLevelToQuality(currentLevel);
|
||||||
|
|
||||||
if (automaticQuality) {
|
if (automaticQuality) {
|
||||||
// Only emit quality changes when automatic quality is enabled
|
// Only emit quality changes when automatic quality is enabled
|
||||||
const quality = hlsLevelToQuality(hls.levels[hls.currentLevel]);
|
emit("changedquality", currentQuality);
|
||||||
emit("changedquality", quality);
|
|
||||||
} else {
|
} else {
|
||||||
// When automatic quality is disabled, check if current level matches preferred quality
|
// For manual quality selection, emit the user's preferred quality
|
||||||
const currentQuality = hlsLevelToQuality(
|
// This ensures the UI shows the selected quality, not the actual playing quality
|
||||||
hls.levels[hls.currentLevel],
|
emit("changedquality", preferenceQuality);
|
||||||
);
|
|
||||||
const preferredQualityLevel = getPreferredQuality(
|
|
||||||
hlsLevelsToQualities(hls.levels),
|
|
||||||
{
|
|
||||||
lastChosenQuality: preferenceQuality,
|
|
||||||
automaticQuality: false,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
// Only re-lock if the current level doesn't match our preferred quality
|
|
||||||
if (currentQuality !== preferredQualityLevel) {
|
|
||||||
setupQualityForHls();
|
|
||||||
} else {
|
|
||||||
// Emit the quality change since we're now at the correct level
|
|
||||||
emit("changedquality", currentQuality);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
hls.on(Hls.Events.SUBTITLE_TRACK_LOADED, () => {
|
hls.on(Hls.Events.SUBTITLE_TRACK_LOADED, () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue