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

154
Visualizações
peerjs adding confirm to accept or refuse to coming call

I am developing a django project and including video call with using peerjs.So when user is calling on the other side confirm doesn't show.Can anyone help me ?(Actually the same code worked yesterday but today I didn't change anything nevertheless it isn't working now)

    var currentUserSlug = JSON.parse(document.getElementById('requestUserUsername').textContent);
var other_user_slug = JSON.parse(document.getElementById('other_user').textContent);


var video1=document.getElementById("video1");
var video2=document.getElementById("video2");

var camera=document.getElementById("camera");
var microfone=document.getElementById("microfone");  


var isMicOpen=true;
var isCamOpen=true;

var side=window.location.search.substr(1).split("=")[1];
const peer = new Peer(currentUserSlug, { host: 'localhost', port: 9000, path: '/' })


navigator.mediaDevices.getUserMedia({audio:true,video:true})
    .then(function(stream){
        video2.srcObject=stream
        video2.play()
        video2.muted=true


        if(side=="caller"){
            var call=peer.call(other_user_slug,stream)
            call.on("stream",function(remoteStream){
                video1.srcObject=remoteStream
                video1.play()
            })
        }else{        
            peer.on("call",function(call){       
                var resCall=confirm("Videocall incoming, do you want to accept it ?");
                if(resCall){
                    call.answer(stream)
                    call.on("stream",function(remoteStream){
                        video1.srcObject=remoteStream
                        video1.play()
                    });
                }
                else{
                    console.log("declined.");
                }
                
            })

        }




    })
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