-
Notifications
You must be signed in to change notification settings - Fork 0
/
person2.html
71 lines (60 loc) · 1.81 KB
/
person2.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Person 2</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 2</h1>
<div class="container">
<video class="remote" id="remote" src="" autoplay></video>
<div class="local-video-wrapper">
<video id="local" class="local" src="" autoplay></video>
</div>
</div>
<script>
let id = "person-2"
let options = {
key : 'peerjs',
host: '13.233.197.233',
port: 9000,
path: '/peers',
debug: 3
}
var peer = new Peer(id, options);
peer.on('call', function(call){
window.navigator.getUserMedia({video: true, audio: false}, function(stream){
let video1 = document.querySelector('#local');
video1.srcObject = stream;
call.answer(stream)
call.on('stream', remoteStream => {
let video2 = document.querySelector('#remote');
video2.srcObject = remoteStream
})
}, err => console.log(err))
});
</script>
</body>
</html>