Local Device Management
Local Device Management
DeviceMgr
- Return a device management class object
- Method example
1 |
|
getDevices
- This method enumerates the cameras, microphones, and speakers in the system
Parameter name | Required | Type | Description |
---|---|---|---|
callback | Yes | Function | If the method is called successfully,the callback parameter object will include the devices object containing system device information and the useDevices object containing information about the devices currently in use by the system. If the call fails, the device information in the devices and useDevices objects will be empty |
- The devices object contains information objects for cameras (videoinput), microphones (audioinput), and speakers (audiooutput). Each device object includes three properties:
Parameter name | Type | Description |
---|---|---|
deviceId | String | The unique device ID for that particular device |
label | String | A label used to distinguish devices. If the user does not have permission to access the camera and microphone, the label will be named in a specific format with an index |
kind | String | Device type, which includes three types based on the selected audio and video devices: videoinput, audioinput, and audiooutput |
- The userDevices object contains the device IDs of the cameras (videoinput), microphones (audioinput), and speakers (audiooutput) that the system is currently using
- Method example
1 2 3 4 5 6 7 |
|
Parameter name | Required | Type | Description |
---|---|---|---|
deviceIdMap | Yes | Object | An object containing the device ID. The device ID is obtained through the getDevices method |
onFailure | No | Function | Failure callback |
onSuccess | No | Function | Success callback |
- Method example
1 2 3 4 5 6 7 |
|
setDevices
- This method sets the cameras, microphones, and speakers that the system will use
- When setDevices sets videoinput in multi-video mode, it refers to setting the primary camera. Setting the primary camera means associating the audio with the primary camera. Since there is no switching issue for the primary camera in multi-video mode, the videoinput switched by this interface is the primary camera (i.e., the camera associated with the audio)
Parameter name | Required | Type | Description |
---|---|---|---|
deviceIdMap | Yes | Object | An object containing the device ID. The device ID is obtained through the getDevices method |
onFailure | No | Function | Failure callback |
onSuccess | No | Function | Success callback |
- Method example
1 2 3 4 5 6 7 8 9 10 |
|
getCameras
- This method enumerates the camera devices in the system
Parameter name | Required | Type | Description |
---|---|---|---|
callback | Yes | Function | If the method call is successful, the callback parameter will be an array containing information about the system's camera objects. If the call fails or no devices are available, an empty array will be returned |
- Method example
1 2 3 |
|
setCamera
- This method sets the camera devices in the system
Parameter name | Required | Type | Description |
---|---|---|---|
deviceId | Yes | String | Camera device ID |
onFailure | No | Function | Failure callback |
isForce | No | Boolean | Whether to force the setting,The default value is false |
onSuccess | No | Function | Success callback |
- Method example
1 2 3 |
|
getMicrophones
- This method enumerates the microphone devices in the system
Parameter name | Required | Type | Description |
---|---|---|---|
callback | Yes | Function | If the method call is successful, the callback parameter will be an array containing information about the system's microphone objects. If the call fails or no devices are available, an empty array will be returned |
- Method example
1 2 3 |
|
setMicrophone
- This method sets the microphone device to be used by the system
Parameter name | Required | Type | Description |
---|---|---|---|
deviceId | Yes | String | Microphone device ID |
onFailure | No | Function | Failure callback |
onSuccess | No | Function | Success callback |
- Method example
1 2 3 |
|
getSpeakers
- This method enumerates the speaker devices in the system
Parameter name | Required | Type | Description |
---|---|---|---|
callback | Yes | Function | If the method call is successful, the callback parameter will be an array containing information about the system's speaker objects. If the call fails or no devices are available, an empty array will be returned |
- Method example
1 2 3 |
|
setSpeaker
- This method sets the speaker device to be used by the system
Parameter name | Required | Type | Description |
---|---|---|---|
deviceId | Yes | String | Speaker device ID |
onFailure | No | Function | Failure callback |
onSuccess | No | Function | Success callback |
- Method example
1 2 3 |
|
startVideoTest
- This method begins to check whether the camera is available
- If a camera is currently being tested, calling startVideoTest will automatically stop the ongoing test. However, to stop the last camera test, the stopVideoTest method must be called
Parameter name | Required | Type | Description |
---|---|---|---|
deviceId | Yes | String | The ID of the device to be tested. The device ID is obtained through the getDevices method |
elementId | Yes | String | The ID of the DOM element. This DOM element is used to contain the video window corresponding to the camera |
options | No | Object | Playback configuration options, which contain properties as described below |
onSuccess | No | Function | The callback function after the video is in the canplay state |
onFailure | No | Function | Method invocation/Video failure callback |
- options
Parameter name | Type | Description |
---|---|---|
mirror | Boolean | The video is displayed in mirror mode, default is false |
loader | Boolean | Indicates whether to display the "loading" style when video data is not loaded, default is true |
mode | Number | Used to indicate the video display mode (whether to crop), possible values can be found in the video display mode section, default is TK_VIDEO_MODE.APECT_RATIO_CONTAIN |
- Method example
1 2 3 4 5 |
|
stopVideoTest
- This method stops the camera detection
- To avoid potential device occupation issues and other problems that may arise when entering the classroom, it is necessary to promptly disable the detection.
Parameter name | Required | Type | Description |
---|---|---|---|
deviceId | No | String | To stop the detection of a specific device, provide the corresponding device ID used when starting the detection. If no device ID is provided, it will default to stopping all detections initiated by calling startVideoTest for the specified deviceid |
onSuccess | No | Function | Success callback |
onFailure | No | Function | Failure callback |
- Method example
1 2 3 |
|
startMicrophoneTest
- This method starts to detect whether the microphone is available
- If a microphone is currently being tested, calling startMicrophoneTest will automatically stop the ongoing detection process. However, to stop the last microphone detection, the stopMicrophoneTest method must be called
Parameter name | Required | Type | Description |
---|---|---|---|
deviceId | Yes | String | The device ID to be detected. The device ID is obtained through the getDevices method |
elementId | Yes | String | The DOM element ID. This DOM element is used to contain the player for playing the microphone audio |
onSuccess | No | Function | The success callback for the method call, carrying the current volume value captured by the microphone |
onFailure | No | Function | The failure callback for the method call |
- Method example
1 2 3 4 5 6 7 8 9 10 11 |
|
stopMicrophoneTest
- This method stops the microphone detection
Parameter name | Required | Type | Description |
---|---|---|---|
onSuccess | No | Function | Success callback |
- Method example
1 2 |
|
startSpeakerTest
- This method starts to detect whether the speaker is available
- If a speaker is currently being tested, calling startSpeakerTest will automatically stop the ongoing detection process. However, to stop the last speaker detection, the stopSpeakerTest method must be
Parameter name | Required | Type | Description |
---|---|---|---|
deviceId | Yes | String | The device ID to be detected. The device ID is obtained through the getDevices method |
audioUrl | Yes | String | The absolute URL of the audio file. It is recommended to use a file in WAV format |
onFailure | No | Function | Failure callback |
onSuccess | No | Function | The success callback, which will be triggered periodically to return the current volume of the audio media file |
- Method example
1 2 3 4 |
|
stopSpeakerTest
- This method stops the speaker detection
Parameter name | Required | Type | Description |
---|---|---|---|
onSuccess | No | Function | Success callback |
- Method example
1 2 |
|
startNetworkTest
- This method starts the network quality detection
- After the API call is made, network speed testing will be performed in a polling manner, and data will be continuously returned through the onSuccess callback
Parameter name | Required | Type | Description |
---|---|---|---|
onSuccess | Yes | Function | The success callback. The first parameter of the callback indicates the network quality (possible values can be found in the Network Quality section); the second parameter represents the latency (measured in milliseconds); the third parameter indicates the detailed uplink and downlink network quality (explained as follows) |
onFailure | No | Function | Failure callback |
- networkQualityDetail
Parameter name | Type | Description |
---|---|---|
downlinkDelayLevel | Number | Downlink network quality (possible values can be found in the Network Quality section) |
uplinkDelayLevel | Number | Uplink network quality (possible values can be found in the Network Quality section) |
downlinkDelay | Number | Downlink network latency (measured in milliseconds) |
uplinkDelay | Number | Uplink network latency (measured in milliseconds) |
- Method example
1 2 |
|
stopNetworkTest
- This method stops the network quality detection
- Method example
1 |
|
registerDeviceChangeListener
- This method adds a listener for device changes (plugging in or unplugging)
- Only one listener can be added. If added repeatedly, the previously added listener will become invalid
- After testing, it has been found that the behavior of an extremely small number of devices is abnormal. The callback function will be triggered continuously even without any plug-in or plug-out operations on the devices
Parameter name | Required | Type | Description |
---|---|---|---|
listener | Yes | Function | The callback function, which will be called when a device change occurs. The parameters of the callback are described as follows |
Parameter name | Type | Description |
---|---|---|
changed | Object | The information of the changed device. Example: {videoinput:[{kind:’videoinput’,label:’Video device label’,deviceId:’Video device ID’}]} |
type | Number | The type of change, with possible values being:(Device added: TK.DEVICE_STATE.DEVICE_ADD)(Device removed: TK.DEVICE_STATE.DEVICE_REMOVE) |
- Method example
1 2 3 4 5 6 |
|
1 |
|
getAudioMediaStream
- This method retrieves the raw audio data of the specified user
- This interface can only be used to obtain the audio data of users who have already joined the stage. When obtaining your own audio data, you do not need to be on stage
- The audio data obtained through the success callback is in the format of 16-bit, 16000 Hz, mono-channel arrayBuffer data
Parameter name | Required | Type | Description |
---|---|---|---|
userid | Yes | String | User id |
option | No | Object | Optional configuration. Currently, only user audio data is supported, and no values should be passed |
onSuccess | Yes | Function | Success callback |
onFailure | No | Function | Failure callback |
- Method example
1 2 |
|