The Wayback Machine - https://web.archive.org/web/20171002073620/https://developer.mozilla.org/en-US/docs/Web/API/VTTCue

MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/d6d7ff2e2f9c

VTTCue


 

VTTCues represent a cue in a text track.

In order to create a new VTTCue, a new object must be instantiated by providing three arguments in the constructor:

  • startTime in seconds: When the text will start to be displayed
  • endTime in seconds: When the text should be gone
  • text: content to be presented in the media element
var cue = new VTTCue(2, 3, 'Cool text to be displayed');

Once the new cue is created, it can be added to an existing text track. A text track can be retrieved from the textTracks list from a video element:

var tracks = document.querySelector('video').textTracks;
var englishTrack = tracks[0];
englishTrack.addCue(cue);

Now, you can see the text "Cool test to be displayed" while playing a video, from second 2 to 3, and then it will be gone.

Document Tags and Contributors

 Contributors to this page: Abhro, chamb
 Last updated by: Abhro,