I'm getting this example straight from Mozilla.
<!doctype html>
<html>
<head>
<title>Generating audio in real time</title>
<script 开发者_运维百科type="text/javascript">
function playTone() {
var output = new Audio();
output.mozSetup(1, 44100);
var samples = new Float32Array(22050);
var len = samples.length;
for (var i = 0; i < samples.length ; i++) {
samples[i] = Math.sin( i / 20 );
}
output.mozWriteAudio(samples);
}
</script>
</head>
<body>
<p>This demo plays a one second tone when you click the button below.</p>
<button onclick="playTone();">Play</button>
</body>
</html>
Firefox 3.6.17, Firebug is saying: output.mozSetup is not a function.
mozSetup and mozWriteAudio need Firefox 4.
According to this page, those methods are marked as [Requires Gecko 2.0] [Non-standard]. Gecko 2.0 was first used in Firefox 4.0.
精彩评论