最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - WebRTC: Get audio level of a mediaStream *without* playing back the audio - Stack Overflow

programmeradmin8浏览0评论

I'm looking to get the microphone activity level of a WebRTC MediaStream. However, I need to get this information without playing back the microphone to the user (otherwise there will be the loopback effect).

The answer in Microphone activity level of WebRTC MediaStream relies on the audio being played back to the user. How can I do this, without playing back the microphone?

I'm looking to get the microphone activity level of a WebRTC MediaStream. However, I need to get this information without playing back the microphone to the user (otherwise there will be the loopback effect).

The answer in Microphone activity level of WebRTC MediaStream relies on the audio being played back to the user. How can I do this, without playing back the microphone?

Share Improve this question asked Jul 8, 2014 at 6:25 apscienceapscience 7,28311 gold badges57 silver badges89 bronze badges 1
  • No it does not? I just tested the code and the mediastream simply goes into the node and is never played back to the speakers. I believe you HAVE to do with with the AudioAPI and connecting it to a node is not playing the audio back... – Benjamin Trent Commented Jul 8, 2014 at 13:05
Add a ment  | 

1 Answer 1

Reset to default 7

Take a look at createGain method. It allows you to set stream's volume.

Here is my (simplified) example that I use in my project:

navigator.getUserMedia({audio: true, video: true}, function(stream) {
    var audioContext = new AudioContext; //or webkitAudioContext
    var source = audioContext.createMediaStreamSource(stream);

    var volume = audioContext.createGain();
    source.connect(volume);
    volume.connect(audioContext.destination);
    volume.gain.value = 0;  //turn off the speakers

    //further manipulations with source
}, function(err) {
    console.log('error', err);
});
发布评论

评论列表(0)

  1. 暂无评论