VTTCue
interface—part of the API for handling WebVTT (text tracks on media presentations)—describes and controls the text track associated with a particular <track>
element. VTTCue(startTime, endTime, text)
VTTCue
object that covers the given time range and has the given text.This interface also inherits properties from TextTrackCue
.
VTTCue.region
VTTRegion
object describing the video's sub-region that the cue will be drawn onto, or null
if none is assigned.VTTCue.vertical
VTTCue.snapToLines
VTTCue.line
attribute is an integer number of lines or a percentage of the video size.VTTCue.line
auto
or a number whose interpretation depends on the value of VTTCue.snapToLines
.VTTCue.lineAlign
VTTCue.line
.VTTCue.position
auto
or a number representing the percentage of the VTTCue.region
, or the video size if VTTCue.region
is null
.VTTCue.positionAlign
VTTCue.position
is anchored to.VTTCue.size
double
representing the size of the cue, as a percentage of the video size.VTTCue.textAlign
VTTCue.text
DOMString
with the contents of the cue.VTTCue.getCueAsHTML
DocumentFragment
.var cue = new VTTCue(2, 3, 'Cool text to be displayed'); var tracks = document.querySelector('video').textTracks; tracks[0].addCue(cue);
Once the new cue is created, it needs to be added to a TextTrack
. Once added, this cue will be drawn from seconds 2 to 3 and will show the text Cool text to be displayed
.
Specification | Status | Comment |
---|---|---|
WebVTT: The Web Video Text Tracks Format | Candidate Recommendation |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | ? | 26 | ? | Yes | ? |
VTTCue() constructor |
Yes | ? | Yes | ? | Yes | ? |
align |
Yes | ? | Yes | ? | Yes | ? |
getCueAsHTML |
Yes | ? | Yes | ? | Yes | ? |
line |
Yes | ? | Yes | ? | Yes | ? |
lineAlign |
No | ? | Yes | ? | No | ? |
position |
Yes | ? | Yes | ? | Yes | ? |
positionAlign |
No | ? | Yes | ? | No | ? |
region |
No | ? | Yes | ? | No | ? |
size |
Yes | ? | Yes | ? | Yes | ? |
snapToLines |
Yes | ? | Yes | ? | Yes | ? |
text |
Yes | ? | Yes | ? | Yes | ? |
vertical |
Yes | ? | Yes | ? | Yes | ? |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | ? | Yes | ? | Yes | Yes | ? | ? |
VTTCue() constructor |
? | Yes | ? | Yes | Yes | ? | ? |
align |
? | Yes | ? | Yes | Yes | ? | ? |
getCueAsHTML |
? | Yes | ? | Yes | Yes | ? | ? |
line |
? | Yes | ? | Yes | Yes | ? | ? |
lineAlign |
? | No | ? | Yes | No | ? | ? |
position |
? | Yes | ? | Yes | Yes | ? | ? |
positionAlign |
? | No | ? | Yes | No | ? | ? |
region |
? | No | ? | Yes | No | ? | ? |
size |
? | Yes | ? | Yes | Yes | ? | ? |
snapToLines |
? | Yes | ? | Yes | Yes | ? | ? |
text |
? | Yes | ? | Yes | Yes | ? | ? |
vertical |
? | Yes | ? | Yes | Yes | ? | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/VTTCue