-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest8.8.3onFrameRead.html
40 lines (38 loc) · 1.71 KB
/
test8.8.3onFrameRead.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
</head>
<body>
<button id="btn-show-scanner">show scanner</button>
<script src="https://cdnjs.cloudflare.com/ajax/libs/eruda/2.4.1/eruda.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.3/dist/dbr.js" data-productKeys="PRODUCT-KEYS"></script>
<script>
eruda.init();
Dynamsoft.DBR.BarcodeReader._onLog = console.log;
// Dynamsoft.DBR.BarcodeReader._bUseFullFeature = true; // Control of loading min wasm or full wasm.
// scanner for decoding video
let pScanner = null;
var _this = {onFrameRead:function(results){
console.log(this,results);
}};
// decode video from camera
document.getElementById('btn-show-scanner').addEventListener('click', async () => {
try{
let scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
// scanner.onFrameRead = function(results){
// console.log(this,results);
// };
scanner.onFrameRead = _this.onFrameRead.bind(_this);
scanner.onUnduplicatedRead = (txt, result) => {
alert(result.barcodeFormatString + ': ' + txt);
};
await scanner.show();
}catch(ex){
alert(ex.message);
throw ex;
}
});
</script>
</body>
</html>