Skip to content
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

Can't set default camera to rear camera #151

Open
RuledesignerSRL opened this issue May 12, 2022 · 1 comment
Open

Can't set default camera to rear camera #151

RuledesignerSRL opened this issue May 12, 2022 · 1 comment

Comments

@RuledesignerSRL
Copy link

RuledesignerSRL commented May 12, 2022

I have the same problem as described in issue #59, I followed the directions for using MediaTrackConstraints and set the facingMode, but nothing happen. In order to write my code I took as a reference the example provided by you here

<webcam [height]="500" [width]="500" [trigger]="triggerObservable" (imageCapture)="handleImage($event)" [allowCameraSwitch]="true" [switchCamera]="nextWebcamObservable" [videoOptions]="videoOptions" [imageQuality]="1" (cameraSwitched)="cameraWasSwitched($event)" (initError)="handleInitError($event)" ></webcam>

public facingMode: string = 'environment'; public get videoOptions(): MediaTrackConstraints { const result: MediaTrackConstraints = {}; if (this.facingMode && this.facingMode !== '') { result.facingMode = { ideal: this.facingMode }; } return result; }

I use:

  • Angular 13.3.6
  • typescritp 4.6.4
@NajibIbrahim
Copy link

NajibIbrahim commented Jun 8, 2022

// 'user' = front camera || 'environment' = rear camera
facingMode = 'environment';

public get videoOptions(): MediaTrackConstraints {
    const result: MediaTrackConstraints = {};
    if (this.facingMode && this.facingMode !== '') {
        result.facingMode = { ideal: this.facingMode };
    }
    return result;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants