"use client"; import { useEffect, useRef, useState } from "react"; import { Button } from "@/components/ui/button"; import { Mic, MicOff, Video, VideoOff, PhoneOff } from "lucide-react"; import { Card } from "@/components/ui/card"; interface CallInterfaceProps { localStream: MediaStream | null; remoteStreams: Map; onLeave: () => void; nicknames: Map; } export default function CallInterface({ localStream, remoteStreams, onLeave, nicknames }: CallInterfaceProps) { const localVideoRef = useRef(null); const [isMuted, setIsMuted] = useState(false); const [isVideoOff, setIsVideoOff] = useState(false); useEffect(() => { if (localVideoRef.current && localStream) { localVideoRef.current.srcObject = localStream; } }, [localStream]); const toggleMute = () => { if (localStream) { localStream.getAudioTracks().forEach(track => track.enabled = !track.enabled); setIsMuted(!isMuted); } }; const toggleVideo = () => { if (localStream) { localStream.getVideoTracks().forEach(track => track.enabled = !track.enabled); setIsVideoOff(!isVideoOff); } }; return (
{/* Local Video */} {/* Remote Videos */} {Array.from(remoteStreams.entries()).map(([socketId, stream]) => ( ))}
{/* Controls */}
); } function RemoteVideo({ stream, nickname }: { stream: MediaStream; nickname: string }) { const videoRef = useRef(null); useEffect(() => { if (videoRef.current) { videoRef.current.srcObject = stream; } }, [stream]); return ( ); }