mirror of
https://api.glitch.com/git/yaswvc
synced 2026-01-12 07:08:10 +00:00
🐂🐏 Checkpoint
./public/main.js:5975361/899 ./views/index.html:5975361/290
This commit is contained in:
parent
d76009cd32
commit
5f8e813b18
2 changed files with 32 additions and 18 deletions
|
|
@ -50,16 +50,19 @@ peer.on('connection', (conn) => {
|
||||||
|
|
||||||
// Handle incoming voice/video connection
|
// Handle incoming voice/video connection
|
||||||
peer.on('call', (call) => {
|
peer.on('call', (call) => {
|
||||||
console.log('INCOMING 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.
|
call.answer(stream); // Answer the call with an A/V stream.
|
||||||
renderVideo(stream, '#localVideo')
|
renderVideo(stream, '#localVideo');
|
||||||
call.on('stream', renderVideo);
|
call.on('stream', renderVideo);
|
||||||
})
|
// navigator.mediaDevices.getUserMedia({video: true, audio: true})
|
||||||
.catch((err) => {
|
// .then((stream) => {
|
||||||
console.error('Failed to get local stream', err);
|
// 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
|
// Initiate outgoing connection
|
||||||
|
|
@ -75,18 +78,34 @@ let connectToPeer = () => {
|
||||||
conn.send('hi!');
|
conn.send('hi!');
|
||||||
});
|
});
|
||||||
|
|
||||||
navigator.mediaDevices.getUserMedia({video: true, audio: true})
|
|
||||||
.then((stream) => {
|
|
||||||
let call = peer.call(peerId, stream);
|
let call = peer.call(peerId, stream);
|
||||||
call.on('stream', renderVideo);
|
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) => {
|
||||||
|
console.log('LOCAL STREAM')
|
||||||
|
stream = stream;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
logMessage('Failed to get local stream', err);
|
logMessage('Failed to get local stream', err);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
startLocalStream();
|
||||||
|
|
||||||
let disconnectFromPeer = () => {
|
let disconnectFromPeer = () => {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.disconnectFromPeer = disconnectFromPeer;
|
||||||
window.connectToPeer = connectToPeer;
|
window.connectToPeer = connectToPeer;
|
||||||
|
|
@ -42,10 +42,5 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer>Made with <a href="https://glitch.com">Glitch</a>!</footer>
|
<footer>Made with <a href="https://glitch.com">Glitch</a>!</footer>
|
||||||
|
|
||||||
<!-- include the Glitch button to show what the webpage is about and
|
|
||||||
to make it easier for folks to view source and remix -->
|
|
||||||
<div class="glitchButton" style="position:fixed;top:2em;right:20px;"></div>
|
|
||||||
<script src="https://button.glitch.me/button.js" defer></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue