Barcode Scanner app using Javascript for windows 8 tablet

I want to create a barcode scanner app in which i want to start the camera preview, and read the barcode. Is there any sample code? I have used the below code but its working only with windows desktop not working with tablet.
function openScanner() {
    var
        // barcode main objects
        zxing,
        sampler,
        element,
        // application  references
        isZxingInit = false,
        isDomReady = false,
        isVisible = false,
        isCancelled = false,
        raiseSuccess,
        raiseError;
    // init objects
    initZXing();
    initSampler().done(function () {
        console.log('- MediaCapture has been initialized successfully!');
        // preparing to show camera preview
        createCameraElement();
        showPanel();
        setTimeout(render, 100);
    }, raiseError);
    // initialize ZXing
    function initZXing() {
        if (!isZxingInit) {
            isZxingInit = true;
            zxing = new ZXing.BarcodeReader();
            console.log('zxing==' + zxing);
        } else {
            console.log('- ZXing instance has been recovered!');
    // initialize MediaCapture
    function initSampler() {
        console.log('- Initializing MediaCapture...');
        sampler = new Windows.Media.Capture.MediaCapture();
        return sampler.initializeAsync();
    // initializes dom element
    function createCameraElement() {
        console.log('- Creating DOM element...');
        if (!isDomReady) {
            isDomReady = true;
            element = document.createElement('video');
         //   element.style.display = 'none';
            element.style.position = 'absolute';
            element.style.left = '0px';
            element.style.top = '0px';
          //  element.style.zIndex = 2e9;
            element.style.width = '100%';
            element.style.height = '100%';
            element.onclick = cancel;
            document.body.appendChild(element);
            console.log('- Camera element has been created!');
        } else {
            console.log('- DOM is ready!');
    function showPanel() {
        if (!isVisible) {
            isCancelled = false;
            isVisible = true;
            element.style.display = 'block';
            element.src = URL.createObjectURL(sampler);
            element.play();
    // renders image
    function render() {
        console.log('- Sampling...');
        var frame, canvas = document.createElement('canvas');
        canvas.width = element.videoWidth;
        canvas.height = element.videoHeight;
        canvas.getContext('2d').drawImage(element, 0, 0, canvas.width, canvas.height);
        frame = canvas.msToBlob().msDetachStream();
        loadStream(frame);
    // loads data stream
    function loadStream(buffer) {
        console.log('- Loading stream...');
        Windows.Graphics.Imaging.BitmapDecoder.createAsync(buffer).done(function (decoder) {
            console.log('- Stream has been loaded!');
            if (decoder) {
                console.log('- Decoding data...');
                decoder.getPixelDataAsync().then(
                    function onSuccess(pixelDataProvider) {
                        console.log('- Detaching pixel data...');
                        decodeBitmapStream(decoder, pixelDataProvider.detachPixelData());
                    }, raiseError);
            } else {
                raiseError(new Error('Unable to load camera image'));
        }, raiseError);
    // decode pixel data
    function decodeBitmapStream(decoder, rawPixels) {
        console.log('- Decoding bitmap stream...');
        var pixels, format, pixelBuffer_U8;
        switch (decoder.bitmapPixelFormat) {
            // RGBA 16
            case Windows.Graphics.Imaging.BitmapPixelFormat.rgba16:
                console.log('- RGBA16 detected...');
                // allocate a typed array with the raw pixel data
                pixelBuffer_U8 = new Uint8Array(rawPixels);
                // Uint16Array provides a typed view into the raw bit pixel data
                pixels = new Uint16Array(pixelBuffer_U8.buffer);
                // defining image format
                format = (decoder.bitmapAlphaMode === Windows.Graphics.Imaging.BitmapAlphaMode.straight ? ZXing.BitmapFormat.rgba32 : ZXing.BitmapFormat.rgb32);
                break;
                // RGBA 8
            case Windows.Graphics.Imaging.BitmapPixelFormat.rgba8:
                console.log('- RGBA8 detected...');
                // for 8 bit pixel, formats, just use returned pixel array.
                pixels = rawPixels;
                // defining image format
                format = (decoder.bitmapAlphaMode === Windows.Graphics.Imaging.BitmapAlphaMode.straight ? ZXing.BitmapFormat.rgba32 : ZXing.BitmapFormat.rgb32);
                break;
                // BGRA 8
            case Windows.Graphics.Imaging.BitmapPixelFormat.bgra8:
                console.log('- BGRA8 detected...');
                // basically, this is still 8 bits...
                pixels = rawPixels;
                // defining image format
                format = (decoder.bitmapAlphaMode === Windows.Graphics.Imaging.BitmapAlphaMode.straight ? ZXing.BitmapFormat.bgra32 : ZXing.BitmapFormat.bgr32);
        // checking barcode
        readCode(decoder, pixels, format);
    // decoding barcode
    function readCode(decoder, pixels, format) {
        'use strict';
        console.log('- Decoding with ZXing...');
        var result = zxing.decode(pixels, decoder.pixelWidth, decoder.pixelHeight, format);
        if (result) {
            console.log('- DECODED: ', result);
            close(result);
        } else if (isCancelled) {
            console.log('- CANCELLED!');
            close({ cancelled: true });
        } else {
            render();
    // cancel rendering
    function cancel() {
        isCancelled = true;
    // close panel
    function close(result) {
        element.style.display = 'none';
        element.pause();
        element.src = '';
        isVisible = false;
        element.parentNode.removeChild(element);
        isDomReady = false;
        raiseSuccess(result);
    function raiseSuccess(result) {
        console.log('Result===' + JSON.stringify(result));
    function raiseError(error) {
        console.log('ERROR::::' + error);
Can anyone tell why its not working on tablet with solution? Thanks in advance

Hi Asha - we have sample code for barcode scanning here:
https://code.msdn.microsoft.com/windowsapps/Barcode-scanner-sample-f39aa411
Matt Small - Microsoft Escalation Engineer - Forum Moderator
If my reply answers your question, please mark this post as answered.
NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined
objects and unknown namespaces.

Similar Messages

  • Support for dynamic forms using javascript for android tablet

    I have some complex multipage pdf forms with javascript functions and calculations made in Acrobat X Standard, I can open and use parts of the form in ezyPDF android app, however the javascript is not fully supported, does anyone know of any plug ins or work arounds to view my forms on an android tablet, my forma have to be stand alone as internet access is not always available.
    Regards Mike

    Get to know CF's structure / array notation. This comes in
    very handy when dealing with queries and form fields.
    - Form.myFieldName can also be referenced by
    Form["myFieldName"]
    - MyQuery.myField can also be referenced by
    MyQuery["myField"][rowNumber]
    Anything in the above example surrounded by quotation makes
    can be made dynamic by just adding in a cf variable surrounded by
    pound signs:
    get_dealer_completion["level_#level_id#"][1]

  • How to get sharepoint online (office 365) data in cloud/windows azure (provider) hosted app using Javascript?

    How to get sharepoint online (office 365) data in cloud/windows azure (provider) hosted app using Javascript?
    I wish to retrieve sharepoint online data in html page (hosted in windows azure) using javascript and then need to play with AngularJS

    Hi,
    According to your description, you might want to get data from Office 365 SharePoint Online(also known as host web) and pass to the Provider Hosted App which is hosted
    in Windows Azure site.
    I would suggest you take a look at the links below about accessing data from the host web
     for a quick start:
    https://msdn.microsoft.com/en-us/library/office/fp179927(v=office.15).aspx#SP15Accessdatafromremoteapp_Codeexample
    http://dannyjessee.com/blog/index.php/2014/07/accessing-sharepoint-data-from-provider-hosted-apps-use-the-right-context/
    Aother sample solution for your reference:
    https://code.msdn.microsoft.com/SharePoint-2013-Get-the-0ec36bb6
    Best regards
    Patrick Liang
    TechNet Community Support

  • Apps for windows tablets

    Is it possible to produce apps for windows tablets with InDesign and Adobe DPS v30 at this moment?

    You can start testing by downloading Adobe Content Viewer from the Windows Store.
    Neil

  • HT4509 Barcode scanner app with international keyboard

    Hi,
    is there any barcode scanner app that can be used as an iternational keyboard:
    it should allow to be added from settings
    when this keyboard is selected, the camera should open, allowing to scan barcode, and using it in any app, as normal keyboard?
    thx

    barcode scanner is an electronic device for reading printed barcodes. Like a flatbed scanner, it consists of a light source, a lens and a light sensor translating optical impulses into electrical ones. Nearly all barcode readers contain decoder circuitry analyzing the barcode's image data

  • Barcode Scanner app

    There are quite a few Barcode Scanner apps available and I wonder if anyone can advise which is the best one to use? Thanks for your help.

    I prefer QR code scanner pro because it's works pretty well, and its free.
    BlackBerry Application Developer
    Eric Lewis

  • How to validate an text field item using javascript for numbers only.

    hi,
    how to validate an text field item using javascript for numbers only.please help me on this urgent
    please mail me solun if posible on [email protected]

    Hi,
    Page HTML header
    <script>
    function onlyNum(evt) {
      // Usage: onKeyPress="return onlyNum(event)"
      evt = (evt) ? evt : window.event;
      var charCode = (evt.which) ? evt.which : evt.keyCode;
      if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        var status = 'This field accepts numbers only!';
        alert(status);
        return false;
      var status = '';
      return true;
    </script>Item HTML Form Element Attributes
    onKeyPress="return onlyNum(event)"Br,Jari

  • Create barcode in Illustrator using Javascript

    Has anyone created a barcode in Illustrator using Javascript?

    Ask in Illustrator
    This forum is about the Cloud as a delivery process, not about using individual programs
    If you start at the Forums Index https://forums.adobe.com/welcome
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says All communities) to open the drop down list and scroll

  • When I attempt to upgrade an app in iTunes for windows, I get an error:  "Could not purchase.  An unknown error occurred (11111).  There was an error in the iTunes Store.  Please try again later"

    When I attempt to upgrade an app in iTunes for windows, I get an error:  "Could not purchase.  An unknown error occurred (11111).  There was an error in the iTunes Store.  Please try again later"
    I am running the latest iTunes 10.7.0.21 for Windows 7.
    This error occurs if I try to either update the app or if I delete it and attempt to redownload.
    I have an iPhone and an iPad.  I am unable to update the apps or install the apps from within the App Store on iOS.
    I do not have an AOL ID, as is a common issue with this type of error.
    From what I can tell, my Apple ID account seems fine.  I logged in, changed some information, and ensured my credit card is valid and updated.
    I can download new apps just fine.  I am unable to update or install apps I have purchased in the past.

    After 30 minutes this morning, no resolution. Then another tech support call this afternoon, 15 minutes in, was escalated to a Tier 2 (Senior) advisor. He said something similar to the above ("this is one of the strangest things I've seen"). He was chatted with iTunes guys and took all my info into the case and was escalating it over to engineering. Said they would be in touch.
    So, no solution...yet.
    Just to clarify:
    iTunes on Windows7: trying to update an existing app, or re-download a prior app, gives the (11111) error. Downloading a new (free) app worked fine.
    App Store on iPhone5, iOS 6.0.1: click on UPDATE, switches to INSTALLING...for a second, then switches back to UPDATE. No error message (and nothing in Diagnostic data).
    App Store on iPad 3, iOS 6.0.1: same as iPhone 5.
    Definitely account related.
    I have cleared the store cache, signed out and back in, deleted the credit card data, and re-added, rebooting PC and iPhone...nothing works.
    Will post if I hear anything back from Apple.

  • How can i edit psd files in PS touch or which software/app i need for androiud tablet (newest tablet)

    how can i edit psd files in PS touch or which software/app i need for androiud tablet (newest tablet) @samsung

    You can import PSD files into Photoshop Touch but the PSD file will be flattened. (The original, of course, will remain untouched; PS Touch just copies it upon import.) I imagine this was done as a failsafe measure since PS Touch has no support for masks or adjustment layers (not to mention that PS Touch only has support for about 12 layers).

  • Printer shared from my Mac is not seen from a PC using Bonjour for Windows

    I am going nuts here, hope someone can help.
    I have a Canon multi-function printer (MP830) attached via USB to a Mac G4 (with Mac OS X Tiger). At one time, I had it set so a Windows 2000 PC could print to it but deinstalled it after some printing issues, and have been unable to get to working again. The machines are connected together via a Netgear router. As far as I know, everything is the same as it was before, yet I cannot get it to work as it did.
    - The printer works fine from the Mac.
    - If I connect the printer to the PC, it works fine.
    - On the PC, using Bonjour for Windows, I cannot see the printer attached to the Mac but I can see, and print to, an Epson printer that is attached to a different Mac.
    - And from the second Mac, I am able to see -- but not successfully print to -- the Canon printer. The print job stays in the queue of the second Mac and says "Unable to connect to SAMBA host, will retry... Error: Connection failed with error."
    - I have tried:
    -- de-installing and re-installing Bonjour for Windows and the Canon print drivers on the PC
    -- and have de-installed and re-installed the Canon drivers on the Mac
    -- I have removed and re-added the Canon printer on the Mac. Printer Sharing is on, and this printer is checked in the Sharing box.
    Any suggestions?
    G4 Quicksilver and Dell PC with Windows 2000   Mac OS X (10.4.9)   Canon MP830

    Thank you. Those are beautifully written procedures.
    Looks like it's a network issue. I reach the step, "Adding a printer using the wizard":
    You must enter the following URL, you must use the Queue Name you noted down earlier
    http://<IP address of Mac>:631/printers/Queue Name
    which I do, entering
    http://192.168.0.4:631/printers/MP830
    and I get the following error:
    "Could not connect to the printer. You either entered a printer name that was incorrect or the specified printer is no longer connected to the server."
    And then I am toast!
    Using the other procedure, I simply don't see the Mac's printers in the Bonjour Wizard's "Browse for Bonjour Printers" window.
    Not sure where to go from here -- any ideas?
    The Mac's IP (set via DHCP) is 192.168.0.4, subnet mask 255.255.255.0. The PC is 192.168.0.5, I can't find the subnet mask.
    Pretty sure it's a network config issue, especially isnce I can Bonjour to my other Mac.
    TIA...

  • Help downloading & using Illustrator for Windows Vista 32 bit laptop

    Hello everyone:
    I'm new to Adobe forums and would like to ask if anyone knows how to work around using Illustrator for Windows Vista 32 bit laptop. I tried twice, yet won't allow download due to "system requirements." I'm trying to start with a free trial. Thanks for the assist in advance!

    As Mike said, CS6 is the last version to support Vista.
    Download CS6 products
    Creative Suite 6
    Mylenium

  • I am running Office 2013.  Trying to sync my reminders with my iphone using icloud for windows, but it is not working.  Can anyone please help?

    I am running Office 2013.  Trying to sync my reminders with my iPhone 5c version 7.1.2 using icloud for windows, but it is not working.  Can anyone please help?

  • While in Add/Remove Prog. in computer, I found apps named: iPOD for Windows 2006-03-23 (138 Mb) and another 2005-09-23 (106 Mb).  I'm trying trying to free up computer HD space.  What are these and can I delete either?

    While in Add/Remove Prog. in computer, I found apps named: iPOD for Windows 2006-03-23 (138 Mb) and another 2005-09-23 (106 Mb).  I'm trying trying to free up computer HD space.  What are these and can I delete either?

    Those are outdated iPod software updaters which can be safely deleted.
    (58627)

  • I have photoshop elements 2.0 for xp.  Is there a chance of using it for windows 8 ?

    I have photoshop elements 2.0 for xp.  Is there a chance of using it for windows 8 ?

    Hi jerryoops,
    Photoshop Elements 2.0 has not been tested and is incompatible for Windows 8.
    Please consider purchasing the latest version Photoshop Elements 11.0 which is compatible with Windows 8.

Maybe you are looking for

  • Mail server setup in this environment

    here's the environment: - od master on one xserve running 10.5.x, upgraded from 10.4.11 - od replica on second xserve running 10.5.x, upgraded from 10.4.11 - mail server on new xserve with fresh install of 10.5.x is it enough to have the mail server

  • Creation of backend contract from SRM system?

    Dear Experts, I am bit confused with the scenario of creation of backend contract from SAP SRM system? It says in few cases, based on the BAdi 'BBP_DETERMINE_Logsys', the system creates a backned contract directly in a backend ERP system. Why do we n

  • Dvd drive not worked properly

     i have  hp pavilion dv4 series.my dvd drive not worked properly.for that purpose only i went 7 times in your service centre but they won't take action  till now .why u people do like this .i want explation and just change my  dvd drive that's all.

  • Help with creating a price list

    I'm just wondering if anybody could possibly help me when creating a price list?. I'm new to SAP so don't have a great knowledge of it. Our company needs to send out a wholesale price list to customers, however some of the items we stock do not inclu

  • How can i get rid of iCloud from iTunes why did it murge?

    how can i delete iCloud from iTunes?