TextTrackCueList: getCueById() 方法
TextTrackCueList 介面的 getCueById() 方法返回 TextTrackCueList 物件所表示的列表中,第一個其識別符號與 id 值匹配的 VTTCue。
語法
js
getCueById(id)
引數
id-
一個字串,表示 cue 的識別符號。
返回值
一個 VTTCue 物件。
示例
TextTrack.cues 屬性返回一個 TextTrackCueList,其中包含該特定軌道當前所有的 cue。呼叫 cues.getCueById("second") 將返回 ID 為 "second" 的 VTTCue。
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;
};
規範
| 規範 |
|---|
| HTML # dom-texttrackcuelist-getcuebyid |
瀏覽器相容性
載入中…