gecko/content/media/test/test_wave_data_s16.html

51 lines
1.4 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Wave Media test: ended</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
// Test if the ended event works correctly.
var endPassed = false;
var completed = false;
function audioavailable(e) {
if (completed)
return;
completed = true;
var samples = e.frameBuffer;
var time = e.time;
ok(samples.length >= 3, "Must be 3 or more samples. There were " + samples.length);
if (samples.length >= 3) {
ok(samples[0] > 0.99 && samples[0] < 1.01, "First sound sample should be close to 1.0. It was " + samples[0]);
ok(samples[1] > -1.01 && samples [1] < -0.99, "Second sound sample should be close to -1.0. It was " + samples[1]);
ok(samples[2] > -0.01 && samples[2] < 0.01, "Third sound sample should be close to 0. It was " + samples[2]);
}
// Only care about the first few samples
SimpleTest.finish();
}
function startTest() {
if (completed)
return;
var v = document.getElementById('v');
v.addEventListener('MozAudioAvailable', audioavailable, false);
v.play();
}
SimpleTest.waitForExplicitFinish();
</script>
</pre>
<audio id='v'
onloadedmetadata='return startTest();'>
<source type='audio/x-wav' src='wavedata_s16.wav'>
</audio>
</body>
</html>