Media Devices

Check permission

checkPermission method helps to check whether permission is given or not for given type.

Parameters

NameTypeDescription
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

NameTypeDescription
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

NameTypeDescription
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

NameTypeDescription
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

NameTypeDescription
mediaDeviceKind'mic' | 'cam'Type of device

Example

await huddleClient.localPeer.deviceHandler.stopStream({mediaDeviceKind: 'cam'});

Events

NameDescriptionReturns
stream-playableTriggered when a stream becomes playable.{ label: string; producer: Producer }
stream-closedTriggered when a stream is closed.{ label: string }
stream-fetchedTriggered when a stream is fetched.{ mediaKind: CustomMediaKind; stream: MediaStream; label: string }
stream-stoppedTriggered when a stream is stopped.{ mediaKind: CustomMediaKind; label: string }
Audio/Video Infrastructure designed for the developers to empower them ship simple yet powerful Audio/Video Apps.
support
company
Copyright © 2022 Graphene 01, Inc. All Rights Reserved.