The addtrack
event is fired when a track is added to a TextTrackList
.
The addtrack
event is fired when a track is added to a TextTrackList
.
Use the event name in methods like addEventListener()
, or set an event handler property.
js
addEventListener("addtrack", (event) => {}); onaddtrack = (event) => {};
A TrackEvent
. Inherits from Event
.
In addition to the properties listed below, properties from the parent interface, Event
, are available.
Using addEventListener()
:
js
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:
js
const mediaElement = document.querySelector("video, audio"); mediaElement.textTracks.onaddtrack = (event) => { console.log(`Text track: ${event.track.label} added`); };
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
addtrack_event |
23 | 12 | 31 | 11 | ≤12.1 | 6 | 4.4 | 25 | 31 | ≤12.1 | 7 | 1.5 |
removetrack
, change
VideoTrackList
targets: addtrack
AudioTrackList
targets: addtrack
MediaStream
targets: addtrack
© 2005–2023 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