1
0
Fork 0
mirror of https://api.glitch.com/git/yaswvc synced 2026-01-12 05:28:10 +00:00

🐂🐏 Checkpoint

./public/main.js:5975361/899
./views/index.html:5975361/290
This commit is contained in:
Glitch (peerjs-video) 2020-09-07 20:57:52 +00:00
parent d76009cd32
commit 5f8e813b18
2 changed files with 32 additions and 18 deletions

View file

@ -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) => {
console.log('INCOMING CALL', call);
call.answer(stream); // Answer the call with an A/V stream.
renderVideo(stream, '#localVideo')
renderVideo(stream, '#localVideo');
call.on('stream', renderVideo);
})
.catch((err) => {
console.error('Failed to get local stream', err);
});
// 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!');
});
navigator.mediaDevices.getUserMedia({video: true, audio: true})
.then((stream) => {
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) => {
console.log('LOCAL STREAM')
stream = stream;
})
.catch((err) => {
logMessage('Failed to get local stream', err);
});
};
}
startLocalStream();
let disconnectFromPeer = () => {
}
window.disconnectFromPeer = disconnectFromPeer;
window.connectToPeer = connectToPeer;

View file

@ -42,10 +42,5 @@
</div>
<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>
</html>