-
Notifications
You must be signed in to change notification settings - Fork 0
/
camfeed.html
59 lines (49 loc) · 1.66 KB
/
camfeed.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Camera</title>
<video id="myVidPlayer" controls muted autoplay></video>
<button onclick="snapshot()" >Snapshot</button>
<div class="mycanvas">
<h6>Captured snapshot</h6>
<canvas></canvas>
</div>
</head>
<body>
</body>
</html>
<script type="text/javascript">
var canvas = document.querySelector("canvas");
var context = canvas.getContext("2d");
const video = document.querySelector('#myVidPlayer');
//w-width,h-height
var w, h;
canvas.style.display = "none";
//new
function snapshot(){
context.fillRect(0, 0, w, h);
context.drawImage(video, 0, 0, w, h);
canvas.style.display = "block";
}
window.navigator.mediaDevices.getUserMedia({ video: true, audio: true })
.then(stream => {
video.srcObject = stream;
video.onloadedmetadata = (e) => {
video.play();
//new
w = video.videoWidth;
h = video.videoHeight
canvas.width = w;
canvas.height = h;
};
})
.catch(error => {
alert('Please Enable The Camera Permission!');
});
if (window.location.href== "http://127.0.0.1:5500/camfeed.html") {
alert("Welcome To CamFeed Software v1.0 - Developed By shoelaze");alert("We Value Your Privacy So , We Don't Collect Any Information In This Page. Enjoy!")
}
</script>