index.html 780 B

12345678910111213141516171819202122232425
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Instascan</title>
  5. <script type="text/javascript" src="https://rawgit.com/schmich/instascan-builds/master/instascan.min.js"></script>
  6. </head>
  7. <body>
  8. <video id="preview"></video>
  9. <script type="text/javascript">
  10. let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
  11. scanner.addListener('scan', function (content) {
  12. console.log(content);
  13. });
  14. Instascan.Camera.getCameras().then(function (cameras) {
  15. if (cameras.length > 0) {
  16. scanner.start(cameras[0]);
  17. } else {
  18. console.error('No cameras found.');
  19. }
  20. }).catch(function (e) {
  21. console.error(e);
  22. });
  23. </script>
  24. </body>
  25. </html>