TextTrackCueList: getCueById() メソッド

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.

getCueById()TextTrackCueList インターフェイスのメソッドで、TextTrackCueList オブジェクトが表すリストの中で、識別子が id の値と一致する最初の VTTCue を返します。

構文

js
getCueById(id)

引数

id

キューの識別子の文字列です。

返値

VTTCue オブジェクトです。

TextTrack.cues プロパティは、その具体的なトラックの現在のキューを格納した TextTrackCueList を返します。cues.getCueById("second") を呼び出すと、VTTCue のうち ID が "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;
};

仕様書

Specification
HTML
# dom-texttrackcuelist-getcuebyid

ブラウザーの互換性

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