useDevices

useDevices(): Object

Returns information about a participant's media devices and their states, along with helper functions that wrap daily-js device-related methods.

Return type

Returns an object with the following properties:

NameTypeDescription
camerasObject[]An array of device objects that detail information about each camera
camStatestring'pending' | 'not-supported' | 'granted' | 'blocked' | 'in-use' | 'not-found', indicates the general state of camera access
hasCamErrorbooleantrue in case camState is one of 'blocked' | 'in-use' | 'not-found'
hasMicErrorbooleantrue in case micState is one of 'blocked' | 'in-use' | 'not-found'
microphonesObject[]An array of device objects that detail information about each microphone
micStatestring'pending' | 'not-supported' | 'granted' | 'blocked' | 'in-use' | 'not-found', indicates the general state of microphone access
refreshDevicesFunctionRefreshes the list of devices using enumerateDevices()
setCameraFunctionSwitches to the camera with the specified deviceId. Calls setInputDevicesAsync()
setMicrophoneFunctionSwitches to the mic with the specified deviceId. Calls setInputDevicesAsync()
setSpeakerFunctionSwitches to the speaker with the specified deviceId. Calls setInputDevicesAsync()
speakersObject[]An array of device objects that detail information about each speaker

Device object properties

NameTypeDescription
deviceObjectThe same device information returned from enumerateDevices()
selectedbooleantrue when this specific device is currently being used by getUserMedia()
statestring'granted' | 'in-use', 'granted' means the device is available, 'in-use' means the device is used by another app

Sample code