<!DOCTYPE html>
<html>
<body>

<video id="myVideo" width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>

<p>Click the button to add a new text track.</p>

<button onclick="myFunction()">Try it</button>

<p><strong>Note:</strong> The addTextTrack method is not supported in any major browsers.</p>

<script>
var x = document.getElementById("myVideo");

function myFunction() {
    var y = x.addTextTrack("caption");
    y.addCue(new TextTrackCue("Test text", 01.000, 04.000,"","","", true));
}
</script>

</body>
</html>