Occurs when a audio or video track ends.
Reasons may include:
Whether a media track is playing on the webpage:
true
: The media track is playing on the webpage.false
: The media track is not playing on the webpage.The type of a media track:
"audio"
: Audio track."video"
: Video track.Closes a local track and releases the audio and video resources that it occupies.
Once you close a local track, you can no longer reuse it.
Gets all the listeners for a specified event.
The event name.
Gets an MediaStreamTrack object.
An MediaStreamTrack object.
DEPRECATED from v4.1.0. Use AgoraRTCClient.getLocalVideoStats and AgoraRTCClient.getLocalAudioStats instead.
Gets the statistics of a local track.
Note: When getting the statistics of a local video track, you cannot get the
encodeDelay
property on iOS.
Gets the ID of a media track, a unique identifier generated by the SDK.
The media track ID.
Gets the label of a local track.
The label that the SDK returns may include:
createMicrophoneAudioTrack
or createCameraVideoTrack
.sourceId
property, if the track is created by calling createScreenVideoTrack
.createCustomAudioTrack
or createCustomVideoTrack
.Removes the listener for a specified event.
The event name.
The callback that corresponds to the event listener.
Listens for a specified event once.
When the specified event happens, the SDK triggers the callback that you pass and then removes the listener.
The event name.
The callback to trigger.
Plays a media track on the webpage.
Specifies a DOM element. The SDK will create a <video>
element under the specified DOM element to play the video track. You can specify a DOM element in either of following ways:
string
: Specify the ID of the DOM element.HTMLElement
: Pass a DOM object.Removes all listeners for a specified event.
The event name. If left empty, all listeners for all events are removed.
Since
4.0.0
Enables/Disables the track.
After a track is disabled, the SDK stops playing and publishing the track.
- Disabling a track does not trigger the LocalTrack.on("track-ended") event.
- If a track is published, disabling this track triggers the user-unpublished event on the remote client, and re-enabling this track triggers the user-published event.
- Do not call
setEnabled
andsetMuted
together.
Whether to enable the track:
true
: Enable the track.false
: Disable the track.Sends or stops sending the media data of the track.
Since
4.6.0
If the track is published, a successful call of setMuted(true)
triggers the user-unpublished event on the remote client, and a successful call of setMuted(false)
triggers the user-published event.
- Calling
setMuted(true)
does not stop capturing audio or video and takes shorter time to take effect than setEnabled. For details, see What are the differences between setEnabled and setMuted?.- Do not call
setEnabled
andsetMuted
together.
Whether to stop sending the media data of the track:
true
: Stop sending the media data of the track.false
: Resume sending the media data of the track.Stops playing the media track.
LocalTrack
is the basic interface for local tracks, providing public methods for LocalAudioTrack and LocalVideoTrack.