-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathsimple.html
More file actions
60 lines (51 loc) · 1.61 KB
/
Copy pathsimple.html
File metadata and controls
60 lines (51 loc) · 1.61 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>simplest rtcninja demo</title>
<script src="../dist/rtcninja.js"></script>
<style>
#localVideo {
width: 30em;
height: 30em;
background-color: #00ff00;
}
</style>
</head>
<body>
<video id="localVideo" muted autoplay></video>
<script>
document.addEventListener("DOMContentLoaded", function(event) {
// Must first init the library
rtcninja();
// Then check.
if (!rtcninja.hasWebRTC()) {
console.log('WebRTC is not supported in your browser :(');
return;
}
console.log('Congrats! Your browser supports WebRTC (or a kind of ;)');
// Getting the user video and/or audio.
rtcninja.getUserMedia(
// Contraints.
{
video: true,
audio: true
},
// Success callback.
function (localStream) {
var video = document.querySelector('video');
video.src = window.URL.createObjectURL(localStream);
// Video element ready.
video.onloadedmetadata = function(e) {
// Do something with the video here.
};
},
// Error callback.
function (err) {
console.error('getUserMedia() failed: %s', err.toString());
}
);
});
</script>
</body>
</html>