简体   繁体   English

使用AudioContext将麦克风音频流传输到扬声器

[英]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.

相关问题 扬声器中的麦克风静音,但仍然可以使用Web Audio Api进行分析(createAnalyser)? - Mute microphone in speakers but still be able to analyze (createAnalyser) with Web Audio Api? HTML5:在 Ubuntu 上从麦克风播放扬声器流 - HTML5: play on speakers stream from microphone on Ubuntu 我可以使用nodejs将麦克风音频从客户端传输到客户端吗? - Can I stream microphone audio from client to client using nodejs? 使用 AudioContext 阻止音频在后台播放 - Using AudioContext stops the audio from playing in the background 使用 AudioContext 获取 16 位输出音频 - Get 16 bit output audio using AudioContext Web音频API:防止通过扬声器播放麦克风输入 - Web Audio API: Prevent microphone input from being played through speakers 我可以使用 Javascript 到 stream 使用 ALAudioDevice(setClientPreferences 然后订阅)来自 Pepper 的麦克风的音频吗? - Can I use Javascript to stream audio sound from Pepper's microphone using ALAudioDevice (setClientPreferences and then subscribe)? 使用android的本地音频与使用audiocontext - Using android's native audio vs using audiocontext 你如何获得定期 <audio> 使用AudioContext时的功能? - How do you get the regular <audio> features when using AudioContext? 音频与AudioContext - Audio vs AudioContext
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM