Media Devices
Check permission
checkPermission
method helps to check whether permission is given or not for given type.
Parameters
Name | Type | Description |
---|---|---|
mediaDeviceKind | 'cam' | 'mic' | 'speaker' | Type of device whose permission you want to check |
Example
const isCamPermission = await huddleClient.localPeer.deviceHandler.checkPermission({
mediaDeviceKind: 'cam'
});
const isMicPermission = await huddleClient.localPeer.deviceHandler.checkPermission({
mediaDeviceKind: 'mic'
});
getMediaPermission
getMediaPermission
method retrieves the media permission for the specified device type.
Parameters
Name | Type | Description |
---|---|---|
mediaDeviceKind | 'cam' | 'mic' | 'speaker' | Type of device |
Example
// Get permission for cam
await huddleClient.localPeer.deviceHandler.getMediaPermission({
mediaDeviceKind: 'cam'
});
// Get permission for mic
await huddleClient.localPeer.deviceHandler.getMediaPermission({
mediaDeviceKind: 'mic'
});
getMediaDevices
getMediaDevices
method returns MediaDeviceInfo[]
, which contains a list of all the devices available in the system based on the specified deviceKind
.
Parameters
Name | Type | Description |
---|---|---|
filterByDeviceKind | 'mic' | 'cam' | 'speaker' | Type of device |
Example
const camDevices = await huddleClient.localPeer.deviceHandler.getMediaDevices({
filterByDeviceKind: 'cam'
});
const micDevices = await huddleClient.localPeer.deviceHandler.getMediaDevices({
filterByDeviceKind: 'mic'
});
const speakerDevices = await huddleClient.localPeer.deviceHandler.getMediaDevices({
filterByDeviceKind: 'speaker'
});
fetchStream
fetchStream
method retrieves the stream from the device for the specified media kind. If no preferred device is found, it will throw an error.
Parameters
Name | Type | Description |
---|---|---|
mediaDeviceKind | 'mic' | 'cam' | Type of device |
Example
const camStream = await huddleClient.localPeer.deviceHandler.fetchStream({mediaDeviceKind: 'cam'});
stopStream
stopStream
method stops the stream from the device for the specified media kind. If no preferred device is found, it will throw an error.
Parameters
Name | Type | Description |
---|---|---|
mediaDeviceKind | 'mic' | 'cam' | Type of device |
Example
await huddleClient.localPeer.deviceHandler.stopStream({mediaDeviceKind: 'cam'});
Events
Name | Description | Returns |
---|---|---|
stream-playable | Triggered when a stream becomes playable. | { label: string; producer: Producer } |
stream-closed | Triggered when a stream is closed. | { label: string } |
stream-fetched | Triggered when a stream is fetched. | { mediaKind: CustomMediaKind; stream: MediaStream; label: string } |
stream-stopped | Triggered when a stream is stopped. | { mediaKind: CustomMediaKind; label: string } |