useLocalMedia
Last updated
Last updated
The useLocalMedia
hook enables preview and selection of local devices (camera & microphone) prior to establishing a connection within a Whereby room. Use this hook to build rich pre-call and waiting room experiences, allowing end users to confirm their device selection up-front. This hook works seamlessly with the hook.
useLocalMedia(mediaStreamConstraints: MediaStreamConstraints): Object | null
The hook returns a LocalMediaReference object with the following properties.
The state of local media
The actions property contains a map of functions which can be invoked to perform an action on local media. All these functions are sync and return void
, and you should rely on the to render the effect of their invocation.
setCameraDevice
(deviceId: string) => void
Change the current camera device
setMicrophoneDevice
(deviceId: string) => void
Change the current microphone device
setSpeakerDevice
(deviceId: string) => void
Change the current speaker device
toggleCameraEnabled
(enabled?: boolean) => void
Change the state of your camera. Omitting the enabled
parameter toggles the current value
toggleMicrophoneEnabled
(enabled?: boolean) => void
Change the state of your microphone. Omitting the enabled
parameter toggles the current value
toggleLowDataModeEnabled
(enabled?: boolean) => void
Change the state of low data mode. Omitting the enabled
parameter toggles the current value
mediaStreamConstraints
Options to use for initializing local media
state
Object representing the state of local media
actions
Object representing the available actions on local media
currentCameraDeviceId
string | undefined
The Id of the current camera device
currentMicrophoneDeviceId
string | undefined
The id of the current microphone device
cameraDeviceError
unknown
cameraDevices
List of the available camera devices
isSettingCameraDevice
boolean
isSettingMicrophoneDevice
boolean
isStarting
boolean
localStream
MediaStream
| undefined
The stream of local media (camera & microphone)
lowDataMode
boolean
State of low data mode
microphoneDeviceError
unknown
microphoneDevices
List of the available microphone devices
speakerDevices
List of the available speaker devices
startError
unknown