You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<divid="reader"></div>
<script>
import { onDestroy, onMount } from'svelte'import {Html5QrcodeasScanner, Html5QrcodeSupportedFormatsasScannerFormats} from"html5-qrcode"// set camera label you want here if you have more than oneconstdocCameraLabel='blah blah'// expose barcode data to other componentslet barcodeData =''asyncfunctiongetQRData (scanner, deviceID) {returnnewPromise((resolve, reject) => {returnscanner.start(deviceID, { fps:10, }, (decodedText, decodedResult) => {resolve(decodedText) }, (msg, err) => {if (msg.indexOf("NotFoundException") >=0) {return }reject(err) }) })}asyncfunctiongetCamera () {constscanner=newScanner("reader", { formatsToSupport: [ScannerFormats.QR_CODE,ScannerFormats.PDF_417, ] }, false);try {constvideoInputDevices=awaitScanner.getCameras()for (let dev of videoInputDevices) {// you can log the device label here to see what to use above,// or just use the first one, etc.// console.log(dev.label)if (dev.label=== docCameraLabel) {constdata=awaitgetQRData(scanner, dev.id)scanner.stop()return data } } } catch (err) {scanner.stop()throw err }}onMount(() => {getCamera().then(data=> {console.log(data) barcodeData = data }, console.error)})onDestroy(() => {scanner.stop()})
</script>
<style>
</style>
Source: mebjas#354 (comment)
Fork: trasherdk/qrcode-scanner
The text was updated successfully, but these errors were encountered: