-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
43 lines (38 loc) · 1.2 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
<!DOCTYPE html>
<html>
<head>
<title>My WebRTC</title>
<style>
video {
position: absolute;
height: 100%;
width: 100%;
transform: scale(-1, 1);
}
</style>
<script>
// camera access works only in https
// github supports https also. So forward all http requests to https
// This is only work around as we don't have any control over github server.
// Otherwise redirection should happen in server not in client as it is not secure!
if (window.location.protocol != "https:") {
window.location.protocol = "https";
}
</script>
</head>
<body>
<video autoplay></video>
<script>
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
var constraints = { audio: false, video: true};
var video = document.querySelector("video");
function successCallback(stream) {
video.src = window.URL.createObjectURL(stream);
}
function errorCallback(error){
console.log("getUserMedia error: ", error);
}
navigator.getUserMedia(constraints, successCallback, errorCallback);
</script>
</body>
</html>