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

213
Views
How to access the remote stream on a Twilio browser call

I'm using the new v2 Twilio Javascript SDK to make calls from the browser to other people. This works fine but I've been asked to add volume controls for the incoming audio stream.

After some research it seems that I need to take the remote stream from the call and feed it through a gain node to reduce the volume.

Unfortunately the result from call.getRemoteStream is always null even when I can hear audio from the call. I've tested this on latest Chrome and Edge and they have the same behavior.

Is there something else I need to do to access the remote stream?

Code:

async function(phoneNumber, token) 
{
    console.log("isSecureContext: " + window.isSecureContext); //check we can get the stream

    var options = {
          edge: 'ashburn', //us US endpoint
          closeProtection: true // will warn user if you try to close browser window during an active call
    };
    var device = new Device(token, options);

    const connectionParams = { 
        "phoneNumber": phoneNumber
    };
    var activeCall = await device.connect({ params: connectionParams });

    //Setup gain (volume) control for incoming audio
    //Note, getRemoteStream always returns null.
    var remoteStream = activeCall.getRemoteStream();

    if(remoteStream)
    {
        var audioCtx = new AudioContext();
        var source = audioCtx.createMediaStreamSource(remoteStream);
        var gainNode = audioCtx.createGain();
        source.connect(gainNode)
        gainNode.connect(audioCtx.destination);
    }
    else
    {
        console.log("No remote stream on call");
    }    
}

The log output is:

isSecureContext: true

then

No remote stream on call

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Twilio support gave me the answer: you need to wait until you start receiving volume events before requesting the stream.

ie

call.on('volume', (inputVolume, outputVolume) => {

    if(inputVolume > 0)
    {
       var remoteStream = activeCall.getRemoteStream();
       ....
    }
});
about 4 years ago · Santiago Trujillo 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!