uppload icon indicating copy to clipboard operation
uppload copied to clipboard

Call camera.close() when not using Camera service

Open shoesandsocks opened this issue 5 years ago • 5 comments

Is your feature request related to a problem? Please describe. It was not clear to me how to stop the Camera, after using an Uppload instance to take a webcam photo; the camera light stayed on and subsequent instances of Uppload didn't work correctly (services un-clickable).

Describe the solution you'd like I got lucky; in an unrelated Issue's code-snippet, I saw how another user was stopping the camera: https://github.com/elninotech/uppload/issues/113#issuecomment-613950372. Maybe a stripped-down version of @saqueib's code could go into the docs?

Describe alternatives you've considered ...

Additional context I think that's it. But maybe I missed it in the docs somewhere else?

Thanks, this is a neat solution.

shoesandsocks avatar Apr 23 '20 19:04 shoesandsocks

well, I'm still having some issues with the subsequent modals not working after a success. It's clearly a bigger architectural problem where I'm doing something dumb/wrong. Will close this.

shoesandsocks avatar Apr 23 '20 20:04 shoesandsocks

Let's keep this open and try and see how we can make sure the camera service auto-stops and works reliably in successive instances/opens.

AnandChowdhary avatar Apr 24 '20 09:04 AnandChowdhary

I might have figured out my problem; I made a mistake, as I expected. I am (for now) using React, and I was modifying the sample code on CodeSandbox here. In attempting to move away from a class-component, I refactored a bit; I also put the upload = new Uppload() and the upload.use() statements inside the functional component. Today I realized my mistake, pulled all of that out of the function, and it seems to work repeatedly. This plus the explicit camera.stop() in the on-close listener (a la #113), seems to have done the trick.

shoesandsocks avatar Apr 28 '20 19:04 shoesandsocks

Thanks for sharing! I think the camera.stop() should definitely be built-in when a user navigates away from the camera service or closes the modal. I thought I already added that, but since I didn't, I'll keep this issue open until I make that update shortly.

AnandChowdhary avatar Apr 29 '20 17:04 AnandChowdhary

@AnandChowdhary I think your code is indeed in place, but a little bug causes the camera to reopen after the modal is closed. I've proposed a solution in #345 - let me know if this is acceptable!

pedantic-git avatar Sep 21 '20 15:09 pedantic-git