TextTrackCueList: getCueById() method
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.
The getCueById() method of the TextTrackCueList interface returns the first VTTCue in the list represented by the TextTrackCueList object whose identifier matches the value of id.
Syntax
js
getCueById(id)
Parameters
id-
A string which is an identifier for the cue.
Return value
A VTTCue object.
Examples
The TextTrack.cues property returns a TextTrackCueList containing the current cues for that particular track. Calling cues.getCueById("second") returns the VTTCue with an ID of "second".
WEBVTT first 00:00:00.000 --> 00:00:00.999 line:80% Hildy! second 00:00:01.000 --> 00:00:01.499 line:80% How are you?
js
const video = document.getElementById("video");
video.onplay = () => {
console.log(video.textTracks[0].cues.getCueById("second")); // a VTTCue object;
};
Specifications
| Specification |
|---|
| HTML> # dom-texttrackcuelist-getcuebyid> |
Browser compatibility
Loading…