Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
WebRTC & Web Audio API - workaround for missing createMediaStreamTrackSource in chromium browsers?

I have a JS-based web gui that uses WebRTC for audio exchange with a server. The WebRTC negotiation works fine, and with a single set of audio tracks (incoming and outgoing) the audio components work fine.

However I've found an issue where I can't add more than the first received track to my web audio context.

According to the documentation, the RTCTrackEvent event for my WebRTC connection returns an event that contains both event.streams and event.track. The streams object will always be the same for a single RTC connection (as far as I can tell), while the track object is the unique track I'm trying to play.

I figured this out because I was originally calling audioCtx.createMediaStreamSource(event.streams[0]) for each received track, thinking that the streams object contained the new track audio. However, that just ended up with multiple copies of the first track playing on top of each other. See the "track ordering" section here for the reason behind that.

The proper way to add & play the new track (as far as I can tell) would be to call createMediaStreamTrackSource(event.track) and connect the resulting node to my web audio flowgraph. However, this function is only supported in Firefox as of right now. Does that mean there's truly no way to add additional received tracks from a WebRTC connection to a web audio flowgraph on other browsers? That seems unlikely. Who here knows the secret trick to making this work?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Well that was actually much simpler than I thought it would be. All you need to do to work around this is create a new MediaStream from the track you need to add:

var newStream = new MediaStream( [ event.track ] ); // must be an array
var newSource = audioCtx.createMediaStreamSource(newStream);
newSource.connect(audioCtx.destination);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!