Search code examples
javascriptandroidhtmlbrowserbarcode

Scanning barcode in Desktop-Browser using mobile


Is it possible that -

  • We scan a Bar-code by using Android device camera
  • Then plugging USB with a desktop
  • Passing the scanned Bar-code data from Mobile to PC
  • And filling a web-form opened in a browser in the desktop by using the data arriving through USB

If this is possible, can anyone suggest me how to implement this one? I have been looking for some solutions but those works only in mobile.


Solution

  • If you want to use an Android device camera, you don't need to connect the device to the USB port. Not like a webcam, there's no driver for opening Android camera straightforward on PC.

    A possible workaround:

    1. Use WebSocket for communication between the desktop browser (E.g. desktop.htm) and the mobile browser (E.g. mobile.htm).
    2. Use WebRTC (getUserMedia) to open Android camera in the mobile browser.
    3. Embed a JavaScript barcode SDK (E.g. ZXing or Dynamsoft JavaScript Barcode SDK) into your mobile web app.
    4. Read barcodes and sync results from mobile.htm to desktop.htm via WebSocket.