TextTrackList: addtrack event

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

Bubbles No
Cancelable No
Interface TrackEvent
Event handler property onaddtrack

Examples

Using addEventListener():

const mediaElement = document.querySelector('video, audio');

mediaElement.textTracks.addEventListener('addtrack', (event) => {
  console.log(`Text track: ${event.track.label} added`);
});

Using the onaddtrack event handler property:

const mediaElement = document.querySelector('video, audio');

mediaElement.textTracks.onaddtrack = (event) => {
  console.log(`Text track: ${event.track.label} added`);
};

Specifications

No specification found

No specification data found for api.TextTrackList.addTrack_event.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

Browser compatibility

No compatibility data found for api.TextTrackList.addTrack_event.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/TextTrackList/addtrack_event