-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question - Turn camera off #41
Comments
Hi @u77171, there's no explicit way to turn off the camera through the component. But you can always remove the component from your page after you're done. Would that work for you? Cheers |
Same issue. Can you add a button that will call something like this? ^Scratch all that. I guess the problem is that some users still see the camera after the widget has been destroyed. Trying to find out which browsers, etc. |
Hi @queejie, Could you elaborate what issue you‘re experiencing? The camera and all active tracks are shut down and closed once the element is removed from the page (i.e. render it with an ng-if). Let me know if that helps. Thanks! |
Closing since no response from requestor. |
I am seeing this same thing. Users are reporting that after they leave the route that has the webcam component, their camera is still recording, indicated by the little red flashing icon on the tab in chrome. The view that uses the camera is super simple: @component({ @ViewChild('webcam-checker-container') webcamContainer: ElementRef; constructor( ngOnInit() { onSubmit = (): void => { @HostListener('window:resize', ['$event']) |
Hey @sstriano, Do you have a minimal demo that shows this behaviour? I‘m having troubles reproducing. The camera should turn itself off after the component is destroyed (shutdown code is present in the component‘s onDestroy() method). A minimal reproducible example would be great. Do you know if the behaviour is specific to a browser? Does it only affect some of your users? Are they all using the same app? Thanks for your help in finding the issue. |
@basst314 I'am facing the same issue, i'am using a modal from ngx-bootstrap with ngx-webcam. |
Same here |
Hi @bobbydowling can you provide more details about what you‘re experiencing and how you integrate with the webcam component? Have you tried adding an ng-if to the webcam component and set it to false if you want the webcam to disappear? A modal could just get hidden if closed but maybe it‘s not destroyed completely. Thanks |
I created an "ImageUpload" component that I load with the Material Dialog component. In that component, I merely copied the code from your demo, so it is already using ng-if on your component. When the Dialog is closed and also on Destroy, which happens when the dialog is closed, I set ng-if to falsey. I also unsubscribe from the Trigger subject, just in case. This happens using the Safari browser on an iPhone. Within the loaded component, when the webcam is visible, I get a red camera in the title bar. When the Dialog is closed and the component is destroyed (assuming), I get a red camera with a diagonal line down the middle, indicating the camera is still loaded, but the webcam is not visible. My concern is that this will eat the battery. Only option is for the user to reload the app. Happens always with all users. |
It's this: There appears to be nothing I can do to manually kill the inner Component. I would need a way to manually kill your component... and ngif is not working. |
I provided more info... what do you think? |
Hi @bobbydowling, it seems like Safari still indicates if the active page has permissions or was using WebRTC, even if the camera is no longer active. I found that the experience is the same when testing this official WebRTC demo on iPhone+Safari. First try selecting a resolution that the iPhone camera can support (e.g. HD), then select something too high, e.g. 8K. The camera stream closes, however the red camera icon with diagonal line is still shown in the Safari browser bar. Other browsers like Chrome on Desktop will also indicate permissions have been granted even if the camera is no longer active (red circle on tab title when active, greyed out camera symbol in browser bar when not active but permissions granted). This seems to align with the official WebRTC/UserMedia API documentation around privacy requirements that states:
Seems like this is what the camera symbol with diagonal line indicates. Hope this helps to clarify things. |
Hi, so i was struggling throughout the day to make the webcam stop record after an ngIf="false" was triggered somewhere over the component and i got this solution:
public cameraWasSwitched(deviceId: string): void {
im using the "showWebcam " as inner flag of a component that uses the ngx-webcam, its for hide/show element purposes. Anyway this might seem kinda obvious but it took me five good hours of my time, so i hope someone else can benefit from it. |
@basst314 here's an example that reproduces the problem |
@basst314 I think there's a sense to reopen this issue because there's a reproducable example above |
We are also running into this issue. Can we please reopen this and investigate? How can I help? |
I have the exact same problem of the example above! I've tried to apply the ngIf on wrapper div of the camera component, but the camera keeps open after the ngIf goes false and the dialog is closed. |
Thanks! It helped me a lot! I wrote it like this:
And the handleInitError would look like:
I've been working with Angular for a few weeks now, so I'm not fully familiarized with the language, but that was the solution I was able to do. |
What worked in my case is to apply fix to the webcam component itself (muhammad-usman-anwar@20c6dc6) and in addition to this close the subject by calling: |
I encountered the same problem, has anyone found a solution? |
I was wondering if there is a way to turn the camera off after you are done using it.
The text was updated successfully, but these errors were encountered: