You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.4 KiB
HTML
40 lines
1.4 KiB
HTML
![]()
7 years ago
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>QrcodeDecoder - Camera</title>
|
||
|
</head>
|
||
|
<body>
|
||
|
<button id="start">Start</button> <button id="stop">Stop</button><br />
|
||
|
<span id="result">Click start to scan qrcode.</span><br />
|
||
|
<hr />
|
||
|
<video id="video" autoplay></video>
|
||
|
|
||
|
<script src="./index.aio.min.js"></script>
|
||
|
<script type="text/javascript">
|
||
|
function main() {
|
||
|
var qr = new QrcodeDecoder();
|
||
|
var video = document.querySelector('#video');
|
||
|
var start = document.querySelector('#start');
|
||
|
var stop = document.querySelector('#stop');
|
||
|
var result = document.querySelector('#result');
|
||
|
async function startScan() {
|
||
|
if (!qr.isCanvasSupported()) {
|
||
|
alert("Your browser doesn't match the required specs.");
|
||
|
throw new Error('Canvas and getUserMedia are required');
|
||
|
}
|
||
|
|
||
|
let code = await qr.decodeFromCamera(video);
|
||
|
console.log('code', code);
|
||
|
result.innerText = "Result: " + code.data;
|
||
|
}
|
||
|
start.onclick = startScan;
|
||
|
|
||
|
stop.onclick = function() {
|
||
|
qr.stop();
|
||
|
};
|
||
|
}
|
||
|
main();
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|