VTTCue: getCueAsHTML() method

Baseline Widely available

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

Phương thức getCueAsHTML() của giao diện VTTCue trả về một DocumentFragment chứa nội dung của cue.

Cú pháp

js
getCueAsHTML()

Tham số

Không có.

Giá trị trả về

Một DocumentFragment.

Ví dụ

Trong ví dụ sau, một VTTCue mới được tạo. Giá trị dưới dạng document fragment sau đó được in ra console.

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);

Thông số kỹ thuật

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

Tương thích trình duyệt