forked from cgiffard/Captionator
-
Notifications
You must be signed in to change notification settings - Fork 1
/
track_IDL.html
77 lines (74 loc) · 3.03 KB
/
track_IDL.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Video Closed Captioning Example</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" media="screen" href="css/captions.css"/>
</head>
<body>
<h1>HTML5 Video Closed Captioning Example</h1>
<p><em><strong>Note:</strong> the German and Japanese subtitles are machine translated.</em></p>
<video controls autobuffer id="videoTest" width="1024" height="464">
<source src="video/arduino.m4v" type="video/mp4" />
<source src="video/arduino.webm" type="video/webm" />
<source src="video/arduino.ogv" type="video/ogg" />
<track id="track1" kind="captions" src="video/arduino-en.srt" type="text/srt" srclang="en" label="English Subtitles" default />
<track id="track2" kind="captions" src="video/arduino-de.srt" type="text/srt" srclang="de" label="German Subtitles" />
<track id="track3" kind="captions" src="video/arduino-ja.srt" type="text/srt" srclang="ja" label="Japanese Subtitles" />
</video>
<h2>Media Controls</h2>
<div id="controls"></div>
<h2>Track Elements</h2>
<table id="idls" border="1">
<tr>
<th>track id</th>
<th>kind</th>
<th>label</th>
<th>src</th>
<th>language</th>
<th>readyState</th>
<th>mode</th>
<th>default</th>
</tr>
</table>
<script type="text/javascript" src="js/captionator.js"></script>
<!-- Initialize Captionator -->
<script type="text/javascript">
window.addEventListener("load",function(eventData) {
captionator.captionify();
},false);
</script>
<script type="text/javascript">
window.addEventListener("load",function(eventData) {
// Create Menu
var subtitleSelector = document.createElement("select");
document.getElementById("controls").appendChild(subtitleSelector);
subtitleSelector.addEventListener("change",function(eventData) {
trackToEnable = parseInt(eventData.target.value,10);
document.getElementById("videoTest").tracks.forEach(function(track,index) {
if (index === trackToEnable) {
track.mode = captionator.TextTrack.SHOWING;
} else if (track.mode != captionator.TextTrack.OFF) {
track.mode = captionator.TextTrack.HIDDEN;
}
});
},false);
document.getElementById("videoTest").tracks.forEach(function(track,index) {
var subtitleOption = document.createElement("option");
subtitleOption.innerHTML = track.label + " (" + track.language + ")";
subtitleOption.setAttribute("value",index);
subtitleSelector.appendChild(subtitleOption);
});
// Fill table
var idls = document.getElementById("idls");
document.getElementById("videoTest").tracks.forEach(function(track,index) {
var row = document.createElement("tr");
row.innerHTML = "<td>" + track.id + "</td><td>" + track.kind + "</td><td>" + track.label +
"</td><td>" + track.src + "</td><td>" + track.language + "</td><td>" + track.readyState +
"</td><td>" + track.mode + "</td><td>" + track.default + "</td>";
idls.appendChild(row);
});
},false);
</script>
</body>
</html>