TUIRoomDeviceManager
TUIRoomDeviceManager API is the device interface of the audio and video call component.
TUIRoomDeviceManager
Function API | Description |
Obtaining the Device List | |
Set current device usage | |
Retrieve currently used device information | |
Start camera test | |
Stop camera test | |
Start mic test | |
Stop mic test | |
Start speaker test | |
Stop speaker test | |
Whether it is the front camera (only for mobile devices) | |
Switch front and rear cameras. This API is only applicable to mobile browsers (only for mobile devices). | |
Query whether to support automatic face position recognition (only for mobile devices) | |
Turn flash on/off, that is, flashlight mode (only for mobile devices) | |
Set audio routing (only for mobile devices) | |
TUIRoomDeviceManagerEvents
Event API | Description |
change event callback | |
Microphone Test Volume Callback |
Type Definition
Type | Description |
Device information |
Enum Definition
Type | Description |
media device type | |
audio playback mode |
Function API Description
getDevicesList
Obtaining the Device List
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();const cameraList = await deviceManager.getDeviceList({ type: TUIMediaDeviceType.kMediaDeviceVideoCamera })const micList = await deviceManager.getDeviceList({ type: TUIMediaDeviceType.kMediaDeviceTypeAudioInput });const speakerList = await deviceManager.getDeviceList({ type: TUIMediaDeviceType.kMediaDeviceTypeAudioOutput });
Parameter list
Parameter | Type | Description |
type | Device Type |
setCurrentDevice
Set current device usage
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();deviceManager.setCurrentDevice({type: TUIMediaDeviceType.kMediaDeviceTypeAudioInput,deviceId: '',});deviceManager.setCurrentDevice({type: TUIMediaDeviceType.kMediaDeviceTypeAudioOutput,deviceId: '',});deviceManager.setCurrentDevice({type: TUIMediaDeviceType.kMediaDeviceVideoCamera,deviceId: '',});
Parameter list
Parameter | Type | Description |
type | Device Type | |
deviceId | string | Device ID. |
Returns {void}
getCurrentDevice
Retrieve currently used device information
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();const camera = deviceManager.getCurrentDevice({type: TUIMediaDeviceType.kMediaDeviceVideoCamera});const mic = deviceManager.getCurrentDevice({type: TUIMediaDeviceType.kMediaDeviceTypeAudioInput});const speaker = deviceManager.getCurrentDevice({type: TUIMediaDeviceType.kMediaDeviceTypeAudioOutput});
Parameter list
Parameter | Type | Description |
type | Device Type |
startCameraDeviceTest
Start camera test
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();await deviceManager.startCameraDeviceTest({ view: 'test-preview' });
Parameter list
Parameter | Type | Description |
view | string | Display the video area for camera testing. The passed-in view is the ID of the div element hosting the video preview. |
Returns {Promise<void>}
stopCameraDeviceTest
Stop camera test
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();await deviceManager.stopCameraDeviceTest();
Returns {Promise<void>}
startMicDeviceTest
Start mic test
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();await deviceManager.startMicDeviceTest({ interval: 200 });
Parameter list
Parameter | Type | Description |
interval | number | Callback time of microphone volume (unit: ms) |
Returns {Promise<void>}
stopMicDeviceTest
Stop mic test
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();await deviceManager.stopMicDeviceTest();
Returns {Promise<void>}
startSpeakerDeviceTest
Start speaker test
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();await deviceManager.startSpeakerDeviceTest({ filePath: '' });
Parameter list
Parameter | Type | Description |
filePath | string | Path of the speaker test audio file |
Returns {Promise<void>}
stopSpeakerDeviceTest
Stop speaker test
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();await deviceManager.stopSpeakerDeviceTest();
Returns {Promise<void>}
isFrontCamera
Whether it is the front camera (only for mobile devices)
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();const isFrontCamera = deviceManager.isFrontCamera();
Returns {boolean}
switchCamera
Switch front and rear cameras. This API is only applicable to mobile browsers (only for mobile devices).
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();await deviceManager.switchCamera({ isFrontCamera: true });
Parameter list
Parameter | Type | Description |
isFrontCamera | boolean | Whether it is the front camera |
Returns {Void}
isAutoFocusEnabled
Query whether to support automatic face position recognition (only for mobile devices)
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();const isAutoFocusEnabled = deviceManager.isAutoFocusEnabled();
Returns {boolean}
enableCameraTorch
Turn flash on/off, that is, flashlight mode (only for mobile devices)
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();await deviceManager.enableCameraTorch({ enabled: true });
Parameter list
Parameter | Type | Description |
enabled | boolean | whether...is enabled |
Returns {Void}
setAudioRoute
Set audio routing (only for mobile devices)
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();await deviceManager.setAudioRoute({ route: TUIAudioRoute.kAudioRouteSpeakerphone});
Parameter list
Parameter | Type | Description |
route | Audio routing mode |
Returns {Void}
on
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();const callback = ({ deviceId, type, state }) => {console.log('deviceManager.onDeviceChange', deviceId, type, state);};deviceManager.on(TUIRoomDeviceMangerEvents.onDeviceChange, callback);
Parameter list
Parameter | Type | Description |
event | Event of device manager | |
function | (...args: any[]) => void; | Listening for events function |
Returns {Void}
off
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();const callback = ({ deviceId, type, state }) => {console.log('deviceManager.onDeviceChange', deviceId, type, state);};deviceManager.off(TUIRoomDeviceMangerEvents.onDeviceChange, callback);
Parameter list
Parameter | Type | Description |
event | Event of device manager | |
function | (...args: any[]) => void; | Listening for events function |
Returns {Void}
Event API Detail
onDeviceChanged
Change event
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();deviceManager.on(TUIRoomDeviceMangerEvents.onDeviceChange, ({ deviceId, type, state }) => {console.log('deviceManager.onDeviceChange', deviceId, type, state);});
The parameters are listed in the table below:
Parameter | Type | Description |
deviceId | string | device ID |
type | TRTCDeviceType | Device Type |
state | TRTCDeviceState | Device status change |
onTestMicVolume
Microphone Test Volume Event
const roomEngine = new TUIRoomEngine();const deviceManager = roomEngine.getDeviceManager();deviceManager.on(TUIRoomDeviceMangerEvents.onTestMicVolume, ({ volume }) => {console.log('deviceManager.onTestMicVolume', volume);});
The parameters are listed in the table below:
Parameter | Type | Description |
volume | number | Microphone Test Volume (0-100) |
Defining Details
TUIDeviceInfo
Device information
Name | Type | Description |
deviceId | string | Device ID |
deviceName | string | device name |
deviceProperties | object | device properties |
Enum Definition Details
TUIMediaDeviceType
Name | Type | Description |
kMediaDeviceTypeUnknown | number | unknown type |
kMediaDeviceTypeAudioInput | number | audio input device |
kMediaDeviceTypeAudioOutput | number | audio output device |
kMediaDeviceTypeVideoCamera | number | camera |
TUIAudioRoute
sound playback mode
Name | Type | Description |
kAudioRouteSpeakerphone | number | Play music out loud (hands-free) via the speaker located at the bottom of the mobile phone, which delivers louder sound suitable for playback. |
kAudioRouteEarpiece | number | Use receiver playback, the receiver is located at the top of the mobile phone, the sound is small, suitable for call scenarios requiring privacy protection. |