AudioTrackList: addtrack event

The addtrack event is fired when a track is added to an AudioTrackList.

Bubbles No
Cancelable No
Interface TrackEvent
Event handler property onaddtrack

Examples

Using addEventListener():

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

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

Using the onaddtrack event handler property:

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

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

Specifications

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

Browser compatibility

BCD tables only load in the browser

See also