Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML Track element for video is not working.

SpongeBOB

Well-Known Coder
Hi everyone,

I have followed the guidance of this URL : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/track to add a track (aka subtitle/captions) on a video.

but it's not working here the code of my page:

HTML:
<!doctype html>
<html lang="en-us">


<head>

<meta charset="utf-8">
<title>test video</title>


<body>
<video id="mylittlevdo" controls >
<source src="test.mp4" type="video/mp4"> <!-- place and rename as test.mp4 an mp4 video in the same folder -->
<track kind="subtitles" src="test.vtt" srclang="en" id="sub1" default />Your browser does not support the video tag.</video><br>

<script>
var vid = document.getElementById("mylittlevdo");

function myFunction() {
  alert(vid.textTracks[0].mode);
}
</script>

<br>
<button onclick="myFunction()" type="button">mode</button><br>

</body>
</html>

Quite simple page, so wen I click the button "mode" I see "showing" meaning that the track should appear..

The TTS file come from developer.mozilla.org... Friday.vtt

Weird as on https://developer.mozilla.org/en-US/docs/Web/HTML/Element/track it work ! what the difference ?

Thanks.
 
Last edited:

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom