I am making audio chat website using WebRTC. I have one problem.
When receiving remote audio from peer. This doesn't work (I can't hear any audio)
var audioContext = new AudioContext();
var audioStream = audioContext.createMediaStreamSource(e.stream);
audioStream.connect(audioContext.destination);
While this works
var audio2 = document.querySelector('audio#audio2');
audio2.srcObject = e.stream;
The reason I need to do it is because I need to be able to control the audio (effects, volume), and as I know, AudioContext provides that. But for some reason, it doesn't work. Any suggestions?
Thank you!
Use
.createMediaStreamSource()
with.createGain()
jsfiddle https://jsfiddle.net/tkw13bfg/2
Alternatively, create an
AudioNode
, use.createGain()