add instascan QR code Reader

This commit is contained in:
fred 2021-08-09 22:42:33 +02:00
parent 6b422d79cc
commit 2bbc5cd43c
1 changed files with 19 additions and 0 deletions

View File

@ -41,6 +41,7 @@ foreach ($videos as $v) {
<title>Astro CLUB</title>
<link rel="stylesheet" href="crowdbunker.css" type="text/css" />
<link rel="icon" type="image/png" href="./astrocrowdbunker.png" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="./instascan.min.js"></script>
</head>
<body>
@ -52,6 +53,9 @@ foreach ($videos as $v) {
</header>
<main>
<video id="preview"></video>
<?php
echo '<ul id="videosList">';
@ -80,6 +84,21 @@ echo '</ul>';
?>
</main>
<script type="text/javascript">
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
scanner.addListener('scan', function (content) {
alert(content);
});
Instascan.Camera.getCameras().then(function (cameras) {
if (cameras.length > 0) {
scanner.start(cameras[0]);
} else {
console.error('No cameras found.');
}
}).catch(function (e) {
console.error(e);
});
</script>
</body>
</html>