我直接从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>火狐3.6.17,火虫说: output.mozSetup不是一个函数。
发布于 2011-05-20 14:04:07
mozSetup和mozWriteAudio需要Firefox4。
根据this page的说法,这些方法被标记为需要Gecko2.0。Gecko 2.0最早是在Firefox 4.0中使用的。
https://stackoverflow.com/questions/6067716
复制相似问题