eroself / vaadin-litelement-zxing

ZXing integration on Vaadin 14
MIT License
0 stars 4 forks source link

Close Video-Stream after successful scan #5

Open Thraze opened 2 years ago

Thraze commented 2 years ago

Hello,

first of all thanks for an awesome plugin. It works like a charm.

I have just one question. I use the ZXingVaadinReader in my Vaadin application in a normal view/verticalLayout and show it after a button is pressed. The button then is set invisible and the ZXingVaadinReader is added to the layout.

If the scan is successful I remove the ZXingVaadinReader and show the button again. The only thing remaining is my browser keeps filming (Webcam lights up and browser indicates camera usage). Is there a way to shutdown the videostream afterwards and restart again later?

I tried already:

Nothing seems to work. How are you dealing with it? Even if I switch to another layout/tab the browser keeps using the camera.

I try to achieve a use case where I can go to a tab, press a scan button, camera-stream is shown until a QR-Code is scanned and then it goes back to the default view, without the browser keeps indicating the camera usage. Especially on mobile the smartphone gets really warm after some time, so you can tell that it keeps shooting even though you can't see the output.

Appreciate any hints.

Thanks, Thraze

eroself commented 1 year ago

If it's in a normal view/verticalLayout, you could just remove the zxing component after scanning by zXingComponent.addValueChangeListener(e->{ remove(zXingComponent); });