QR Code scanning

Don’t worry about the loading indicator. It can be closed from Vaadin properties. Is your camera enabled?
IMG_9567.jpg

Yes, the camera is enabled

That emulator pic looks like you have OBS on your machine, and it’s using that as a video source. Not something that would happen on a phone.

Ok, so done couple extra tests. Had someone load your demo page and that appears to be working fine on a newer Android smartphone and on iPhone 14 Pro

My initial device is an older one, and after doing some tests I noticed that e.g. the web browser returns nothing for navigator.mediaDevices.enumerateDevices()

Also, a few conditions must be met, like using a HTTPs connection

That being said, it looks like your solution does work on more recent devices (I assume this is due to browser versions)

Now, I am just wondering why does your demo app keep showing the loading bar? I know that it can be removed, but why is that even happening, in the first place? Could the issue cause memory leaks, for example?

While the addon is loaded into page, it keeps trying to read video streams and decode qr/bar code. Haven’t seen memory leaks so far, it reset the reader on disconnecting.

Could you possibly share the code of your demo app? Built a very simple App and Layout for testing, and it keeps reloading over and over again…

Trying to isolate things so that I can spot what’s causing the reload once the reader is added to the layout

public class ZXingView extends VerticalLayout {

public ZXingView() {
    super();
    Label value1 = new Label();
    ZXingVaadinReader zXingVaadin1 = new ZXingVaadinReader();
    zXingVaadin1.setFrom(Constants.From.camera);

// zXingVaadin1.setId(“video”);
zXingVaadin1.setWidth(“350”);
zXingVaadin1.setStyle(“border : 1px solid gray”);
zXingVaadin1.addValueChangeListener(e->{
System.out.println(“====================================================”);
System.out.println(“=================QR=====:”+e.getValue());
System.out.println(“====================================================”);
value1.setText(e.getValue());
//remove(zXingVaadin1);
});
add(zXingVaadin1);
add(new Label(“”));
Button reset = new Button(“Reset”);
reset.addClickListener(event → {
zXingVaadin1.reset();
value1.setText(“”);
});
add(reset);
add(value1);
setAlignItems(Alignment.CENTER);
}

}

Thank you! I am still facing the same behavior… Using Vaadin 14.7.0 and the compatible ZXingVaadin version is 1.0.2-8

Maybe yours does work with more recent version(s)?

For instance, in ZXingVaadin 1.0.2-8 the reset method is not available

Also noticed that your demo shows the following html:

Note the id, especially

My version shows this: “

UPDATE: I set src to empty string and the id to some random value and it appears to be working!

Well done. The version for Java 8 is not the latest.