|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <meta http-equiv="Content-Type" content="text/html" />
- <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no" />
- <title>获取设备摄像头 getUserMedia</title>
- <style>
- #video {
- display: block;
- width: 240px;
- height: 240px;
- background: #000;
- border-radius: 5px;
- }
- </style>
- </head>
- <body>
- <div id="video"></div>
- <div>
- <button id="open">打开</button>
- <button id="close">关闭</button>
- </div>
- <div id="result"></div>
- </body>
- <script src="qrscan.js"></script>
- <script src="UPNG.js"></script>
- <script src="jsQR.js"></script>
- <script>
- var ds = null;
- var scan = new QRScan('video');
-
- document.getElementById('open').onclick = function () {
- scan.openScan();
- ds = window.setInterval(function () {
- startScan();
- }, 1500);
- };
- document.getElementById('close').onclick = function () {
- scan.closeScan();
- window.clearInterval(ds);
- };
-
- var re_div = document.getElementById('result');
- function startScan() {
- scan.getImgDecode(function (data) {
- console.log(data);
- var p = document.createElement('p');
- if (data.success) {
- p.innerHTML = 'RESULT: ' + data.payload;
- } else {
- p.innerHTML = 'ERROR: ' + data.msg;
- }
- re_div.appendChild(p);
- });
- };
- </script>
- </html>
- ————————————————
- 版权声明:本文为CSDN博主「onionLxy」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
- 原文链接:https://blog.csdn.net/onionLxy/article/details/96620455
|