kybarg / react-qr-scanner

React component for reading QR codes using PC web camera or mobile phone camera.
MIT License
126 stars 40 forks source link

Turn on/off camera #21

Open drigos opened 4 years ago

drigos commented 4 years ago

Is there a way to turn camera off and on?

yeungma commented 4 years ago

Same question - how to turn off/on camera?

kybarg commented 4 years ago

@drigos @yeungma What do you mean by that? Do you want to stops video stream? OR phyisycally turn camera off?

yeungma commented 4 years ago

Hi, I don't know how to turn off camera by code. Just can do that by closing the app or browser tab.

On Wed, Nov 4, 2020, 01:40 Ruslan Kyba notifications@github.com wrote:

@drigos https://github.com/drigos @yeungma https://github.com/yeungma What do you mean by that? Do you want to stops video stream? OR phyisycally turn camera off?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kybarg/react-qr-scanner/issues/21#issuecomment-721277943, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQJNB3LGNFANDJ7KIIFX7LSOA6CFANCNFSM4M5T7MTQ .

piiok commented 3 years ago

The cam turn off when you unmount component

kevin-ping commented 3 years ago

this works for me in my react project

set a hook eg. const [camera, setCamear] = useState(false);

assign a button to toggle this hook, then use this hook to control 《QrReader》 in the render section {camera && 《QrReader》 }