-
Notifications
You must be signed in to change notification settings - Fork 0
/
person1.html
72 lines (63 loc) · 1.92 KB
/
person1.html
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Person 1</title>
<script src="https://unpkg.com/[email protected]/dist/peerjs.min.js"></script>
<style>
.container {
width: 560px;
margin: 0 auto;
}
.remote {
width: 100%;
height: 450px;
background-color: #191919;
}
.local {
width: 250px;
height: 250px;
background-color: #191919;
}
.local-video-wrapper {
display: flex;
justify-content: center;
}
</style>
</head>
<body>
<h1>Person 1</h1>
<div class="container">
<video class="remote" id="remote" src="" autoplay></video>
<div class="local-video-wrapper">
<video class="local" id="local" src="" autoplay></video>
</div>
<button type="button" id="call" onclick="initCall()">
Call Person 2
</button>
</div>
<script>
let id = "person-1"
let options = {
key: 'peerjs',
host: '13.233.197.233',
port: 9000,
path: '/peers',
debug: 3
}
var peer = new Peer(id, options);
function initCall() {
window.navigator.getUserMedia({video: true, audio: false}, function(stream){
let video = document.querySelector('#local');
video.srcObject = stream
let call = peer.call('person-2', stream)
call.on('stream', remoteStream => {
let video2 = document.querySelector('#remote')
video2.srcObject = remoteStream;
});
}, err => console.log(err));
}
</script>
</body>
</html>