How to stop CameraPreview while it is starting. #321
Unanswered
frederikheld
asked this question in
Q&A
Replies: 1 comment
-
BTW: This is the solution I came up with. It works, but I'd consider it a workaround for something that is missing in the const retryItervalTimeout = setInterval(async () => {
try {
await CameraPreview.stop()
clearInterval(retryItervalTimeout)
} catch (error) { /* */ }
}, 100) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there any way to stop the CameraPreview instance before
start()
has resolved the promise?I use CameraPreview within a dialog component in a VueJS app. I watch the
dialogIsOpen
state to turn the CameraPreview on/off. When the dialog opens, I callCameraPreview.start()
. When the dialog closes, I callCameraPreview.stop()
.CameraPreview.start()
takes a while to resolve. If the user closes the dialog beforestart()
has resolved, the call will fail with the following errorUncaught (in promise) TypeError: Cannot read properties of null (reading 'getTracks')
and the camera will stay active.What would be the right way to prevent this?
Beta Was this translation helpful? Give feedback.
All reactions