Fix screen share player sizing

This commit is contained in:
illusia committed 2026-10-11 23:36:58 +08:00
1 parent 13499541e0
commit a4e54d6341
5 files changed
+86 -5

No files matched your search

@@ -10,6 +10,20 @@ interface ScreenShareResolutionOption {
label: string;
}
export function calculateScreenSharePlayerSize(
sourceWidth: number,
sourceHeight: number,
maxWidth: number,
maxHeight: number,
): { width: number; height: number } | null {
if (![sourceWidth, sourceHeight, maxWidth, maxHeight].every((value) => Number.isFinite(value) && value > 0)) return null;
const scale = Math.min(maxWidth / sourceWidth, maxHeight / sourceHeight);
return {
width: Math.max(1, Math.floor(sourceWidth * scale)),
height: Math.max(1, Math.floor(sourceHeight * scale)),
};
}
interface UseWebClientScreenShareOptions {
streams: ScreenShareStream[];
viewing: Ref<boolean>;