The VTTCue()
constructor creates and returns a new VTTCue
object.
On this page
VTTCue: VTTCue() constructor
Syntax
js
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 string providing the text that will be shown during the time span indicated by
startTime
andendTime
.
Return value
A new VTTCue
object representing a cue which will be presented during the time span given.
Examples
js
// Create a cue that is shown from 2 to 3 seconds and uses the given text.
let cue = new VTTCue(2, 3, "Cool text to be displayed");
Specifications
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
VTTCue |
33 | 79 | 31 | No | 20 | 8 | 4.4.3 | 33 | 31 | 20 | 8 | 2.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/VTTCue