useLocalMedia
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 useRoomConnection hook.
useLocalMedia(mediaStreamConstraints: MediaStreamConstraints): Object | null
Parameters
Return type
The hook returns a LocalMediaReference object with the following properties.
state
The state of local media
currentCameraDeviceId
string | undefined
The Id of the current camera device
currentMicrophoneDeviceId
string | undefined
The id of the current microphone device
cameraDeviceError
unknown
isSettingCameraDevice
boolean
isSettingMicrophoneDevice
boolean
isStarting
boolean
lowDataMode
boolean
State of low data mode
microphoneDeviceError
unknown
startError
unknown
actions
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 state 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
Usage
Last updated