-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreceiver.js
More file actions
31 lines (22 loc) · 744 Bytes
/
receiver.js
File metadata and controls
31 lines (22 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
document.addEventListener('DOMContentLoaded', (event) => {
const peer = new Peer("receiver",
{
host: "localhost",
port: 9000,
path: "/"
});
let localStream = null;
const startChat = async () => {
localStream = await navigator.mediaDevices.getUserMedia({
video: true
});
document.querySelector('video#local').srcObject = localStream;
}
startChat();
peer.on("call", (call) => {
call.answer(localStream);
call.on("stream", remoteStream => {
document.querySelector('video#remote').srcObject = remoteStream;
});
});
});//end DOMContentLoaded