webcam-qr-barcode-scanner
Reactive icon

Webcam QR & Barcode Scanner

StableĀ versionĀ 1.0.0Ā (Compatible withĀ OutSystems 11)
Uploaded
 on 26 Jul (10 hours ago)
Ā byĀ 
0.0
Ā (0 ratings)
webcam-qr-barcode-scanner

Webcam QR & Barcode Scanner

Documentation
1.0.0

A high-performance, responsive Web Block to scan 1D & 2D barcodes (QR Code, EAN-13, CODE-128, DataMatrix, etc.) using webcams with auto-stop protection, built-in camera switching, and flexible control options.


🌟 Key Features

  • ⚔ Native Browser Scanning: Powered by html5-qrcode — zero native mobile plugins or extra app builds required.
  • šŸ›‘ Single-Scan Auto-Stop Protection: Automatically stops the camera stream immediately on success or error to prevent duplicate rapid scans and save battery.
  • šŸ“± Cross-Platform: 100% compatible with Reactive WebProgressive Web Apps (PWA), and Native Mobile Shells (iOS & Android).
  • šŸ”„ Built-in Camera Switcher (ShowCameraSwitch): Optional UI button to switch seamlessly between front (selfie) and back (environment) cameras.
  • āÆļø Manual & Auto Controls (ShowStart_StopButtons): Configure hands-free auto-scanning on load or display built-in Start/Stop UI control buttons.
  • šŸ“¦ Wide Barcode Support: Reads QR Code, EAN-13, EAN-8, CODE-39, CODE-128, UPC-A, UPC-E, DataMatrix, and PDF417.
  • šŸŽØ Customizable Viewfinder: Configurable scan box dimensions (QrBoxWidthQrBoxHeight), framerate (Fps), and extended CSS classes.
  • šŸ“¢ Reactive Event Handlers: Returns decoded value, format name, and error messages via native OutSystems block events.

šŸ’» Framework Compatibility

FrameworkSupported
OutSystems 11 (O11) Reactive Webāœ… Yes
OutSystems 11 (O11) Mobile / PWAāœ… Yes
OutSystems Developer Cloud (ODC)āœ… Yes
Traditional WebāŒ No (Use Reactive version)

šŸ“– User Manual & Technical Reference

1. Block Specification

šŸ“„ Input Parameters

Parameter NameData TypeMandatoryDefault ValueDescription
FacingModeTextFalse"environment"Initial camera: "environment" (rear camera) or "user" (front camera).
FpsIntegerFalse10Scanning frames per second (10–15 recommended).
QrBoxWidthIntegerFalse250Target scan box width in pixels.
QrBoxHeightIntegerFalse250Target scan box height in pixels.
AutoStartBooleanFalseTrueAutomatically start webcam stream when block renders.
ShowCameraSwitchBooleanFalseTrueDisplays built-in camera flip icon button on the scanner UI.
ShowStart_StopButtonsBooleanFalseFalseDisplays built-in "Start Scanner" & "Stop Scanner" control buttons.
ExtendedClassTextFalse""Additional CSS class(es) applied to the outer block container.

šŸ“¤ Block Events

Event NameParameter(s)Behavior
OnScanSuccessDecodedText (Text), FormatName (Text)Triggered when a valid code is detected. The camera scan automatically stops immediately after firing.
OnScanErrorErrorMessage (Text)Triggered if camera permission is denied or camera fails. The camera scan automatically stops.

āš™ļø Block-Level Public Client Actions

Parent screens can invoke these public actions directly on the block instance widget reference (e.g. MyScannerBlock.StartScanner):

Action NameScopeDescription
StartScannerBlock-Level (Public)Starts the camera video stream and scan loop manually for this block instance.
StopScannerBlock-Level (Public)Stops the camera stream and releases hardware resources for this block instance.
SwitchCameraBlock-Level (Public)Toggles active camera between front and rear lenses for this block instance.

2. Integration & Usage Patterns

Pattern A: Single Code Scan (Default / Hands-Free)

Ideal for lookup forms, search inputs, or product detail pages.

  1. Drag QRAndBarcodeScanner onto your Reactive Screen.
  2. Set AutoStartTrue.
  3. In the OnScanSuccess event handler:
    • Assign SearchVariable = DecodedText.
    • Execute your search query or navigate to the target page. (The camera automatically stops as soon as the code is read).

Pattern B: Continuous Multi-Item Scanning (Inventory / Shopping Cart)

Ideal for scanning multiple items sequentially without re-opening screens.

  1. Drag QRAndBarcodeScanner onto your screen and name the block widget ScannerWidget.
  2. In the OnScanSuccess event handler:
    • Add DecodedText to your items list or database.
    • Call ScannerWidget.StartScanner to instantly restart the camera for the next item!

Pattern C: Manual User Control

Ideal when users scan occasionally and you want to conserve device battery.

  1. Drag QRAndBarcodeScanner onto your screen.
  2. Set AutoStartFalse.
  3. Set ShowStart_StopButtonsTrue.
  4. Set ShowCameraSwitchTrue.
  5. Users can now click Start Scanner, switch cameras if needed, scan, and click Stop Scanner whenever they choose.

Pattern D: Parent Screen Button Controls

Ideal when you want custom action buttons outside the block on your screen.

  1. Drag QRAndBarcodeScanner onto your screen and set its Name to MyScanner.
  2. Set ShowStart_StopButtonsFalse.
  3. Add a custom button on your Parent Screen labeled "Scan Barcode".
  4. In the button's On Click action flow, call MyScanner.StartScanner.

šŸ” Troubleshooting & FAQ

Q: Why does the scanner show a black box or permission error on HTTP?

A: Web browsers restrict camera access (getUserMedia) exclusively to Secure Contexts (HTTPS) or localhost. Ensure your deployment environment has a valid SSL certificate.

Q: How do I prevent rapid duplicate scans?

A: Duplicate scans are automatically prevented! The component automatically invokes StopScanner immediately when OnScanSuccess fires.

Q: How do parent screens trigger StartScanner or SwitchCamera?

A: Because these actions are Public Block-Level Client Actions, simply give your Block widget a name on your screen canvas (e.g. MyScanner) and invoke MyScanner.StartScanner or MyScanner.SwitchCamera from any screen action!


šŸ“„ License & Contribution

  • Distributed under the MIT License. Free for commercial and non-commercial use in all OutSystems applications.