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

299
Views
Error de obtención de WebRTC, no puedo encontrar ese problema

Parece que todo está bien, pero tengo un error. ¡No puedo encontrar el error de donde viene! Espero que alguien pueda ayudarme aquí, por favor https://gabrieltanner.org/blog/webrtc-video-broadcast

El error es SyntaxError no detectado:

El identificador 'video' ya ha sido declarado

Broadcast.js :

 const peerConnections = {}; const config = { iceServers: [ { "urls": "stun:stun.l.google.com:19302", }, // { // "urls": "turn:TURN_IP?transport=tcp", // "username": "TURN_USERNAME", // "credential": "TURN_CREDENTIALS" // } ] }; const socket = io.connect(window.location.origin); const video = document.querySelector('video'); const constraints = { video: {facingMode: "user"} }; navigator.mediaDevices .getDisplayMedia(constraints) .then(stream => { video.srcObject = stream; socket.emit("broadcaster"); }) .catch(error => console.error(error)); socket.on("watcher", id => { const peerConnection = new RTCPeerConnection(config); peerConnections[id] = peerConnection; let stream = video.srcObject; stream.getTracks().forEach(track => peerConnection.addTrack(track, stream)); peerConnection.onicecandidate = event => { if (event.candidate) { socket.emit("candidate", id, event.candidate); } }; peerConnection .createOffer() .then(sdp => peerConnection.setLocalDescription(sdp)) .then(() => { socket.emit("offer", id, peerConnection.localDescription); }); }); socket.on("answer", (id, description) => { peerConnections[id].setRemoteDescription(description); }); socket.on("candidate", (id, candidate) => { peerConnections[id].addIceCandidate(new RTCIceCandidate(candidate)); }); socket.on("disconnectPeer", id => { peerConnections[id].close(); delete peerConnections[id]; }); window.onunload = window.onbeforeunload = () => { socket.close(); };
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!