Loading files
05241c15dThis file is pinned to the selected release. Download the original to open it in your design tool.
"use client";
import { useEffect, useRef } from "react";
import type { RemoteTrack } from "livekit-client";
export function CameraTile({
track,
label,
fit = "cover",
}: {
track: RemoteTrack | undefined;
label: string;
/** "cover" fills the tile (crops); "contain" shows the whole feed (letterboxed) */
fit?: "cover" | "contain";
}) {
const ref = useRef<HTMLVideoElement | null>(null);
useEffect(() => {
const el = ref.current;
if (!el || !track) return;
track.attach(el);
return () => {
track.detach(el);
};
}, [track]);
if (!track) {
return (
<div className="absolute inset-0 flex flex-col items-center justify-center gap-3 text-center">
<div className="font-pixel text-neon-magenta neon-text text-sm sm:text-base blink">
NO SIGNAL
</div>
<div className="font-terminal text-neon-cyan/70 text-lg tracking-widest">
{label}
</div>
<div className="font-terminal text-cab-500 text-sm">
waiting for camera feed…
</div>
</div>
);
}
return (
<video
ref={ref}
autoPlay
muted
playsInline
className={`absolute inset-0 h-full w-full ${fit === "contain" ? "object-contain" : "object-cover"}`}
/>
);
}