densen2014 / ZXingBlazor

Using ZXing Scan barcode/QR code in blazor
Apache License 2.0
93 stars 39 forks source link

Cannot enumerate devices, method not supported #12

Closed ricardoreveles3 closed 2 years ago

ricardoreveles3 commented 2 years ago
Captura de Pantalla 2022-03-28 a la(s) 17 04 35

Im having a problem to scann codes as the library trows an error.

densen2014 commented 2 years ago

The new version use JavaScript isolation in JavaScript modules

Blazor enables JavaScript (JS) isolation in standard JavaScript modules (ECMAScript specification).

JS isolation provides the following benefits:


[Destructive upgrade] The file Pages/_Host.cshtml or wasm project is wwwroot/index.html, no need to add references!!!!

If it is an upgrade from an older version, please remove the reference of zxing.js

!!REMOVE!!

!!REMOVE!!

. enjoy !

ricardoreveles3 commented 2 years ago

Thank you very much, I removed the scripts and no longer the error on load the JS is appear. But the error "Cant enumerate the devices, method not supported" remains

Captura de Pantalla 2022-03-29 a la(s) 8 52 04
parente89 commented 2 years ago

I also encountered the same problem. The solution is to set the project in https otherwise device enumeration will not be possible.

Currently, however, with the latest 0.21 update, if there are multiple acquisition devices connected, the plugin does not work. If there is only one device, it will boot quietly.

densen2014 commented 2 years ago

run in a phone?

ricardoreveles3 commented 2 years ago

On Mac (Latest update) and Google Chrome Versión 99.0.4844.84 (Build oficial) (x86_64)

densen2014 commented 2 years ago

Thank you very much, I removed the scripts and no longer the error on load the JS is appear. But the error "Cant enumerate the devices, method not supported" remains Captura de Pantalla 2022-03-29 a la(s) 8 52 04

try using https

densen2014 commented 2 years ago

On Mac (Latest update) and Google Chrome Versión 99.0.4844.84 (Build oficial) (x86_64)

may MacPro with only buildin camara no ploblem. but ver 0.2.1 yes has a bug, i was fixed and publish a new 0.2.2

densen2014 commented 2 years ago
  1. Create a new projet

    dotnet new blazorserver -o demo1
    dotnet sln add demo1/demo1.csproj
    dotnet add demo1 package ZXingBlazor
  2. In Pages/Index.razor

    
    @using ZXingBlazor.Components
    <button class="btn btn-primary"
        type="button"
        @onclick="(() => ShowScanBarcode = !ShowScanBarcode)">
    [Sacn]
    </button>
    <input type="text" class="form-control" style="min-width: 100px;"
       @bind-value="BarCode"
       placeholder="BarCode" />
    @if (ShowScanBarcode)
    {
    
    <BarcodeReader ScanResult="((e) => { BarCode=e; ShowScanBarcode = !ShowScanBarcode; })"
                   ShowScanBarcode="ShowScanBarcode"
                   Close="(()=>ShowScanBarcode=!ShowScanBarcode)"
                   ScanBtnTitle="Scan"
                   ResetBtnTitle="Reset"
                   CloseBtnTitle="Close"
                   SelectDeviceBtnTitle="Select Device" />

}

@code{ ///

/// Display the scan code interface /// bool ShowScanBarcode { get; set; } = false;

/// <summary>
/// BarCode
/// </summary>
public string? BarCode { get; set; }

private string message;

private Task OnError(string message)
{
    this.message = message;
    StateHasChanged();
    return Task.CompletedTask;
}

}


3. Run

cd demo1 dotnet run

ricardoreveles3 commented 2 years ago
Captura de Pantalla 2022-03-30 a la(s) 9 41 26

It has the same result

densen2014 commented 2 years ago

try https://zxingblazor.app1.es/

ricardoreveles3 commented 2 years ago
Captura de Pantalla 2022-03-30 a la(s) 11 05 13

The demo works fine

densen2014 commented 2 years ago
Captura de Pantalla 2022-03-30 a la(s) 11 05 13

The demo works fine

try run the source code =>Demo.Server

ricardoreveles3 commented 2 years ago

When I run the demo locally works, but when I deployed to internet does not work

Captura de Pantalla 2022-03-30 a la(s) 11 58 30
ricardoreveles3 commented 2 years ago

Im using docker to deployed to internet

densen2014 commented 2 years ago

Im using docker to deployed to internet

try https

Security getUserMedia() can only be called from an HTTPS URL or localhost. Otherwise, the promise from the call is rejected. getUserMedia() also doesn't work for cross-origin calls from iframes. For more information, see Deprecating Permissions in Cross-Origin Iframes.

All browsers generate an infobar upon the call to getUserMedia(), which gives users the option to grant or deny access to their cameras or microphones. Here's the permission dialog from Chrome:

densen2014 commented 2 years ago

Im using docker to deployed to internet

i try link your ip to my https://blazor.app1.es/ it works fine!

parente89 commented 2 years ago

Not work with more camera, for example in tablet

densen2014 commented 2 years ago

it using https or not?

parente89 commented 2 years ago

Https, but not even with the one published by you on github it works

densen2014 commented 2 years ago

Https, but not even with the one published by you on github it works

neither https://zxingblazor.app1.es/ ?

parente89 commented 2 years ago

Https, but not even with the one published by you on github it works

Screenshot_2022-03-30-20-58-28-759_com android chrome

Yes

densen2014 commented 2 years ago

try zxing officials demo

https://zxing-js.github.io/library/examples/barcode-camera/

parente89 commented 2 years ago

try zxing officials demo

https://zxing-js.github.io/library/examples/barcode-camera/

Yes it works

densen2014 commented 2 years ago

interesting , what brand and model is the tablet?

parente89 commented 2 years ago

interesting , what brand and model is the tablet?

i tried with notebook with windows 10 and it doesn't work. Lenovo tab m10 and not working. Xiaomi mi notes 10 and it doesn't work

parente89 commented 2 years ago

interesting , what brand and model is the tablet?

however I want to clarify that up to 0.20 it worked normally, but it was not customizable