Aditya
Aditya

Reputation: 431

HTML5 track not working

Srt file is not loading in my sample video .I have attached both html and srt file.mp4 is a sample video.Am i going wrong somewhere ?

<body>
<video id="myVideo" >
<source src="rock.mp4"/>
<track src="sample.srt" kind="subtitle" srclang="en" label="English"/>
</video>
<button onclick="play()">play</button>
<button onclick="pause()">pause</button>
<button onclick="smallwidth()">small width</button>
<button onclick="bigwidth()">big width</button>
</body> 
<script>
function play(){
    myVideo.play();
}   
function pause(){
    myVideo.pause();
}   
function smallwidth(){
    myVideo.width=200;
}   
function bigwidth(){
    myVideo.width=300;
}
</script>
</html>

sample.srt
1
00:00:01.000 --> 00:01:05.000
This is rockmp4
2
00:01:05.000 --> 00:05:10.000
file was specified using the 'track' element

Upvotes: 0

Views: 679

Answers (1)

Ainei
Ainei

Reputation: 50

You're missing an "s" in your "kind" attribute. It should be like this:

<track src="sample.srt" kind="subtitles" srclang="en" label="English"/>

Also, you should try changing your substitles file to .vtt from .srt, because it is more preffered by browsers :)

Upvotes: 2

Related Questions