hamidrezahy / Blazor.QRCode

9 stars 1 forks source link

Sample project doesn't work #3

Open MrYossu opened 2 years ago

MrYossu commented 2 years ago

Thanks for adding the sample project, however it doesn't work.

As I commented in issue #2 , your JavaScript is incorrect. The variable you use inside one of the functions doesn't match the name of the parameter, so you get an error. See the issue there for more details.

However, even if I copy the JavaScript out, correct it and put it in a file which I link instead of the JavaScript from the package, it still doesn't work.

I modified your sample code to look like this...

@page "/"

<PageTitle>Index</PageTitle>

<QrCode ElementId="id"
        Width="150"
        height="150"
        Text="hamidrez77@gmail.com">
</QrCode>
<br />
<QrCodeReader Width="400" OnDetect="@DetectCallBack" OnError="@ErrorCallBack" />

@code
{

  public void DetectCallBack(string detectedString) => Console.WriteLine($"DetectCallBack: {detectedString}");

  public void ErrorCallBack(string errormesg) => Console.WriteLine($"ErrorCallBack: {errormesg}");
}

When I click the Start scanning button, I see masses of lines in the console window, all identical...

blazor.webassembly.js:1 ErrorCallBack: QR code parse error, error = TypeError: Cannot read properties of null (reading 'getContext')

Pointing my webcam at a QR code doesn't do anything, presumably because of this error.

Any ideas what the issue is?

As a side point, the Width properties on your two components are inconsistent. The QrCode component takes a plain number, whereas the QrCodeReader component requires a unit as well, eg 600px. This is confusing.

Thanks

MrYossu commented 2 years ago

@hamidrezahy Any chance you can take a look at this? I'd really like to use the component, but can't get it working.

Thanks

hamidrezahy commented 2 years ago

Hello sorry for the delay I will definitely check at the first opportunity, but I need to say these things The sample project works perfectly for me in creating the barcode But the barcode reader has a bug and I have no idea why, and this is while the barcode reader was used in a real project and worked perfectly

MrYossu commented 2 years ago

@hamidrezahy Yes, the barcode creator worked fine, it was the reader that wasn't working.

As I said, there is an error in the JavaScript, but even fixing that, I still get errors when trying to read a QR code.

Please keep me posted if you can find out what the problem is.

Thanks