VTTCue: getCueAsHTML() 方法

Baseline 已廣泛支援

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

VTTCue 介面的 getCueAsHTML() 方法返回一個包含提示內容(cue content)的 DocumentFragment

語法

js
getCueAsHTML()

引數

無。

返回值

一個 DocumentFragment

示例

在下面的示例中,建立了一個新的 VTTCue。然後將作為文件片段的值列印到控制檯。

js
let video = document.querySelector("video");
let track = video.addTextTrack("captions", "Captions", "en");
track.mode = "showing";

let cue = new VTTCue(0, 0.9, "Hildy!");
console.log(cue.getCueAsHTML());

track.addCue(cue);

規範

規範
WebVTT:網頁影片文字軌道格式
# dom-vttcue-getcueashtml

瀏覽器相容性