This commit is contained in:
Josh Hawkins 2024-02-10 09:36:22 -06:00
parent 8377e466a3
commit 5a2b88a5f0
2 changed files with 4 additions and 18 deletions

View File

@ -23,7 +23,6 @@ const emptyObject = Object.freeze({});
type LivePlayerProps = { type LivePlayerProps = {
className?: string; className?: string;
aspectRatio?: string;
cameraConfig: CameraConfig; cameraConfig: CameraConfig;
preferredLiveMode?: LivePlayerMode; preferredLiveMode?: LivePlayerMode;
showStillWithoutActivity?: boolean; showStillWithoutActivity?: boolean;
@ -33,7 +32,6 @@ type Options = { [key: string]: boolean };
export default function LivePlayer({ export default function LivePlayer({
className, className,
aspectRatio,
cameraConfig, cameraConfig,
preferredLiveMode, preferredLiveMode,
showStillWithoutActivity = true, showStillWithoutActivity = true,
@ -168,7 +166,6 @@ export default function LivePlayer({
? "outline-destructive outline-1 rounded-2xl shadow-[0_0_6px_1px] shadow-destructive" ? "outline-destructive outline-1 rounded-2xl shadow-[0_0_6px_1px] shadow-destructive"
: "outline-0" : "outline-0"
} transition-all duration-500 ${className}`} } transition-all duration-500 ${className}`}
style={{ aspectRatio: aspectRatio }}
> >
{(showStillWithoutActivity == false || activeMotion || activeTracking) && {(showStillWithoutActivity == false || activeMotion || activeTracking) &&
player} player}

View File

@ -80,17 +80,15 @@ function Live() {
let grow; let grow;
let aspectRatio = camera.detect.width / camera.detect.height; let aspectRatio = camera.detect.width / camera.detect.height;
if (aspectRatio > 2) { if (aspectRatio > 2) {
grow = "md:col-span-2"; grow = "md:col-span-2 aspect-wide";
} else if (aspectRatio < 1) { } else if (aspectRatio < 1) {
grow = `md:row-span-2`; grow = `md:row-span-2 aspect-[8/9]`;
} else {
grow = "aspect-video";
} }
return ( return (
<LivePlayer <LivePlayer
key={camera.name} key={camera.name}
aspectRatio={getAspectRatio(
camera.detect.width,
camera.detect.height
)}
className={`mb-2 md:mb-0 rounded-2xl bg-black ${grow}`} className={`mb-2 md:mb-0 rounded-2xl bg-black ${grow}`}
cameraConfig={camera} cameraConfig={camera}
preferredLiveMode="mse" preferredLiveMode="mse"
@ -102,13 +100,4 @@ function Live() {
); );
} }
function getAspectRatio(width: number, height: number): string {
const gcd = (a: number, b: number): number => {
return b === 0 ? a : gcd(b, a % b);
};
const common = gcd(width, height);
return `${width / common}/${height / common}`;
}
export default Live; export default Live;