Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda