TextTrackCueList: getCueById()-Methode

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.

Die getCueById()-Methode der TextTrackCueList-Schnittstelle gibt die erste VTTCue in der Liste zurück, die durch das TextTrackCueList-Objekt dargestellt wird und deren Identifikator mit dem id-Wert übereinstimmt.

Syntax

js
getCueById(id)

Parameter

id

Ein String, der ein Identifikator für die Cue ist.

Rückgabewert

Ein VTTCue-Objekt.

Beispiele

Die TextTrack.cues-Eigenschaft gibt eine TextTrackCueList zurück, die die aktuellen Cues für diesen bestimmten Track enthält. Der Aufruf von cues.getCueById("second") gibt die VTTCue mit der ID "second" zurück.

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;
};

Spezifikationen

Specification
HTML
# dom-texttrackcuelist-getcuebyid

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
getCueById

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support