VideoTrackList: addtrack event

The addtrack event is fired when a track is added to a VideoTrackList.

Bubbles No
Cancelable No
Interface TrackEvent
Event handler property onaddtrack

Examples

Using addEventListener():

const videoElement = document.querySelector('video');

videoElement.videoTracks.addEventListener('addtrack', (event) => {
  console.log(`Video track: ${event.track.label} added`);
});

Using the onaddtrack event handler property:

const videoElement = document.querySelector('video');

videoElement.videoTracks.onaddtrack = (event) => {
  console.log(`Video track: ${event.track.label} added`);
};

Specifications

Specification
HTML Standard (HTML)
# event-media-addtrack

Browser compatibility

BCD tables only load in the browser

See also