Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. HTMLTrackElement

HTMLTrackElement

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

TheHTMLTrackElement interface represents anHTML<track> element within theDOM. This element can be used as a child of either<audio> or<video> to specify a text track containing information such as closed captions or subtitles.

EventTarget Node Element HTMLElement HTMLTrackElement

Instance properties

Inherits properties from its parent,HTMLElement.

HTMLTrackElement.kind

A string that reflects thekind HTML attribute, indicating how the text track is meant to be used. Possible values are:subtitles,captions,descriptions,chapters, ormetadata.

HTMLTrackElement.src

A string that reflects thesrc HTML attribute, indicating the address of the text track data.

HTMLTrackElement.srclang

A string that reflects thesrclang HTML attribute, indicating the language of the text track data.

HTMLTrackElement.label

A string that reflects thelabel HTML attribute, indicating a user-readable title for the track.

HTMLTrackElement.default

A boolean value reflecting thedefault attribute, indicating that the track is to be enabled if the user's preferences do not indicate that another track would be more appropriate.

HTMLTrackElement.readyStateRead only

Returns anunsigned short that show the readiness state of the track:

ConstantValueDescription
NONE0Indicates that the text track's cues have not been obtained.
LOADING1Indicates that the text track is loading and there have been no fatal errors encountered so far. Further cues might still be added to the track by the parser.
LOADED2Indicates that the text track has been loaded with no fatal errors.
ERROR3Indicates that the text track was enabled, but when the user agent attempted to obtain it, this failed in some way. Some or all of the cues are likely missing and will not be obtained.
HTMLTrackElement.trackRead only

ReturnsTextTrack is the track element's text track data.

Instance methods

No specific method; inherits methods from its parent,HTMLElement.

Events

Inherits events from its parent,HTMLElement.

Listen to these events usingaddEventListener() or by assigning an event listener to theoneventname property of this interface:

cuechange

Sent when the underlyingTextTrack has changed the currently-presented cues. This event is always sent to theTextTrack but isalso sent to theHTMLTrackElement if one is associated with the track.You may also use theoncuechange event handler to establish a handler for this event.

Usage notes

Loading of the track's text resource

The WebVTT or TTML data describing the actual cues for the text track isn't loaded if the track'smode is initially in thedisabled state. If you need to be able to perform any processing on the track after the<track> is set up, you should instead ensure that the track'smode is eitherhidden (if you don't want it to start out being presented to the user) orshowing (to initially display the track). You can then change the mode as desired later.

Specifications

Specification
HTML
# htmltrackelement

Browser compatibility

See also

  • The HTML element implementing this interface:<track>.

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp