VTTCue: text プロパティ

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.

textVTTCue インターフェイスのプロパティで、このキューのテキストコンテンツを表します。

キューの生のテキストを保持する文字列です。

次の例では、新しい VTTCue が作成され、 size の値には文字列 "new cue value" が設定されます。そして、その値がコンソールに出力されます。

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

let cue1 = new VTTCue(0, 0.9, "Hildy!");
cue1.text = "new cue value";
console.log(cue1.text); // 'new cue value';

track.addCue(cue1);

仕様書

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

ブラウザーの互換性

BCD tables only load in the browser