Table of contents
Swift
Objective-C

This documentation is deprecated. It applies only to legacy version 9.x of Barcode Reader and must not be used for new development.

Please refer to the latest documentation and Migration Guide, which supersede this content.

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?

« Back to FAQ index

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();
});

This page is compatible for:

Is this page helpful?

YesYes NoNo