<webcam (imageCapture)="imageCaptured($event)" [trigger]="capture$" (initError)="handleInitError($event)">
默认情况下,手机上的real camera处于打开状态。我想在默认情况下设置前置摄像头。
olmpazwi1#
https://developer.mozilla.org/en-us/docs/web/api/mediatrackconstraints/facingmodecamera.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">
1条答案
按热度按时间olmpazwi1#
https://developer.mozilla.org/en-us/docs/web/api/mediatrackconstraints/facingmode
camera.component.ts
camera.component.html