I've been trying to capture audio stream on a webpage where communication can be 2-way. So far I've been successful in capturing the audio stream of the user who is speaking using MediaRecorder and navigator.mediaDevices. This is the piece of code I wrote:
const onError = (err) => {
console.log('The following error occured: ' + err);
}
const onSuccess = (stream) => {
const options = {
audioBitsPerSecond : 64000,
mimeType : 'audio/webm;codecs=opus'
}
recorder = new MediaRecorder(stream, options);
}
//
navigator.mediaDevices.getUserMedia({ audio: true }).then(onSuccess, onError);
recorder.ondataavailable = (e) => {
console.log("data available");
};
recorder.start(1000);
However, I'm not able to capture the audio stream of the user who is speaking on the other end. I'm trying to do this on an online conference browser based application. I'd like to know how I can capture the audio stream of all the users speaking.