ngx-webcam icon indicating copy to clipboard operation
ngx-webcam copied to clipboard

After unsubscribe, seems camera is still active

Open TLKG opened this issue 2 years ago • 3 comments

To utilize it:

import {WebcamImage, WebcamInitError, WebcamUtil} from 'ngx-webcam';
export class MyComponent implements OnInit, OnDestroy
{
...
private nextWebcam: Subject<boolean|string> = new Subject<boolean|string>();
constructor() { this.openWebCam();}
public get nextWebcamObservable(): Observable<boolean|string> 
    {
        return this.nextWebcam.asObservable();
    }
ngOnDestroy() 
{ 
  this.nextWebcam.unsubscribe(); 
...
}
}

After exiting the page, still shows image

image

How to completely cancel this camera service?

"ngx-webcam": "^0.3.2"
"@angular/core": "^12.1.4"

TLKG avatar Feb 04 '22 20:02 TLKG

I'm seeing this too

jakehockey10 avatar Mar 01 '22 17:03 jakehockey10

Same things here

josbol avatar May 11 '22 21:05 josbol

Hi, not sure why first PR is waiting for such a long time. I faced that issue, too and executing this.mediaStream.removeTrack(track); really helps.

Unfortunately it does not resolve the issue always (there still might be some delay of turning camera off). What worked in my case is to call this.nextWebcam.complete(); on the code that closes camera connection (triggered in closeModal method in my case).

https://github.com/basst314/ngx-webcam/issues/41

Just leaving my 2 cents on that for future users..PR created here: https://github.com/basst314/ngx-webcam/pull/155/commits/f5b237293b6e79299ec62a6ff2dabc762e963385

kamilhawdziejuk avatar Sep 13 '22 18:09 kamilhawdziejuk