VTTCue: getCueAsHTML() メソッド

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

getCueAsHTML()VTTCue インターフェイスのメソッドで、このキューの内容を含んだ DocumentFragment を返します。

構文

js
getCueAsHTML()

引数

なし。

返値

次の例では、新しい VTTCue が作成されます。そして、文書フラグメントとしての値がコンソールに出力されます。

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

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

track.addCue(cue1);

仕様書

Specification
WebVTT: The Web Video Text Tracks Format
# dom-vttcue-getcueashtml

ブラウザーの互換性

BCD tables only load in the browser