textTracks property
The read-only textTracks
property on HTMLMediaElement objects returns a
TextTrackList object listing all of the TextTrack
objects representing the media element's text tracks, in the same order as
in
the list of text tracks.
You can detect when tracks are added to and removed from an
<audio>
or
<video>
element
using the addtrack
and removetrack
events. However, these
events aren't sent directly to the media element itself. Instead, they're
sent to the
track list object of the
HTMLMediaElement
that corresponds to the type of track that was added to the element
The returned list is live; that is, as tracks are added to and removed from the media element, the list's contents change dynamically. Once you have a reference to the list, you can monitor it for changes to detect when new text tracks are added or existing ones removed.
See TextTrackList events to learn more about watching for changes to a media element's track list.
Implementation
external TextTrackList get textTracks;