【发布时间】:2019-01-27 12:48:07
【问题描述】:
Ionic 3 摄像头访问代码
takePhoto(flag) {
return new Promise((resolve, reject) => {
var sourceType: any;
if (flag == "PHOTOLIBRARY") {
sourceType = this.camera.PictureSourceType.PHOTOLIBRARY;
} else {
sourceType = this.camera.PictureSourceType.CAMERA;
}
const options: CameraOptions = {
quality: 50,
sourceType: sourceType,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
targetWidth: 450,
targetHeight: 450,
saveToPhotoAlbum: false,
correctOrientation: true,
cameraDirection: this.camera.Direction.FRONT
};
this.camera.getPicture(options).then(
imageData => {
resolve(imageData);
})
})
}
**在使用后置摄像头时它可以工作,但是当我们更改 CameraOptions 的 cameraDirection 但仍然打开后置摄像头时**
【问题讨论】:
标签: angularjs typescript cordova ionic-framework ionic3