forked from MrSwitch/peer.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
75 lines (60 loc) · 1.32 KB
/
index.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
73
74
75
<!DOCTYPE html>
<html>
<head>
<script src="tb.js"></script>
<script src="/socket.io/socket.io.js"></script>
<style>
video{
width:300px;
height:300px;
border:1px solid #eee;
}
video.mine{
background:#069;
}
</style>
</head>
<body>
<h1>WebRTC</h1>
<video class="mine"></video>
<script>
var publisher = TB.initPublisher('video').on({
started : function(){
// Flip content horizontally
publisher.el.style.webkitTransform = "scaleX(-1)";
console.log('The users media has been bound to the page');
},
failure : function(event){
console.error( "Camera not available: " + (event&&event.code===1
?'user denied'
:'unknown'));
}
});
var session = TB.initSession();
session.on({
sessionConnected : function(event){
console.log('hurrah, connected to session');
session.publish(publisher);
},
streamCreated : function(event){
var video = document.createElement('video');
video.src = window.URL.createObjectURL(event.stream);
video.autoplay = true;
video.onerror = function(){
alert('streamdestroyed');
}
document.body.appendChild(video);
},
streamDestroyed : function(event){
console.log('streamdestroyed');
},
message : function(event){
console.log('message');
console.log(event);
},
connectionDestroyed : function(){}
});
session.connect();
</script>
</body>
</html>