This is a remote audio track. You can obtain it from the DingRTCRemoteUser.audioTrack object after calling subscribe.
Inherits from: RemoteTrack
Properties
Property | Type | Description | Minimum supported version |
isPlaying | boolean | Indicates whether the media track is playing. | 3.0.0 |
trackMediaType | The media track type. | 3.0.0 | |
userId | string | The UID of the remote user. | 3.0.0 |
API List
Interface | Description | Minimum supported version |
Gets the current playback volume. | 3.0.0 | |
Gets the volume level of the remote audio track. | 3.0.0 | |
Plays the remote audio track. | 3.0.0 | |
Sets the audio output device. | 3.0.0 | |
Sets the playback volume. | 3.0.0 | |
Gets the media track. | 3.0.0 | |
Gets the stream track ID. | 3.0.0 | |
Replaces the media track. | 3.0.0 | |
Stops playback. | 3.0.0 | |
Removes the callback function for a specified event listener. | 3.0.0 | |
Adds a listener for a specified event and sets a callback function. | 3.0.0 | |
Listens for a specified event once. The listener is removed after the callback function is triggered. | 3.0.0 | |
Removes the listeners for a specified event or all events of the object. | 3.0.0 |
API details
getVolume()
Retrieves the current playback volume.
Type signature
getVolume(): number;
Returns
number
The current playback volume.
getVolumeLevel()
Retrieves the volume level of the remote audio track.
Type Signature
getVolumeLevel(): number;
Returns
number
play()
Plays the remote audio track.
Type Signature
play(): void;
Back
void
setSpeaker()
Sets the audio output device.
Type Signature
setSpeaker(deviceId: string): Promise<void>;
Parameters
Parameter | Type | Description |
deviceId | string | The device ID. Obtain it using getPlaybackDevices(). |
Back
Promise<void>
setVolume()
Sets the playback volume.
Type signature
setVolume(volume: number): void;
Parameters
Parameter | Type | Description |
volume | number | The volume level. The value ranges from 0 to 1. A value of 0 means mute, and a value of 1 means the original volume. |
Returns
void
getMediaStreamTrack()
Retrieves the media track.
Type Signature
getMediaStreamTrack(): MediaStreamTrack;
Returns
MediaStreamTrack
The media track.
getTrackId()
Retrieves the stream track ID.
Type Signature
getTrackId(): string;
Returns
string
The stream track ID.
play()
Plays the media track on the page.
Type signature
play(): void;
Returns
void
replaceTrack()
Replaces the media track.
Signature
replaceTrack(track: MediaStreamTrack, stopOldTrack?: boolean): void;
Parameter | Type | Description |
track | MediaStreamTrack | The media track. |
stopOldTrack | boolean | (Optional) Specifies whether to stop the previous track. |
Returns
void
stop()
Stops playback.
Type Signature
stop(): void;
Returns
void
on()
Adds a listener for a specified event and sets a callback function.
Type signature
on(event: string, fn: Function): void;
Parameters
Parameter | Type | Description |
event | string | The event to listen for. |
fn | Function | The callback function that is triggered when the event occurs. |
Returns
void
off()
Removes the callback function for a specified event listener.
Type signature
off(event: string, fn: Function): void;
Parameters
Parameter | Type | Description |
event | string | The event to listen for. |
fn | Function | The callback function that is triggered when the event occurs. |
Returns
void
once()
Listens for a specified event once. The listener is removed after the callback function is triggered.
Type signature
once(event: string, fn: Function): void;
Parameters
Parameter | Type | Description |
event | string | The event to listen for. |
fn | Function | The callback function that is triggered when the event occurs. |
Returns
void
removeAllListeners()
Removes the listeners for a specified event or all events of the object.
Type Signature
removeAllListeners(event?: string): void;
Parameters
Parameter | Type | Description |
event | string | (Optional) If you specify an event, the corresponding listeners are removed. If you do not specify this parameter, all listeners for all events of the object are removed. |
Returns
void