2.html
3.44 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<audio id="a1" controls>
<source src="./mp3.mp3" type="audio/mpeg">
<source src="./horse.mp3" type="audio/mpeg">
</audio>
<script type="text/javascript">
video = document.getElementsByTagName("video")[0];
for (i=0; i< video.audioTracks.length; i++) {
if (video.audioTracks[i].language === 'sgn-asf') {
video.audioTracks[i].selected = true;
} else {
video.audioTracks[i].selected = false;
}
}
</script>
<!-- <script type="text/javascript" src="https://www.html5rocks.com/en/tutorials/webaudio/intro/js/buffer-loader.js"></script> -->
<script type="text/javascript">
// function BufferLoader(context, urlList, callback) {
// this.context = context;
// this.urlList = urlList;
// this.onload = callback;
// this.bufferList = new Array();
// this.loadCount = 0;
// }
// BufferLoader.prototype.loadBuffer = function(url, index) {
// // Load buffer asynchronously
// var request = new XMLHttpRequest();
// request.open("GET", url, true);
// request.responseType = "arraybuffer";
// var loader = this;
// request.onload = function() {
// // Asynchronously decode the audio file data in request.response
// loader.context.decodeAudioData(
// request.response,
// function(buffer) {
// console.log(loader.loadCount);
// if (!buffer) {
// alert('error decoding file data: ' + url);
// return;
// }
// loader.bufferList[index] = buffer;
// if (++loader.loadCount == loader.urlList.length)
// loader.onload(loader.bufferList);
// },
// function(error) {
// console.error('decodeAudioData error', error);
// }
// );
// }
// request.onerror = function() {
// alert('BufferLoader: XHR error');
// }
// request.send();
// }
// BufferLoader.prototype.load = function() {
// for (var i = 0; i < this.urlList.length; ++i)
// this.loadBuffer(this.urlList[i], i);
// }
// window.onload = function(){
// setTimeout(function(){
// init();
// },3000)
// };
// var context;
// var bufferLoader;
// function init() {
// // Fix up prefixing
// window.AudioContext = window.AudioContext || window.webkitAudioContext;
// context = new AudioContext();
// bufferLoader = new BufferLoader(
// context, [
// './mp3.mp3',
// './horse.mp3',
// ],
// finishedLoading
// );
// bufferLoader.load();
// }
// function finishedLoading(bufferList) {
// // Create two sources and play them both together.
// var source1 = context.createBufferSource();
// var source2 = context.createBufferSource();
// source1.buffer = bufferList[0];
// source2.buffer = bufferList[1];
// source1.connect(context.destination);
// source2.connect(context.destination);
// source1.start(0);
// source2.start(0);
// }
</script>
</body>
</html>