TextTrackCueList: length 屬性

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

length 屬性是 TextTrackCueList 介面的一個只讀屬性,它返回列表中提示的數量。

一個無符號長整型(unsigned long),表示列表中提示的數量。

示例

TextTrack.cues 屬性返回一個 TextTrackCueList,其中包含該特定軌道上的當前提示。呼叫 cues.length 會返回列表中提示的數量。使用下面的 WebVTT 軌道,length 的值為 5。

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?

third
00:00:01.500 --> 00:00:02.999 line:80%
Tell me, is the ruler of the universe in?

fourth
00:00:03.000 --> 00:00:04.299 line:80%
Yes, they're in - in a bad humor

fifth
00:00:04.300 --> 00:00:06.000 line:80%
Somebody must've stolen the crown jewels
js
const video = document.getElementById("video");
video.onplay = () => {
  console.log(video.textTracks[0].cues.length); // 5
};

規範

規範
HTML
# dom-texttrackcuelist-length

瀏覽器相容性