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

148
Visualizações
Webrtc audio problems when initiating connecton from desktop to mobile

Iam making a web app using webrtc that allows two users to communicate with each other using both video and audio. The app uses node.js as signaling server. The app works fine when communicating between two desktops but when I try a desktop to mobile communication, if the user initiating the offer is the one in the desktop, the one on mobile can't hear any sound. If it happens the other way around, both have audio. When I check the devtools the audio stream is sent from the desktop and is received by the mobile (it is active and not muted) but there is no sound. I use the audio element to play the audio stream and the video element to play the video stream. I have tested this on both chrome and mozilla and i encounter the same problem.

If anyone can help it would be greatly appreciated.

Bellow are code samples of the ontrack event

  rtcConnection.ontrack = function(event) {
                console.log('Remote stream received.');
                
                if(event.streams[0].getAudioTracks().length > 0) {
                    
                    event.streams[0].getAudioTracks().forEach((track) => {
                        remoteAudioStream .addTrack(track);
                    });
                    
                    audioPlayer.srcObject = remoteAudioStream;  
                    
                }
                
                if (event.streams[0].getVideoTracks().length > 0){
                    
                    event.streams[0].getVideoTracks().forEach((track) => {
                        remoteVideoStream .addTrack(track);
                    });
                    
                    localVideo.srcObject = remoteVideoStream;
                   
                }
               
            
            };

and the capture media stream:

function getUserMedia() {   

let getAudio = true;
let getVideo = true;

let constraints = { audio: getAudio, video: getVideo };

    
navigator.mediaDevices.getUserMedia(constraints) // Ask user to allow access to his media devices  
.then(
    function(data) { //if yes, get stream config data and join room
    
        localStream = data;
    
            console.log('Getting user media succeeded.');
            
            console.log('RTC Connection created. Getting user media. Adding stream tracks to RTC connection');
            
            
            sendMessage({ type: 'peermessage', messagetype:'info', messagetext: 'Peer started video streaming.'});
            
            //stream to be sent to the other user
            localStream.getTracks().forEach(track => rtcConnection.addTrack(track, localStream));
        
        
        console.log('Creating offer');
        rtcConnection.createOffer()
        .then(function(offer) { // createOffer success
            console.log('Offer created. Setting it as local description');
            return rtcConnection.setLocalDescription(offer);
        }, logError)    // createOffer error
        .then(function() {  // setLocalDescription success
            console.log('Offer set as local description. Sending it to agent');
            sendMessage(rtcConnection.localDescription)
        }, logError);   // setLocalDescription error
        
    }
);

}

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