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

228
Views
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 answers
Answer question

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 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!