TUIDeviceManager
is an multimedia device manager used to manage audio and video-related hardware devices such as cameras, microphones, and speakers.// npmnpm i @tencentcloud/tuiroom-engine-electron@2.4.0-alpha.3 --save// pnpmpnpm i @tencentcloud/tuiroom-engine-electron@2.4.0-alpha.3 --save// yarnyarn add @tencentcloud/tuiroom-engine-electron@2.4.0-alpha.3
import TUIRoomEngine, {TUIDeviceManager, TUIDeviceInfo} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();const cameraList: Array<TUIDeviceInfo> = deviceManager.getCameraDevicesList();
Method | Description |
Get the list of camera devices | |
Get the list of microphone devices | |
Get the list of speaker devices | |
Set the current device | |
Get the current device | |
Set the volume of the current device | |
Get the volume of the current device | |
Mute the current device | |
Get the mute status of the current device | |
Enable system device following | |
Start microphone test | |
Stop microphone test | |
Start speaker test | |
Stop speaker test | |
Start camera test | |
Stop camera test | |
Enable mirror during camera test | |
Set the camera device during camera test | |
Set the capture resolution of the camera during the test | |
Set the video preprocessing plugin library file path during camera test | |
Set video preprocessing parameters during camera test | |
Register event listener | |
Unregister event listener |
Type | Description |
Camera capture parameters | |
Audio and video device information | |
Rectangular coordinate area |
Enum | Description |
Camera capture mode | |
Audio and video device event type | |
Audio and video device state | |
Audio and video device type |
import TUIRoomEngine, {TUIDeviceManager, TUIDeviceInfo} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();const cameraList: Array<TUIDeviceInfo> = deviceManager.getCameraDevicesList();
TUIDeviceInfo
>import TUIRoomEngine, {TUIDeviceManager, TUIDeviceInfo} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();const cameraList: Array<TUIDeviceInfo> = deviceManager.getMicDevicesList();
TUIDeviceInfo
>import TUIRoomEngine, {TUIDeviceManager, TUIDeviceInfo} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();const cameraList: Array<TUIDeviceInfo> = deviceManager.getSpeakerDevicesList();
TUIDeviceInfo
>import TUIRoomEngine, {TUIDeviceManager, TUIMediaDeviceType} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();deviceManager.setCurrentDevice(TUIMediaDeviceType.kMediaDeviceTypeAudioOutput, 'Your speaker ID');
Parameter | Type | Validation | Default value | Description |
type | - | - | Device type | |
deviceId | string | - | - | Device ID |
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager, TUIMediaDeviceType} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();const currentSpeaker:TUIDeviceInfo = await deviceManager.getCurrentDevice(TUIMediaDeviceType.kMediaDeviceTypeAudioOutput);
Parameter | Type | Validation | Default value | Description |
type | - | - | Device type |
Promise
<TUIDeviceInfo
>import TUIRoomEngine, {TUIDeviceManager, TUIMediaDeviceType} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();deviceManager.setCurrentDeviceVolume(TUIMediaDeviceType.kMediaDeviceTypeAudioInput, value);
Parameter | Type | Validation | Default value | Description |
type | - | - | Device type. Only for microphone and speaker | |
volume | number | [0-100] | 60 | Volume, range: 0 - 100 |
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager, TUIMediaDeviceType} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();const currentMicVolume = await deviceManager.getCurrentDeviceVolume(TUIMediaDeviceType.kMediaDeviceTypeAudioInput);
Parameter | Type | Validation | Default value | Description |
type | - | - | Device type |
Promise
<number
>import TUIRoomEngine, {TUIDeviceManager, TUIMediaDeviceType} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();deviceManager.setCurrentDeviceMute(TUIMediaDeviceType.kMediaDeviceTypeAudioInput, true);
Parameter | Type | Validation | Default value | Description |
type | - | - | Device type | |
mute | boolean | - | - | Whether to mute or not |
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager, TUIMediaDeviceType} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();const isCurrentMicMuted = await deviceManager.getCurrentDeviceMute(TUIMediaDeviceType.kMediaDeviceTypeAudioInput, true);
Parameter | Type | Validation | Default value | Description |
type | - | - | Device type |
Promise
<boolean
>import TUIRoomEngine, {TUIDeviceManager, TUIMediaDeviceType} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();deviceManager.enableFollowingDefaultAudioDevice(TUIMediaDeviceType.kMediaDeviceTypeAudioInput, true);
Parameter | Type | Validation | Default value | Description |
type | - | - | Device type | |
enable | boolean | - | - | Whether to follow the system's default audio device |
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();deviceManager.startMicDeviceTest(300, true);
Parameter | Type | Validation | Default value | Description |
interval | number | - | - | Microphone volume callback interval, unit: milliseconds. |
playback | boolean | - | - | Whether to enable microphone sound playback. After enabling, the user will hear their own voice when testing the microphone. If the playback parameter is not passed, it defaults to false. |
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();deviceManager.stopMicDeviceTest();
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();const audioFilePath = '';deviceManager.startSpeakerDeviceTest(audioFilePath);
Parameter | Type | Validation | Default value | Description |
filePath | string | Valid audio file path | - | Audio file path used to test speaker. |
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();deviceManager.stopSpeakerDeviceTest();
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager, TUIRect} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();const rect: TUIRect = {left: 100,top: 50,right: 740,bottom: 410,};const windowID: Uint8Array; // Get by Electron API BrowserWindow.getNativeWindowHandle()deviceManager.startCameraDeviceTest(windowID, rect);
Parameter | Type | Validation | Default value | Description |
windowID | Uint8Array | - | - | Window ID, got by Electron API BrowserWindow.getNativeWindowHandle(), to preview camera. |
rect | - | - | The position area used to display camera video in the window. |
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();deviceManager.stopCameraDeviceTest();
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();deviceManager.setCameraTestRenderMirror(true);
Parameter | Type | Validation | Default value | Description |
mirror | boolean | - | - | Whether to enable mirroring |
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();deviceManager.setCameraTestDeviceId('Your camera ID');
Parameter | Type | Validation | Default value | Description |
cameraId | string | - | - | Camera device ID |
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();deviceManager.setCameraTestResolution(1920, 1080);
Parameter | Type | Validation | Default value | Description |
width | number | - | - | Camera capture width |
height | number | - | - | Camera capture height |
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();deviceManager.setCameraTestVideoPluginPath('Your library path');
Parameter | Type | Validation | Default value | Description |
path | string | - | - | Video preprocess dynamic library path |
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();deviceManager.setCameraTestVideoPluginParameter('{}'); // JSON string
Parameter | Type | Validation | Default value | Description |
params | string | - | - | JSON parameter string |
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager, TUIMediaDeviceType, TUIMediaDeviceState} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();const onDeviceChanged = (deviceId: string, type: TUIMediaDeviceType, state: TUIMediaDeviceState) => {// ...}deviceManager.on(TUIMediaDeviceEventType.onDeviceChanged, onDeviceChanged);
Parameter | Type | Validation | Default value | Description |
eventName | - | - | Event name | |
func | (...args: any[]) => void | - | - | Event handler function |
Promise
<void
>import TUIRoomEngine, {TUIDeviceManager, TUIMediaDeviceType, TUIMediaDeviceState} from '@tencentcloud/tuiroom-engine-electron';const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();const onDeviceChanged = (deviceId: string, type: TUIMediaDeviceType, state: TUIMediaDeviceState) => {// ...}deviceManager.off(TUIMediaDeviceEventType.onDeviceChanged, onDeviceChanged);
Parameter | Type | Validation | Default value | Description |
eventName | - | - | Event name | |
func | (...args: any[]) => void | - | - | Event handler function |
Promise
<void
>Field | Type | Description |
mode | Camera capture mode | |
width | number | Camera capture width |
height | number | Camera capture height |
Field | Type | Description |
deviceId | string | Device ID |
deviceName | string | Device Name |
deviceProperties | Record<string, any> | Device properties. Only cameras supported, including the capture resolutions supported by the camera. |
Field | Type | Description |
left | number | Left line coordinate |
top | number | Top line coordinate |
right | number | Right line coordinate |
bottom | number | Bottom line coordinate |
Enumeration item | Type | Description |
kCameraResolutionStrategyAuto | number | Automatically adjust capture parameters. The SDK selects appropriate camera output parameters based on the actual performance of the capture device and network conditions, maintaining a balance between device performance and video preview quality. |
kCameraResolutionStrategyPerformance | number | Priority on device performance. The SDK selects the closest camera output parameters based on the user's settings for encoder resolution and frame rate, thereby ensuring device performance. |
kCameraResolutionStrategyHighQuality | number | Priority on video preview quality. The SDK selects higher camera output parameters to improve the quality of the preview video. In this case, more CPU and memory will be consumed for video preprocessing. |
kCameraCaptureManual | number | Allows users to set the local camera capture video width and height. |
Enumeration item | Type | Value | Description |
string | 'onDeviceChanged' | Device state change event name |
Enumeration item | Type | Value | Description |
kMediaDeviceStateAdd | number | 0 | New device added |
kMediaDeviceStateRemove | number | 1 | Device removed |
kMediaDeviceStateActive | number | 2 | Device activated |
kMediaDefaultDeviceChanged | number | 3 | System default device changed |
Enumeration item | Type | Value | Description |
kMediaDeviceTypeUnknown | number | -1 | Unkonw media |
kMediaDeviceTypeAudioInput | number | 0 | Microphone |
kMediaDeviceTypeAudioOutput | number | 1 | Speaker |
kMediaDeviceTypeVideoCamera | number | 2 | Camera |
Paramter | Type | Description |
deviceID | string | Device ID |
type | Device type | |
state | Device state |
Was this page helpful?