RemoteTrack
This is the base class for remote track objects and provides common methods for RemoteAudioTrack and RemoteVideoTrack.
Properties
Property | Type | Description | Minimum supported version |
isPlaying | boolean | Indicates whether the media track is playing. | 3.0.0 |
trackMediaType | The type of the media track. | 3.0.0 | |
userId | string | The user ID of the remote user. | 3.0.0 |
Methods
Method name | Description | Minimum supported version |
Gets the media track. | 3.0.0 | |
Gets the stream track ID. | 3.0.0 | |
Plays the media track on the page. | 3.0.0 | |
Replaces the audio or video track. | 3.0.0 | |
Stops playback. | 3.0.0 | |
Unregisters a listener for a specific event. | 3.0.0 | |
Registers a listener for a specific event and sets a callback function. | 3.0.0 | |
Registers a one-time listener for a specific event. The listener is removed after the callback function is triggered. | 3.0.0 | |
Unregisters listeners for a specific event or for all events on the object. | 3.0.0 |
Events
Event | Event parameters | Description | Minimum supported version |
() => void | Triggered when the first frame of audio or video is decoded. | 3.0.0 |
Method details
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(element?: string | HTMLElement, config?: VideoPlayerConfig): void;
Parameters
Parameter | Type | Description |
element | string | HTMLElement | (Optional) Specifies a Document Object Model (DOM) element. The software development kit (SDK) creates a video element under this DOM element to play the video track. Two types are supported: - string: The ID of the DOM element. - HTMLElement: You can pass a DOM element directly. |
config | (Optional) Video media playback parameters. |
Returns
void
replaceTrack()
Replaces the audio or video track.
Type signature
replaceTrack(track: MediaStreamTrack, stopOldTrack?: boolean): void;
Parameter | Type | Description |
track | MediaStreamTrack | The audio or video track. |
stopOldTrack | boolean | (Optional) Specifies whether to stop the previous track. |
Back
void
stop()
Stops playback.
Type signature
stop(): void;
Returns
void
on()
Registers a listener 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 that is triggered when the event occurs. |
Returns
void
off()
Unregisters a listener 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 that is triggered when the event occurs. |
Returns
void
once()
Registers a one-time listener for a specific event. 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 specific event to listen for. |
fn | Function | The callback function that is triggered when the event occurs. |
Returns
void
removeAllListeners()
Unregisters listeners for a specific event or for all events on the object.
Type signature
removeAllListeners(event?: string): void;
Parameters
Parameter | Type | Description |
event | string | (Optional) If you specify an event, the corresponding listener callback functions are cleared. If you do not specify this parameter, all event listeners for the object are cleared. |
Returns
void
Event List
"first-frame-decoded"
Triggered when the first frame of audio or video is decoded.
Type signature
'first-frame-decoded': () => void