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

138
Views
How to show remote participant video on Twilio programmable video?

I have web page with the following javascript code.

My code is listening to participant connected event on a certain room.

Whenever a new participant is connected, I need to show his remote video.

Here is my code :

    var LastTrack;

    function trackSubscribed(HtmlParent, track) {   
        LastTrack = track;  

        console.log("the track width is : " + track.dimensions.width);
        console.log("the track Height is : " + track.dimensions.height);
        HtmlParent.appendChild(track.attach()); 
      }
      
    function participantConnected(HtmlParent, participant) {    
        participant.tracks.forEach(publication => {
          if (publication.isSubscribed) {
            trackSubscribed(HtmlParent, publication.track);
          }
          else { console.log('Track not subscribed'); }
          
        });
        
        participant.on('trackSubscribed',   track => trackSubscribed(HtmlParent, track));
        
      }

This code never works the first time. The remote video is not added the html dom and in the logs I have :

the track width is : null
the track height is : null

However if I call the manually (few seconds later) the function trackSubscribed(HtmlParent, LastTrack) then it works. The video is shown as expected and the dimensions are correct :

the track width is : 640
the track height is : 480

It's like when I'm trying to add the track to the html dom the first time, the track is not "ready".

Does anyone know what am I doing wrong here ?

Thanks. Cheers,

about 4 years ago · Juan Pablo Isaza
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!