content/media/webaudio/test/test_mediaStreamAudioDestinationNode.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/webaudio/test/test_mediaStreamAudioDestinationNode.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test MediaStreamAudioDestinationNode</title>
     1.8 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <script type="text/javascript" src="webaudio.js"></script>
    1.10 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.11 +</head>
    1.12 +<body>
    1.13 +<pre id="test">
    1.14 +<audio id="audioelem"></audio>
    1.15 +<script class="testbody" type="text/javascript">
    1.16 +
    1.17 +SimpleTest.waitForExplicitFinish();
    1.18 +addLoadEvent(function() {
    1.19 +  var context = new AudioContext();
    1.20 +  var buffer = context.createBuffer(1, 2048, context.sampleRate);
    1.21 +  for (var i = 0; i < 2048; ++i) {
    1.22 +    buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate);
    1.23 +  }
    1.24 +
    1.25 +  var source = context.createBufferSource();
    1.26 +  source.buffer = buffer;
    1.27 +
    1.28 +  var dest = context.createMediaStreamDestination();
    1.29 +  source.connect(dest);
    1.30 +
    1.31 +  var elem = document.getElementById('audioelem');
    1.32 +  elem.mozSrcObject = dest.stream;
    1.33 +  elem.onloadedmetadata = function() {
    1.34 +    ok(true, "got metadata event");
    1.35 +    setTimeout(function() {
    1.36 +      is(elem.played.length, 1, "should have a played interval");
    1.37 +      is(elem.played.start(0), 0, "should have played immediately");
    1.38 +      isnot(elem.played.end(0), 0, "should have played for a non-zero interval");
    1.39 +      SimpleTest.finish();
    1.40 +    }, 2000);
    1.41 +  };
    1.42 +
    1.43 +  source.start(0);
    1.44 +  elem.play();
    1.45 +});
    1.46 +</script>

mercurial