"use client"; import { useEffect } from "react"; import { DailyMeetingState } from "@daily-co/daily-js"; import { useDaily, useDevices } from "@daily-co/daily-react"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { IconMicrophone, IconDeviceSpeaker } from "@tabler/icons-react"; import { AudioIndicatorBar } from "../AudioIndicator"; interface Props {} export default function DevicePicker({}: Props) { const daily = useDaily(); const { currentMic, hasMicError, micState, microphones, setMicrophone, currentSpeaker, speakers, setSpeaker, } = useDevices(); const handleMicrophoneChange = (value: string) => { setMicrophone(value); }; const handleSpeakerChange = (value: string) => { setSpeaker(value); }; useEffect(() => { if (microphones.length > 0 || !daily || daily.isDestroyed()) return; const meetingState = daily.meetingState(); const meetingStatesBeforeJoin: DailyMeetingState[] = [ "new", "loading", "loaded", ]; if (meetingStatesBeforeJoin.includes(meetingState)) { daily.startCamera({ startVideoOff: true, startAudioOff: false }); } }, [daily, microphones]); return (
Please check your browser and system permissions. Make sure that this app is allowed to access your microphone.
) : micState === "in-use" ? (Your microphone is being used by another app. Please close any other apps using your microphone and restart this app.
) : micState === "not-found" ? (No microphone seems to be connected. Please connect a microphone.
) : micState === "not-supported" ? (This app is not supported on your device. Please update your software or use a different device.
) : (There seems to be an issue accessing your microphone. Try restarting the app or consult a system administrator.
)}