如何在Firefox和&amp ;;中停止音频播放使用source.connect()hack

时间:2014-10-01 02:06:18

标签: javascript firefox audio getusermedia

我正在开发一个webapp(部分)使用recorder.js记录一些音频,并将其发送到服务器。我试图瞄准Firefox,所以我必须使用这个黑客来阻止音频源的切断:

// Hack for a Firefox bug that stops input after a few seconds
window.source = audio_context.createMediaStreamSource(stream);
source.connect(audio_context.destination);

我认为这会导致音频通过电脑扬声器播放,但我不确定。在网络音频方面,我是一个新手。我的目标是消除扬声器播放的音频。

编辑:

这是我在Github上的JS文件的链接:https://github.com/miller9904/Jonathan/blob/master/js/main.js#L87

1 个答案:

答案 0 :(得分:0)

您必须将源连接到节点(通过该节点检索要记录的数据),将this.node替换为您分配给用于处理的yuor节点的变量名称。

window.source.connect(this.node);
//this.node.connect(this.context.destination);

编辑:刚刚检查过,连接到目的地不是强制性的,也要确保你的节点变量没有被垃圾收集(我假设你的情况正在发生,因为录音会在几秒后停止。)