-
Notifications
You must be signed in to change notification settings - Fork 34
/
video.html
45 lines (38 loc) · 1.22 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>QrcodeDecoder - Video</title>
</head>
<body>
<button id="start">Start</button> <button id="stop">Stop</button><br />
<span id="result">Click start to scan qrcode.</span><br />
<video src="./assets/qrcode-video.mp4"></video>
<script src="./lib/vconsole.min.js"></script>
<script src="./lib/index.min.js"></script>
<script type="text/javascript">
var vConsole = new VConsole();
function main() {
var video = document.querySelector('video');
var result = document.querySelector('#result');
var start = document.querySelector('#start');
var stop = document.querySelector('#stop');
var qr = new QrcodeDecoder.default();
start.onclick = startScan;
stop.onclick = function () {
qr.stop();
video.pause();
};
async function startScan() {
video.play();
const code = await qr.decodeFromVideo(video);
console.log('code', code);
result.innerText = 'Result: ' + code.data;
}
}
main();
</script>
</body>
</html>