'use client'; import React, { useState, useEffect } from 'react'; import { TrackToggle, DisconnectButton } from '@livekit/components-react'; import { Room, RoomEvent, Track } from 'livekit-client'; import '../../styles/CustomControlBar.css'; interface CustomControlBarProps { room: Room; roomName: string; } export function CustomControlBar({ room, roomName }: CustomControlBarProps) { const [recording, setRecording] = useState(false); const [participantCount, setParticipantCount] = useState(1); useEffect(() => { if (room) { const updateRecordingStatus = () => setRecording(room.isRecording); const updateParticipantCount = () => { if (room && room.participants) { setParticipantCount(room.participants.size + 1); } }; if (room.state === 'connected') { updateParticipantCount(); } room.on(RoomEvent.Connected, updateParticipantCount); room.on(RoomEvent.ParticipantConnected, updateParticipantCount); room.on(RoomEvent.ParticipantDisconnected, updateParticipantCount); room.on(RoomEvent.RecordingStatusChanged, updateRecordingStatus); return () => { room.off(RoomEvent.Connected, updateParticipantCount); room.off(RoomEvent.ParticipantConnected, updateParticipantCount); room.off(RoomEvent.ParticipantDisconnected, updateParticipantCount); room.off(RoomEvent.RecordingStatusChanged, updateRecordingStatus); }; } }, [room]); const handleCopyLink = () => { navigator.clipboard.writeText(window.location.href) .then(() => alert('Link copied to clipboard!')) .catch((err) => console.error('Failed to copy link:', err)); }; return (