0

I'm implementing a WebRTC Audio chat. I have everything working, and was initially using <audio> elements to output the audio, which worked fine.

But then I wanted to implement a "Speaking indicator" feature, and decided to go with AudioContext.

It works, in Safari + Firefox, but no Chrome. I just don't get any output.

This is my code:

const audioContext = new AudioContext();

// Create an audio source node from the stream received by the
// RTCPeerConnection with peerConnection.ontrack()
const audioSourceNode = audioContext.createMediaStreamSource(stream);

// Connect the audio source to the destination
audioSourceNode.connect(audioContext.destination);

Am I missing something? Do I need to somehow use an <audio> element to get sound on Chrome?

enyo
  • 16,269
  • 9
  • 56
  • 73
  • you might have blocked microphone on your browser – IT goldman Oct 31 '22 at 13:47
  • As I said, using an – enyo Oct 31 '22 at 13:56

1 Answers1

1

It's an old known bug in Chrome that wasn't fixed so far.

A common workaround is to create a muted <audio> element to make the audio flowing (it can be deleted after). See this answer for an example.

Ivan
  • 624
  • 4
  • 7