API list
API | Description | Minimum supported version |
Checks the compatibility of the DingRTC Web software development kit (SDK) with the current browser. | 3.0.0 | |
Creates a video track from the video captured by the camera. | 3.0.0 | |
Creates a client instance for RTC communication. | 3.0.0 | |
Creates a custom audio track. Use this method to transform a MediaStreamTrack that you maintain into an audio track for the SDK. | 3.0.0 | |
Creates a custom video track. Use this method to transform a MediaStreamTrack that you maintain into a video track for the SDK. | 3.0.0 | |
Creates a microphone audio track and a camera video track at the same time. It creates an audio track from the microphone and a video track from the camera. | 3.0.0 | |
Creates an audio track from the audio captured by the microphone. | 3.0.0 | |
Creates a video track for screen sharing. | 3.0.0 | |
Creates an array of video and audio tracks for screen sharing. The browser provides an option to share audio. If the user does not select this option, the result does not include an audio track. | 3.9.0 | |
Enumerates the available video input devices, such as cameras. On a successful call, the SDK returns the available video input devices as MediaDeviceInfo objects. | 3.0.0 | |
Enumerates the available media input and output devices, such as microphones, cameras, and headsets. On a successful call, the SDK returns the available media devices as MediaDeviceInfo objects. | 3.0.0 | |
Enumerates the available audio input devices, such as microphones. On a successful call, the SDK returns the available audio input devices as MediaDeviceInfo objects. | 3.0.0 | |
Enumerates the available audio playback devices, such as speakers. On a successful call, the SDK returns the available audio playback devices as MediaDeviceInfo objects. | 3.0.0 | |
Configures the SDK integration options. | 3.0.0 | |
Sets the log output level for the SDK. | 3.0.0 | |
Gets the encoding and decoding formats that the SDK supports for the current browser. | 3.0.0 | |
Removes a listener callback function for a specific event. | 3.0.0 | |
Listens for a specific event and sets a callback function. | 3.0.0 | |
Listens for a specific event once. The callback function is removed after it is triggered. | 3.0.0 | |
Removes the listener callbacks for a specific event or all events on the object. | 3.0.0 |
Event list
DingRTC global events
Event | Callback type | Description | Minimum supported version |
(track:LocalTrack|RemoteTrack) => void | Audio autoplay failed. | 3.0.0 | |
(info:Data type) => void | The state of the video capture device changed. | 3.0.0 | |
(info:Data type) => void | The state of the audio capture device changed. | 3.0.0 | |
(info:Data type) => void | The audio playback device changed. | 3.0.0 |
API details
createClient()
Creates a client instance for real-time communication (RTC).
Type signature
createClient(): DingRTCClient;
Returns
checkSystemRequirements()
Call this method before you create a client instance with createClient.
Checks the compatibility of the DingRTC Web SDK with the current browser.
Type signature
checkSystemRequirements(): boolean;Returns
Indicates whether the current browser is supported.
getCameras()
Enumerates the available video input devices, such as cameras. If the call is successful, the SDK returns the available video input devices as an array of MediaDeviceInfo objects.
Type signature
getCameras(): Promise<MediaDeviceInfo[]>;
Back
Returns a MediaDeviceInfo[] array of all available local video input devices.
getPlaybackDevices()
Enumerates the available audio playback devices, such as speakers. If the call is successful, the SDK returns the available audio playback devices as an array of MediaDeviceInfo objects.
Type signature
getPlaybackDevices(): Promise<MediaDeviceInfo[]>;
Returns
Returns a MediaDeviceInfo[] array of all available local audio playback devices.
getDevices()
Enumerates the available media input and output devices, such as microphones, cameras, and headsets. If the call is successful, the SDK returns the available media devices as an array of MediaDeviceInfo objects.
Type signature
getDevices(): Promise<MediaDeviceInfo[]>;
Returns
Returns a MediaDeviceInfo[] array of all available local media devices.
getMicrophones()
Enumerates the available audio input devices, such as microphones. If the call is successful, the SDK returns the available audio input devices as an array of MediaDeviceInfo objects.
Type signature
getMicrophones(): Promise<MediaDeviceInfo[]>;
Back
Returns a MediaDeviceInfo[] array of all available local audio input devices.
createCameraVideoTrack()
Creates a video track from the video captured by the camera.
Type signature
createCameraVideoTrack(config: CameraVideoTrackConfig): Promise<CameraVideoTrack>;
Parameter | Type | Description |
config | The configuration for video capture, including the capture device and encoding settings. |
Returns
Promise<CameraVideoTrack>
Camera track
createMicrophoneAudioTrack()
Creates an audio track from the audio captured by the microphone.
Type signature
createMicrophoneAudioTrack(config?: MicrophoneAudioTrackConfig): Promise<MicrophoneAudioTrack>;
Parameters
Parameter | Type | Description |
config | (Optional) The configuration for audio capture from the microphone, including the capture device and audio encoding settings. |
Returns
Promise<MicrophoneAudioTrack>
Audio track
createCustomVideoTrack()
Creates a custom video track. You can use this method to create a video track for the SDK from a MediaStreamTrack object.
Type signature
createCustomVideoTrack(config: CustomVideoTrackConfig): Promise<LocalVideoTrack>;
Parameters
Parameter | Type | Description |
config | The configuration for the custom video track. |
Returns
Promise<LocalVideoTrack>
The created custom video track.
createCustomAudioTrack()
Creates a custom audio track. You can use this method to create an audio track for the SDK from a MediaStreamTrack object.
Type signature
createCustomAudioTrack(config: CustomAudioTrackConfig): Promise<LocalAudioTrack>;
Parameters
Parameter | Type | Description |
config | The configuration for the custom audio. |
Returns
Promise<LocalAudioTrack>
The created custom audio track.
createScreenVideoTrack()
Creates a video track for screen sharing.
Type signature
createScreenVideoTrack(config: ScreenVideoTrackConfig): Promise<LocalVideoTrack[]>;
Parameters
Parameter | Type | Description |
config | The video configuration for screen sharing, including encoding and capture settings. |
Returns
Promise<LocalVideoTrack[]>
Returns an array with one element: the video track for screen sharing.
createScreenVideoAndAudioTrack()
You can create a video track for screen sharing.
Type signature
createScreenVideoAndAudioTrack(config: ScreenVideoTrackConfig): Promise<LocalTrack[]>;
Parameters
Parameter | Type | Description |
config | The video configuration for screen sharing, including encoding and capture settings. |
Back
Promise<LocalTrack[]>
Returns an array. The first element is the video track for screen sharing. If the user chooses to share audio in the browser, the second element is the audio track for screen sharing. Otherwise, the array contains only the video track.
createMicrophoneAndCameraTracks()
Simultaneously creates an audio track from the microphone and a video track from the camera.
Type signature
createMicrophoneAndCameraTracks(videoConfig: CameraVideoTrackConfig, audioConfig: MicrophoneAudioTrackConfig): Promise<(CameraVideoTrack | MicrophoneAudioTrack)[]>;
Parameters
Parameter | Type | Description |
videoConfig | The audio capture configuration includes the capture device and the encoding configuration. | |
audioConfig | The video capture configuration, including the capture device and encoding configuration. |
Returns
Promise<(CameraVideoTrack|MicrophoneAudioTrack)[]>
The created audio and video tracks.
setClientConfig()
Configures the SDK integration options.
Type signature:
setClientConfig(config: GlobalClientConfigInfo): void;
Parameters
Parameter | Type | Description |
config | Configuration parameters. |
Returns:
void
setLogLevel()
Sets the log output level for the SDK.
Type signature
setLogLevel(level: LogLevel): void;
Parameters
Parameter | Type | Description |
level | The log output level. |
Returns
void
getSupportedCodec()
Retrieves the encoding and decoding formats that the DingRTC Web SDK supports for the current browser. H.264 on some Huawei phones has interoperability issues with other platforms. This will be optimized in a future release.
Type signature:
getSupportedCodec(): Promise<{
audio: string[];
video: string[];
}>;
Returns:
Promise<{ audio: string[]; video: string[]; }>
The supported audio and video encoding and decoding formats.
on()
Listens for a specific event and sets a callback function.
Type signature
on(event: string, fn: Function): void;
Parameters
Parameter | Type | Description |
event | string | The specific event to listen for. |
fn | Function | The callback function to trigger when the event occurs. |
Returns
void
off()
Removes a listener callback function for a specific event.
Type signature
off(event: string, fn: Function): void;
Parameters
Parameter | Type | Description |
event | string | The specific event to listen for. |
fn | Function | The callback function to trigger when the event occurs. |
Returns
void
once()
Listens for a specific event once. The callback function is removed after it is triggered.
Type signature
once(event: string, fn: Function): void;
Parameters
Parameter | Type | Description |
event | string | The specific event to listen for. |
fn | Function | The callback function to trigger when the event occurs. |
Returns
void
removeAllListeners()
Removes the listener callbacks for a specific event or all events on the object.
Type signature
removeAllListeners(event?: string): void;
Parameters
Parameter | Type | Description |
event | string | (Optional) If a specific event is set, its listener callback functions are cleared. If this parameter is not provided, the listener functions for all events on the object are cleared. |
Returns
void
Event details
"autoplay-failed"
Audio autoplay failed
Type signature
'autoplay-failed': (track: LocalTrack|RemoteTrack) => void;
Example
DingRTC.on('autoplay-failed', (track) => {
console.log(track);
});"camera-changed"
Changes in video capture device status
Type signature
'camera-changed': (info: DeviceInfo) => void;
Example
DingRTC.on('camera-changed', (info) => {
console.log(info);
})"microphone-changed"
Audio capture device state changes
Type signature
'microphone-changed': (info: DeviceInfo) => void;
Example
DingRTC.on('microphone-changed', (info) => {
console.log(info);
})
"playback-device-changed"
Changing the audio playback device
Type signature
'playback-device-changed': (info: DeviceInfo) => void;
Example
DingRTC.on('playback-device-changed', (info) => {
console.log(info);
});