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