Overview
TheJitsiTrack class represents a single media track (either audio or video). It serves as the base class for both JitsiLocalTrack and JitsiRemoteTrack.
Constructor
The conference instance this track belongs to
The WebRTC MediaStream instance
The WebRTC MediaStreamTrack instance (must be part of the stream)
Handler for onended/oninactive events of the stream
The media type of the track (‘audio’ or ‘video’)
The video type for video tracks (‘camera’ or ‘desktop’)
Methods
attach()
Attaches the MediaStream of this track to an HTML container.The HTML container (‘video’ or ‘audio’ element) to attach to
Resolves when the track is successfully attached
detach()
Removes this JitsiTrack from the HTML container.The HTML container to detach from. If not specified, detaches from all containers
dispose()
Removes attached event listeners and cleans up resources.Resolves when disposal is complete
getId()
Returns the ID of the track.The track ID or null if this is a fake track
getOriginalStream()
Returns the WebRTC MediaStream instance.The underlying WebRTC MediaStream
getSourceName()
Returns the source name of the track.The source name identifier
getSsrc()
Returns the primary SSRC associated with the track.The synchronization source identifier
getStreamId()
Returns the ID of the underlying WebRTC MediaStream.The MediaStream ID
getTrack()
Returns the underlying WebRTC MediaStreamTrack.The underlying MediaStreamTrack
getTrackId()
Returns the ID of the underlying WebRTC MediaStreamTrack.The MediaStreamTrack ID
getTrackLabel()
Returns the label of the underlying WebRTC MediaStreamTrack.The track label (e.g., device name)
getType()
Returns the type (audio or video) of this track.Either ‘audio’ or ‘video’
getUsageLabel()
Returns a meaningful usage label for this track.‘mic’ for audio tracks, or the video type (‘camera’, ‘desktop’) for video tracks
getVideoType()
Returns the video type of this track.‘camera’ or ‘desktop’ for video tracks, undefined for audio
getHeight()
Returns the height of the track in normalized landscape format.The minimum of track height and width (normalized)
getWidth()
Returns the width of the track in normalized landscape format.The maximum of track height and width (normalized)
isActive()
Checks whether the MediaStream is active/not ended.True if the MediaStream is active, false otherwise
isAudioTrack()
Checks if this is an audio track.True if this is an audio track
isVideoTrack()
Checks if this is a video track.True if this is a video track
isLocal()
Checks whether this is a local track.True if it’s a local track, false otherwise
isLocalAudioTrack()
Checks whether this is a local audio track.True if this is a local audio track
isMuted()
Checks whether this track is muted.True if the track is muted
setAudioLevel()
Sets the audio level for the stream.Value between 0 and 1
The peer connection instance which is the source for the audio level
setAudioOutput()
Sets a new audio output device for track’s DOM elements.ID of ‘audiooutput’ device from navigator.mediaDevices.enumerateDevices(), or ” for default device
Resolves when the audio output device is changed successfully
setSourceName()
Assigns the source name to a track.The name to be assigned to the track
Properties
Indicates whether this JitsiTrack has been disposed. If true, the track is unusable
The conference instance this track belongs to
The video type (‘camera’ or ‘desktop’) for video tracks
Array of HTML elements that are displaying the track
Events
JitsiTrack extends the Listenable class and emits various events:TRACK_AUDIO_LEVEL_CHANGED- Fired when audio level changesTRACK_AUDIO_OUTPUT_CHANGED- Fired when audio output device changesNO_AUDIO_INPUT- Fired when no audio input is detected