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

141
Vistas
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
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