HTMLTrackElement: cuechange event

この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!
この記事を English (US) で読むこともできます。

The cuechange event fires when a TextTrack has changed the currently displaying cues. The event is fired at both the TextTrack and at the HTMLTrackElement in which it's being presented, if any.

Bubbles No
Cancelable No
Interface Event
Event handler oncuechange

Examples

On the TextTrack

You can set up a listener for the cuechange event on a TextTrack using  the addEventListener() method:

track.addEventListener('cuechange', function () {
  let cues = track.activeCues;  // array of current cues
});

Or you can just set the oncuechange event handler property:

track.oncuechange = function () {
  let cues = track.activeCues; // array of current cues
}

On the track element

The underlying TextTrack, indicated by the track property, receives a cuechange event every time the currently-presented cue is changed. This happens even if the track isn't associated with a media element.

If the track is associated with a media element, using the <track> element as a child of the <audio> or <video> element, the cuechange event is also sent to the HTMLTrackElement.

let textTrackElem = document.getElementById("texttrack");

textTrackElem.addEventListener("cuechange", (event) => {
  let cues = event.target.track.activeCues;
});

In addition, you can use the oncuechange event handler:

let textTrackElem = document.getElementById("texttrack");

textTrackElem.oncuechange = (event) => {
  let cues = event.target.track.activeCues;
});

Specifications

Specification Status
HTML Living Standard
The definition of 'cuechange' in that specification.
Living Standard

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
cuechange eventChrome Full support YesEdge Full support 12Firefox Full support 31IE ? Opera ? Safari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 31Opera Android No support NoSafari iOS ? Samsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also

ドキュメントのタグと貢献者

このページの貢献者: Sheppy
最終更新者: Sheppy,