'ngx-webcam how to identify if user allowed webcam permission or not - Angular 4+

I'm having issue with ngx-webcam plugin in Angular4+, as i'm using this plugin to capture images in my application but when user doesn't allow permission of using webcam then I should make a change from capturing to upload a image from computer or mobile.

In this ngx-webcam plugin we do have, to turn on/off webcam but what i need is to identify if user gave permission or not to use webcame for capturing image.

I'm trying to get this resolved and searched a lot but couldn't find anything relevant to find whether a user allowed



Solution 1:[1]

  public handleInitError(error: WebcamInitError): void {
    if (error.mediaStreamError && error.mediaStreamError.name === 'NotAllowedError') {
      this.camPermission = true;
      console.warn('Camera access was not allowed by user!');
    }
  }
<webcam (initError)="handleInitError($event)"></webcam>

Solution 2:[2]

Display errors and then take action accordingly

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user3280493
Solution 2 Zia Khan