How to stop the camera stream from opening right away after DBR-JS demo is loaded? How to enable the camera on the click of a button?
Version 10
let startScanBtn = document.getElementById("StartScanning"); // double check the ID of the button
version 9
Instead of creating the BarcodeScanner
instance on page load, trigger the creation on the click of the Start Scanning
button instead, as shown in the sample code below -
let startScanBtn = document.getElementById("StartScanning"); // double check the ID of the button
startScanBtn.addEventListener("click", async function () {
let scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
scanner.onFrameRead = (results) => {
console.log(results);
};
scanner.onUniqueRead = (txt, result) => {
alert(txt);
};
await scanner.show();
});