Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

233
Vistas
Webrtc how to play mp3 to remote peer

Webrtc is already established between local browser and remote browser.

Audio is working send and receiving

A library is handling webrtc connection so don't have stream or rtcpeerconnection object access in this scope

I want to create functions to play short mp3 sounds to local browser or remote browser

This works fine to play to the local browser

    function  playAudioToLocal(mp3url) {
        const context = new AudioContext();

        const response = await fetch(mp3url);
        const arrayBuffer = await response.arrayBuffer();

        const audioBuffer = await context.decodeAudioData(arrayBuffer);
        const source = context.createBufferSource();
        source.buffer = audioBuffer;
        source.start(0);

        source.connect(context.destination);
    }

How would equivalent be to play mp3 to remote?

    function playAudioToRemote(mp3url) {

        const context = new AudioContext();

        const response = await fetch(mp3url);
        const arrayBuffer = await response.arrayBuffer();

        const audioBuffer = await context.decodeAudioData(arrayBuffer);

        *WANT TO PLAY audioBuffer TO REMOTE*

    }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

this code will transform your decoded audio to a MediaStream that you can use with webrtc :

function playAudioToRemote(mp3url) {
const context = new AudioContext();
  const response = await fetch(mp3url);
  const arrayBuffer = await response.arrayBuffer();
  const audioBuffer = await context.decodeAudioData(arrayBuffer);

  const destination = context.createMediaStreamDestination();
  const bufferSource = context.createBufferSource();
  bufferSource.buffer = audioBuffer;
  bufferSource.start(0);
  bufferSource.connect(destination);
  return destination.stream;
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda