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:
startTimein seconds: When the text will start to be displayed
endTimein 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; 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.