Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda