RemoteTrack

更新时间: 2026-01-18 18:57:51

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

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

getMediaStreamTrack()

Gets the media track.

3.0.0

getTrackId()

Gets the stream track ID.

3.0.0

play()

Plays the media track on the page.

3.0.0

replaceTrack()

Replaces the audio or video track.

3.0.0

stop()

Stops playback.

3.0.0

off()

Unregisters a listener for a specific event.

3.0.0

on()

Registers a listener for a specific event and sets a callback function.

3.0.0

once()

Registers a one-time listener for a specific event. The listener is removed after the callback function is triggered.

3.0.0

removeAllListeners()

Unregisters listeners for a specific event or for all events on the object.

3.0.0

Events

Event

Event parameters

Description

Minimum supported version

"first-frame-decoded"

() => 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

VideoPlayerConfig

(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

上一篇: MicrophoneAudioTrack 下一篇: RemoteVideoTrack
阿里云首页 音视频通信 相关技术圈