From 5f8e813b1854d0f48a06cdc09518f7aa722d0ca1 Mon Sep 17 00:00:00 2001 From: "Glitch (peerjs-video)" Date: Mon, 7 Sep 2020 20:57:52 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=82=F0=9F=90=8F=20Checkpoint=20./publi?= =?UTF-8?q?c/main.js:5975361/899=20./views/index.html:5975361/290?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/main.js | 45 ++++++++++++++++++++++++++++++++------------- views/index.html | 5 ----- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/public/main.js b/public/main.js index f2c4689..41ed615 100644 --- a/public/main.js +++ b/public/main.js @@ -50,16 +50,19 @@ peer.on('connection', (conn) => { // Handle incoming voice/video connection peer.on('call', (call) => { - console.log('INCOMING CALL', call) - navigator.mediaDevices.getUserMedia({video: true, audio: true}) - .then((stream) => { - call.answer(stream); // Answer the call with an A/V stream. - renderVideo(stream, '#localVideo') - call.on('stream', renderVideo); - }) - .catch((err) => { - console.error('Failed to get local stream', err); - }); + console.log('INCOMING CALL', call); + call.answer(stream); // Answer the call with an A/V stream. + renderVideo(stream, '#localVideo'); + call.on('stream', renderVideo); + // navigator.mediaDevices.getUserMedia({video: true, audio: true}) + // .then((stream) => { + // call.answer(stream); // Answer the call with an A/V stream. + // renderVideo(stream, '#localVideo'); + // call.on('stream', renderVideo); + // }) + // .catch((err) => { + // console.error('Failed to get local stream', err); + // }); }); // Initiate outgoing connection @@ -75,18 +78,34 @@ let connectToPeer = () => { conn.send('hi!'); }); + let call = peer.call(peerId, stream); + call.on('stream', renderVideo); + // navigator.mediaDevices.getUserMedia({video: true, audio: true}) + // .then((stream) => { + // let call = peer.call(peerId, stream); + // call.on('stream', renderVideo); + // }) + // .catch((err) => { + // logMessage('Failed to get local stream', err); + // }); +}; + +let stream; +let startLocalStream = () => { navigator.mediaDevices.getUserMedia({video: true, audio: true}) .then((stream) => { - let call = peer.call(peerId, stream); - call.on('stream', renderVideo); + console.log('LOCAL STREAM') + stream = stream; }) .catch((err) => { logMessage('Failed to get local stream', err); }); -}; +} +startLocalStream(); let disconnectFromPeer = () => { } +window.disconnectFromPeer = disconnectFromPeer; window.connectToPeer = connectToPeer; \ No newline at end of file diff --git a/views/index.html b/views/index.html index 466cbfe..cd3413e 100644 --- a/views/index.html +++ b/views/index.html @@ -42,10 +42,5 @@ - - -
-