-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadme.html
78 lines (62 loc) · 1.52 KB
/
readme.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
76
77
78
<html>
<head>
<script>
//'use strict';
const constraints = {
audio: false,
video: {
width: 600, height: 300
}
};
function init2()
{
console.log("Init...");
const video = document.getElementById('video');
const canvas = document.getElementById('canvas');
const snap = document.getElementById("snap");
const errorMsgElement = document.getElementById('errorMsg');
// Draw image
var context = canvas.getContext('2d');
snap.addEventListener("click", function() {
context.drawImage(video, 0, 0, 640, 480);
});
}
// Access webcam
async function init() {
try {
const stream = await navigator.mediaDevices.getUserMedia(constraints);
handleSuccess(stream);
} catch (e) {
document.getElementById('errorMsg').innerHTML = `navigator.getUserMedia error:${e.toString()}`;
}
}
// Success
function handleSuccess(stream) {
//window.stream = stream;
video.srcObject = stream;
console.log("exito");
}
function fin()
{
const video = document.getElementById('video');
video.pause();
console.log("pausando..");
}
</script>
</head>
<body onload="init2();">
<button id="boton-start" onclick="init()">INICIAR</button>
<button id="boton-end" onclick="fin()">FINALIZAR</button>
<!-- Stream video via webcam -->
<div class="video-wrap">
<video id="video" playsinline autoplay></video>
</div>
<!-- Trigger canvas web API -->
<div class="controller">
<button id="snap">Capture</button>
</div>
<!-- Webcam video snapshot -->
<canvas id="canvas" width="640" height="480"></canvas>
<span id="errorMsg"></span>
</body>
</html>