"use client"; import { useEffect, useRef } from "react"; import type { Track } from "livekit-client"; export function SfuVideoTile({ videoTrack, audioTrack, name, isLocal = false, isHost = false, muted = false, videoOff = false, speaking = false, compact = false, }: { videoTrack?: Track | null; audioTrack?: Track | null; name: string; isLocal?: boolean; isHost?: boolean; muted?: boolean; videoOff?: boolean; speaking?: boolean; compact?: boolean; }) { const videoRef = useRef(null); const audioRef = useRef(null); useEffect(() => { const videoElement = videoRef.current; if (!videoElement || !videoTrack || videoOff) return; videoTrack.attach(videoElement); return () => { videoTrack.detach(videoElement); }; }, [videoTrack, videoOff]); useEffect(() => { const audioElement = audioRef.current; if (!audioElement || !audioTrack || isLocal) return; audioTrack.attach(audioElement); return () => { audioTrack.detach(audioElement); }; }, [audioTrack, isLocal]); return (
{videoTrack && !videoOff ? (
); }