[英]Stream microphone audio to speakers using AudioContext
I feel like maybe something has changed in Chrome as there are demos of this functionality out there that don't seem to work anymore. 我觉得Chrome可能发生了一些变化,因为那里有此功能的演示似乎不再起作用。 I haven't found anything saying so though. 我什么都没说。 Here is my code: 这是我的代码:
navigator.getUserMedia = ( navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||navigator.msGetUserMedia);
var aCtx;
var analyser;
var microphone;
if (navigator.getUserMedia) {
navigator.getUserMedia({audio: true}, function(stream) {
aCtx = new webkitAudioContext();
analyser = aCtx.createAnalyser();
microphone = aCtx.createMediaStreamSource(stream);
microphone.connect(analyser);
analyser.connect(aCtx.destination);
});
};
I can't get the audio to play through the speakers. 我无法通过扬声器播放音频。 I'm hoping that my code is just incorrect and that this is still possible. 我希望我的代码不正确,并且仍然可以实现。 I can get it to work if I use an audio tag and send it straight there but I want to be able to add filters to it. 如果使用音频标签并将其直接发送到那里,我可以使其正常工作,但是我希望能够为其添加过滤器。
You have made a typographical error. 您犯了一个印刷错误。 Your first line should be 您的第一行应该是
navigator.getUserMedia = ( navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||navigator.msGetUserMedia);
It looks like I needed to change my microphone to default. 看来我需要将麦克风更改为默认麦克风。 It was set on display audio. 它设置在显示音频上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.