RemoteTrack

更新时间:
复制 MD 格式

This is the base class for remote track objects. It provides common methods for the RemoteAudioTrack and RemoteVideoTrack classes.

Property list

Property

Type

Description

Minimum supported version

isPlaying

boolean

Indicates if the media track is playing.

1.0.0

Method list

Interface Name

Description

Minimum supported version

getTrackId()

Gets the stream track ID.

1.0.0

getUserId()

Gets the user ID.

1.0.0

off()

Unregisters a listener for a specified event.

1.0.0

on()

Registers a listener for a specified event.

1.0.0

once()

Registers a one-time listener for a specified event. The listener is removed after the event is triggered.

1.0.0

removeAllListeners()

Unregisters all listeners for a specified event or for all events.

1.0.0

Event list

Event

Event parameters

Description

Minimum supported version

"first-frame-decoded"

() => void

Triggered when the first audio or video frame is decoded.

3.0.0

Method details

getUserId()

Retrieves the user ID.

Type signature

getUserId(): string

Returns

string

The user ID.

getTrackId()

Retrieves the stream track ID.

Type signature

getTrackId(): string;

Back

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 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: Pass a DOM element directly.

config

VideoPlayerConfig

(Optional) The video media playback parameters.

Returns

void

stop()

Stops playback.

Type signature

stop(): void;

Returns

void

on()

Registers a listener for a specified event.

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

Unregisters a listener for a specified event.

Type signature

off(event: string, fn: Function): void;

Parameters

Parameter

Type

Description

event

string

The specified event to listen for.

fn

Function

The callback function that runs when the event is triggered.

Returns

void

once()

Registers a one-time listener for a specified event. The listener is removed after the event 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()

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

Type signature

removeAllListeners(event?: string): void;

Parameters

Parameter

Type

Description

event

string

(Optional) The event for which to unregister all listeners. If you do not specify this parameter, all listeners for all events on the object are unregistered.

Returns

void

Event List

"first-frame-decoded"

Triggered when the first audio or video frame is decoded.

Type signature

'first-frame-decoded': () => void