TextTrackCueList.getCueById()

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

var cue = TextTrackCueList.getCueById(id);

Parameters

id

A DOMString 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?
let video = document.getElementById("video");
video.onplay = function () {
  console.log(video.textTracks[0].cues.getCueById("second")) // a VTTCue object;
}

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
getCueById
23
12
31
10
≤12.1
6
≤37
25
31
≤12.1
6
1.5

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCueList/getCueById