content/media/webaudio/test/test_decodeMultichannel.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:724946f74e84
1 <!DOCTYPE HTML>
2 <html>
3 <meta charset=utf-8>
4 <head>
5 <title>Test that we can decode 4 channel wave file in webaudio, but not in &lt;audio&gt;</title>
6 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
8 </head>
9 <body>
10 <pre id="test">
11 <script class="testbody" type="text/javascript">
12 var filename = "audio-quad.wav";
13
14 SimpleTest.waitForExplicitFinish();
15
16 function finishTest(a) {
17 if (a) {
18 a = null;
19 SimpleTest.finish();
20 }
21 }
22
23 function decodeUsingAudioElement() {
24 var a = new Audio();
25 a.addEventListener("error", function() {
26 ok(true, "We should not be able to decode this file using an HTMLAudioElement");
27 finishTest(a);
28 });
29 a.addEventListener("loadedmetadata", function() {
30 ok(false, "We should not be able to decode this file using an HTMLMediaElement.");
31 finishTest(a);
32 });
33
34 a.src = filename;
35 a.load();
36 }
37
38 addLoadEvent(function() {
39 var xhr = new XMLHttpRequest();
40 xhr.open("GET", filename);
41 xhr.responseType = "arraybuffer";
42 xhr.onload = function() {
43 var context = new AudioContext();
44 context.decodeAudioData(xhr.response, function(b) {
45 ok(true, "Decoding of a wave file with four channels succeded.");
46 is(b.numberOfChannels, 4, "The AudioBuffer should have 4 channels.");
47 decodeUsingAudioElement();
48 }, function() {
49 ok(false, "Decoding of a wave file with four channels failed.");
50 decodeUsingAudioElement();
51 });
52 };
53 xhr.send(null);
54 });
55 </script>
56 </pre>
57 </body>
58 </html>

mercurial