<!DOCTYPE html>
<html>
    <head>
        <title>///////</title>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/instascan/1.0.0/index.js" integrity="sha512-QblNATV/gin5FC8tqTM2gfCMBei2qCzTte4O6CxGp8KQ5BgC5vNNGv99uTBvzmq+AFFYFoUNhowGOOJNTIBy6A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/instascan/1.0.0/index.min.js" integrity="sha512-ve8zzIbgiFFiUFW32RRJD+NBFRoVrGlhYfRLcTbQrqcFeazoPxhV03wWlyvDQE+/8GgZSMp+HqJlVBloc9D2vA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/instascan/1.0.0/src/camera.js" integrity="sha512-ENcWKhDaCzwCXldANkzeRmkQxeMxDuvrS8MkRH3/HSxVY9IFf3VNe4rAO1EeWxS5cey0eKHk+sF4ZltwVRVeeA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/instascan/1.0.0/src/camera.min.js" integrity="sha512-62PikEVTNQL5GTUTGJQCIbqkpu6gsrjkKVLVt3nm1UcGxuiXJE63rXt5Y8QHwjCN+8vKw6SBq5f2BbZOtI/rdg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/instascan/1.0.0/src/scanner.js" integrity="sha512-ffItW+oDx65pPgHhU7t4v3RQC5KP9qmpFwpLX1UPFSI19wQISo6y7Z6xjipVIQiUbXIJB/XhH545GvnguLpvWw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/instascan/1.0.0/src/scanner.min.js" integrity="sha512-4wgp0QqokkXAt6fuzisXfxI2u5vjPP8Sj5lRuT+f0fpmF0OcdkiKxr2byGgtJdUOi/jONy5BuRIJAORe0KmEaA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/instascan/1.0.0/src/zxing.js" integrity="sha512-jF+sEr/GWKk5++cVtC2KMK/6jHyIyzK2OB0+CG8zyIxJw2fgpMfY3UQUQPTHLHeFwkIDT2+wl5EcIvSq4NKKsg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/instascan/1.0.0/src/zxing.min.js" integrity="sha512-HTMvDnKIzrfcofgQyEdYQHLSuXwbExp6G17PzyaiuzDKmW5n+3DsTs2JHwLIpHtyq4iFk0le/EPQqUyfcpK4Hg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
   
   
   
    </head>
    <body>
        <video id="preview" <?php /* style="position:fixed;right:0;bottom:0;min-width:100%;min-height:100%;" */ ?>></video>
        <script type="text/javascript">
            let opts = {
                // Whether to scan continuously for QR codes. If false, use scanner.scan() to manually scan.
                // If true, the scanner emits the "scan" event when a QR code is scanned. Default true.
                continuous: true,
                // The HTML element to use for the camera's video preview. Must be a <video> element.
                // When the camera is active, this element will have the "active" CSS class, otherwise,
                // it will have the "inactive" class. By default, an invisible element will be created to
                // host the video.
                video: document.getElementById('preview'),
                // Whether to horizontally mirror the video preview. This is helpful when trying to
                // scan a QR code with a user-facing camera. Default true.
                mirror: false,
                // Whether to include the scanned image data as part of the scan result. See the "scan" event
                // for image format details. Default false.
                captureImage: false,
                // Only applies to continuous mode. Whether to actively scan when the tab is not active.
                // When false, this reduces CPU usage when the tab is not active. Default true.
                backgroundScan: true,
                // Only applies to continuous mode. The period, in milliseconds, before the same QR code
                // will be recognized in succession. Default 5000 (5 seconds).
                refractoryPeriod: 5000,
                // Only applies to continuous mode. The period, in rendered frames, between scans. A lower scan period
                // increases CPU usage but makes scan response faster. Default 1 (i.e. analyze every frame).
                scanPeriod: 1
            };
            let scanner = new Instascan.Scanner(opts);
      scanner.addListener('scan', function (content) {
        window.location = "result.php?result="+content;
      });
      Instascan.Camera.getCameras().then(function (cameras) {
        if (cameras.length > 0) {
          if(cameras.length > 1){
            scanner.start(cameras[1]);
          }
          else{
            scanner.start(cameras[0]);
          }
        } else {
          console.error('No cameras found.');
        }
      }).catch(function (e) {
        console.error(e);
      });
        </script>
    </body>
</html>