A local camera video track that lets you switch capture devices and adjust encoding parameters.
Inherits from: LocalVideoTrack
Properties
Property | Type | Description | Minimum supported version |
deviceId | string | Obtain the device ID. | 1.0.0 |
isPlaying | boolean | Indicates whether the media track is playing. | 1.0.0 |
API List
Interface | Description | Minimum supported version |
Updates the media device used for track data capture. | 1.0.0 | |
Enables or disables the camera track. | 1.0.0 | |
Pause/Resume Camera Tracking | 1.0.0 | |
Gets the data of the currently rendered video frame. | 1.0.0 | |
Updates the video track encoding settings to adjust video quality. | 1.0.0 | |
Get stream track id | 1.0.0 | |
Get the stream track name | 1.0.0 | |
Play the media track on the page | 1.0.0 | |
Stop playback | 1.0.0 | |
Cancels a listener callback function for a specified event. | 1.0.0 | |
Listens for a specified event and sets a callback function. | 1.0.0 | |
Listens for a specified event once and removes the listener after the callback function is triggered. | 1.0.0 | |
Removes the listener callback for a specified event or for all events on the object. | 1.0.0 |
API details
setDevice()
Updates the media device for track data capture.
Type Signature
setDevice(deviceId: string): Promise<void>; // On mobile devices, you can set this to user/environment
Returns
void
getCurrentFrameData()
This method can only be called after playback. Otherwise, it returns empty data.
You can retrieve the data of the currently rendered video frame.
Signature
getCurrentFrameData(): string;
Returns
An 'image/png' data URL
setEncoderConfiguration()
In versions earlier than 3.8.0, if you call this API, ensure that the video track is not being published. If the track is already published, you must unpublish it before calling this API and then publish it again.
Updates the video track encoding settings to adjust video quality.
Type Signature
VideoEncoderConfigurationsetEncoderConfiguration(config: <a baseurl="t3055980_v1_0_0.xdita" data-node="4688872" data-root="16740" data-tag="xref" href="t2584362.xdita#bbc425705ddqw" id="76d78b7d184ri">VideoEncoderConfiguration</a>): Promise<void>;
Back
Promise<void>
getMediaStreamTrack()
Obtains the underlying MediaStreamTrack object.
Type Signature
getMediaStreamTrack(): MediaStreamTrack;
Returns
MediaStreamTrack
The MediaStreamTrack object.
getTrackId()
Obtains the track ID.
Type signature
getTrackId(): string;
Returns
string
The track ID.
play()
Plays the media track in 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 in this element to play the video track. This parameter supports two types: - string: The ID of the DOM element. - HTMLElement: Pass a DOM element directly. |
config | (Optional) The parameters for video playback. |
Returns
void
stop()
Stops the playback of the media track.
Type signature
stop(): void;
Returns
void
close()
Closes the local track and releases the associated capture devices.
After a local track is closed, it cannot be used again. You must create a new track to use it again.
Type signature
close(): void;
Returns
void
getTrackLabel()
Retrieves the source description of the local track.
Type Signature
getTrackLabel(): string;
Back
string
The audio or video track description.
setDevice()
Updates the media device for a configured track.
Type signature
setDevice(deviceId: string): Promise<void>;
Parameters
Parameter | Parameters | Description |
deviceId | string | The device ID. |
Returns
Promise<void>
setEnabled()
Enables or disables the track.
When a track is disabled, both playback and publishing are stopped. If the track is already published, calling `setEnabled` also triggers the `user-info-updated` event for remote users.
Type Signature
setEnabled(enabled: boolean): Promise<void>;
Parameters
Parameter | Parameters | Description |
enabled | boolean | Specifies whether to enable the track. Valid values:true: Enables the track.false: Disables the track. |
Returns
Promise<void>
The difference between `setEnabled` and `setMuted` is that `setMuted` responds faster and does not affect the capture state of the audio or video device. For example, calling `setEnabled(false)` on a camera track turns off the camera's LED indicator, while `setMuted(true)` does not.
Do not call `setEnabled` and `setMuted` at the same time.
setMuted()
Pauses or resumes sending the media data for the track.
If the track is already published, calling `setMuted` triggers the `user-info-updated` event for remote users.
Type Signature
setMuted(muted: boolean): Promise<void>;
Parameters
Parameter | Parameters | Description |
muted | boolean | Sends or pauses the media data for the track. - true: Sends the media data. - false: Pauses sending the media data. |
Returns
Promise<void>
on()
Listens for a specified event and sets a callback function.
Type signature
on(event: string, fn: Function): void;
Parameters
Parameter | Type | Description |
event | string | The specified event to monitor. |
fn | Function | The callback function that is called when the event is triggered. |
Returns
void
off()
Cancels the listener callback function for a specified event.
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 runs when the event is triggered. |
Returns
void
once()
Listens for a specified event one time. 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 specified event to listen for. |
fn | Function | The callback function that runs when the event is triggered. |
Returns
void
removeAllListeners()
Removes the listener callback for a specified event or all event listeners from the object.
Type Signature
removeAllListeners(event?: string): void;
Parameters
Parameter | Type | Description |
event | string | (Optional) If an event is specified, the listener callback function for that event is deleted. If this parameter is omitted, the listener functions for all events on the object are deleted. |
Returns
void