The VTTCue()
constructor creates and returns a new VTTCue
object.
Syntax
vttCue = new VTTCue(startTime, endTime, text);
Parameters
startTime
- This is a
double
representing the initial text track cue start time. This is the time, given in seconds and fractions of a second, denoting the beginning of the range of the media data to which this cue applies. For example, if a cue is to be visible from 50 seconds to a one minute, five and a half seconds in the media's playback,startTime
will be 50.0. endTime
- This is a
double
representing the ending time for this text track cue. This is the time at which the cue should stop being presented to the user, given in seconds and fractions thereof. Given the example cue mentioned understartTime
, the value ofendTime
would be 65.5. text
- A
DOMString
providing the text that will be shown during the time span indicated bystartTime
andendTime
.
Return value
A new VTTCue
object representing a cue which will be presented during the time span given.
Example
// Create a cue that is shown from 2 to 3 seconds and uses the given text. var cue = new VTTCue(2, 3, 'Cool text to be displayed');
Specifications
Specification | Status | Comment |
---|---|---|
WebVTT: The Web Video Text Tracks Format The definition of 'VTTCue()' in that specification. |
Candidate Recommendation |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
VTTCue() constructor | Chrome Full support Yes | Edge Full support ≤79 | Firefox Full support Yes | IE ? | Opera Full support Yes | Safari ? | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- Compatibility unknown
- Compatibility unknown