LocalVideoTrack is the base class for local video tracks and provides their main features.
Inherits from: LocalTrack
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 | |
enabled | boolean | The current enabled state of the local track. | 3.0.0 |
muted | boolean | Indicates whether the track is muted. | 3.0.0 |
API List
API | Description | Minimum supported version |
Enables or disables the video track. | 3.0.0 | |
Pauses or resumes the video track. | 3.0.0 | |
Gets the data of the currently rendered video frame. | 3.0.0 | |
Gets the media track. | 3.0.0 | |
Updates the video track's encoder configuration to adjust video quality. | 3.0.0 | |
Gets the 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 | |
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 | |
Adds a one-time listener for a specified event. The listener is removed after the callback function is triggered. | 3.0.0 | |
Removes the listeners for a specified event or for all events on this object. | 3.0.0 |
Method details
getCurrentFrameData()
Call this method only after playback starts. If you call this method before calling play, it returns empty data.
Retrieves the data of the currently rendered video frame.
Type signature
getCurrentFrameData(): string;
Returns
A dataURL of the 'image/png' type.
setEncoderConfiguration()
For versions earlier than 3.8.0, ensure that the video track is not being published when you call this method. If the track is already published, you must unpublish it, call this method, and then publish the track again.
Updates the video track's encoder configuration to adjust video quality.
Type signature
VideoEncoderConfigurationsetEncoderConfiguration(config: <a baseurl="t2584365_v1_1_3.xdita" data-node="4688872" data-root="16740" data-tag="xref" href="t2584362.xdita#bbc425705ddqw" id="2b294c58a79qt">VideoEncoderConfiguration</a>): Promise<void>;
Returns
Promise<void>
getMediaStreamTrack()
Retrieves the media track.
Type signature
getMediaStreamTrack(): MediaStreamTrack;
Returns
MediaStreamTrack
The media track.
getTrackId()
Retrieves the track ID.
Type signature
getTrackId(): string;
Returns
string
The 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 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`: A DOM element object. |
config | (Optional) The 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
close()
Closes the local track and releases its capture devices.
A closed local track cannot be reused. To use it again, you must create a new one.
Type signature
close(): void;
Back
void
getTrackLabel()
Retrieves the source description of the local track.
Type signature
getTrackLabel(): string;
Returns
string
Description of the audio or video track.
setDevice()
Update the media device for the track
Type signature
setDevice(deviceId: string): Promise<void>;
Parameters
Parameter | Parameters | Description |
deviceId | string | The device ID. |
Back
Promise<void>
setEnabled()
Enable or disable the track.
Disabling a track stops both playback and publishing. If the track is published, calling `setEnabled` triggers the `user-info-updated` event on the remote client.
Type signature
setEnabled(enabled: boolean): Promise<void>;
Parameters
Parameter | Parameters | Description |
enabled | boolean | Specifies whether to enable the track. - `true`: Enable the track. - `false`: Disable the track. |
Back
Promise<void>
The `setMuted` method has a faster response time and does not affect the device's capture state. For example, calling `setEnabled(false)` on a camera track turns off the camera's LED indicator, whereas calling `setMuted(true)` does not.
Do not call `setEnabled` and `setMuted` at the same time.
setMuted()
Starts or stops sending media data for the track.
If a track is published, calling `setMuted` triggers the `user-info-updated` event on the remote client.
Type signature
setMuted(muted: boolean): Promise<void>;
Parameters
Parameter | Parameters | Description |
muted | boolean | Specifies whether to send or stop sending the media data of the track. - `true`: Stop sending media data. - `false`: Resume sending media data. |
Returns
Promise<void>
on()
Registers a listener for a specific event and sets its 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. |
Back
void
off()
Removes the callback function from a specified event listener.
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 to run when the event is triggered. |
Returns
void
once()
Adds a one-time listener for a specified event. This listener is triggered only once and then removed.
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. |
Back
void
removeAllListeners()
Removes listeners for a specified event or all listeners from this 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 removed. If you do not specify this parameter, all event listeners for the object are removed. |
Back
void