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 |
浏览器兼容性
加载中…