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
Specification | Status |
---|---|
HTML Living Standard The definition of 'addtrack' in that specification. |
Living Standard |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
No compatibility data found. Please contribute data for "api.TextTrackList.addtrack_event" (depth: 1) to the MDN compatibility data repository.
See also
- Related events:
removetrack
,change
- This event on
VideoTrackList
targets:addtrack
- This event on
AudioTrackList
targets:addtrack
- This event on
MediaStream
targets:addtrack
- Media Streams API
- WebRTC