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
Parameter | Required | Type | Description |
---|---|---|---|
mediaStreamConstraints | Options to use for initializing local media |
Return type
The hook returns a LocalMediaReference object with the following properties.
Property | Type | Description |
---|---|---|
state | Object representing the state of local media | |
actions | Object representing the available actions on local media |
state
The state of local media
Property | Type | Description |
---|---|---|
currentCameraDeviceId |
| The Id of the current camera device |
currentMicrophoneDeviceId |
| The id of the current microphone device |
cameraDeviceError |
| |
cameraDevices | List of the available camera devices | |
isSettingCameraDevice |
| |
isSettingMicrophoneDevice |
| |
isStarting |
| |
localStream | The stream of local media (camera & microphone) | |
lowDataMode | boolean | State of low data mode |
microphoneDeviceError |
| |
microphoneDevices | List of the available microphone devices | |
speakerDevices | List of the available speaker devices | |
startError |
|
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.
Name | Parameters | Description |
---|---|---|
setCameraDevice |
| Change the current camera device |
setMicrophoneDevice |
| Change the current microphone device |
setSpeakerDevice |
| Change the current speaker device |
toggleCameraEnabled |
| Change the state of your camera. Omitting the |
toggleMicrophoneEnabled |
| Change the state of your microphone. Omitting the |
toggleLowDataModeEnabled |
| Change the state of low data mode. Omitting the |
Usage
Last updated