34 lines
1.2 KiB
HTML
34 lines
1.2 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Instascan</title>
|
|
<!-- script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script -->
|
|
<!-- script src="https://rawgit.com/schmich/instascan-builds/master/instascan.min.js"></script -->
|
|
<script src="/static/instascan.min.js"></script>
|
|
</head>
|
|
<body>
|
|
<video style="outline:none; width:90%;" id="preview"></video>
|
|
<script type="text/javascript">
|
|
let options = {
|
|
video: document.getElementById('preview'),
|
|
mirror: false,
|
|
};
|
|
let scanner = new Instascan.Scanner(options);
|
|
scanner.addListener('scan', function (content) {
|
|
window.location.replace(content);
|
|
});
|
|
Instascan.Camera.getCameras().then(function (cameras) {
|
|
if (cameras.length > 1) {
|
|
scanner.start(cameras[1]);
|
|
} else if (cameras.length > 0) {
|
|
scanner.start(cameras[0]);
|
|
} else {
|
|
console.error('No cameras found.');
|
|
}
|
|
}).catch(function (e) {
|
|
console.error(e);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|