Camera Light not turn off after CameraPreview.stop() called
See original GitHub issueHi @arielhernandezmusa ,
thanks to your capacitor plugin, i can put image overlay when taking picture in PWA, but there’s something strange about the camera behaviour.
When i called the CameraPreview.stop(), it did stop the camera but the green light is still on(i’m using mac). Is this a right behaviour ? i’m comparing itwith Camera PWA and it did stopped the light after i hit a close button.
i’m using Ionic React and the div is inside IonModal. stopCamera function will be called as hook function to App.tsx.
PhotoPreview.tsx
`const stopCamera = async ()=> { console.log(“stop triggered”); const result = await CameraPreview.stop(); console.log(result);
}`
app.tsx `const showCameraModalDismissHandler = () => { (stopCamera() as any).then( setShowCameraModal(false) )
}`
<IonModal onDidPresent={() => showCameraModalPresentHandler()} onWillDismiss={() => showCameraModalDismissHandler()} isOpen={showCameraModal}> <div id="cameraPreview" style={{flex: "1 1 0%",overflow: "hidden"}}></div> </IonModal>
Appreciate any feedback!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top GitHub Comments
i see @arochet, so you make it as global variable and make stop function become sync, will try it.
thanks for the insight and code! hope @arielhernandezmusa can give comment for it.
thanks
Hi,
Finally i decide to make my own camera preview. I keep the “tracks” of the stream global and i stop() them. Hope this help the developper to to fix the issue. The camera light turn off.
Html code :
and TypeScript Code
Customize as you want. I will improve it.
Thank you