/
video.html
60 lines (44 loc) · 1.23 KB
/
video.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
<html>
<head>
<title>VIDEO STREAMING </title>
</head>
<body bgcolor=lime>
<p><span id="errorMsg"></span></p>
<div>
<h1 id='h1' align=center > FACE RECOGNITION PROJECT DEMO </h1>
</div>
<div class="video-wrap" align=center>
<video id="video" playsinline autoplay></video>
</div>
<div align=center>
<button style="padding:30px;border-radius:10px;background-color:yellow;font-size:20px" id='click' value="New Tab" onclick="location.href='/confirm'" >CLICK TO PROCEED </button>
</div>
<!-- Webcam video snapshot -->
<script type='text/javascript'>
const video = document.getElementById('video');
const errorMsgElement = document.querySelector('span#errorMsg');
const constraints = {
audio: true,
video: {
width: 400, height:400
}
};
// Access webcam
async function init() {
try {
const stream = await navigator.mediaDevices.getUserMedia(constraints);
handleSuccess(stream);
} catch (e) {
errorMsgElement.innerHTML = `navigator.getUserMedia error:${e.toString()}`;
}
}
// Success
function handleSuccess(stream) {
window.stream = stream;
video.srcObject = stream;
}
// Load init
init();
</script>
</body>
</html>