Reputation:
<webcam (imageCapture)="imageCaptured($event)" [trigger]="capture$" (initError)="handleInitError($event)">
On mobile real camera open by default. I want to set front camera by default.
Upvotes: 1
Views: 3441
Reputation: 483
https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/facingMode
camera.component.ts
//facingMode: string = 'environment'; Set rear camera
facingMode: string = 'user'; //Set front camera
allowCameraSwitch = false;
public get videoOptions(): MediaTrackConstraints {
const result: MediaTrackConstraints = {};
if (this.facingMode && this.facingMode !== '') {
result.facingMode = { ideal: this.facingMode };
}
return result;
}
camera.component.html
<webcam (imageCapture)="imageCaptured($event)" [trigger]="capture$" (initError)="handleInitError($event)" [videoOptions]="videoOptions" [allowCameraSwitch]="allowCameraSwitch">
Upvotes: 1