From c316b8007ce1841563f0a1449ed09b31af7de771 Mon Sep 17 00:00:00 2001 From: asklie <760956257@qq.com> Date: Sat, 16 Nov 2024 18:24:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0isFocusModeSupported?= =?UTF-8?q?=E4=B8=8EisExposureModeSupported=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: asklie <760956257@qq.com> --- .../example/ohos/hvigor/hvigor-config.json5 | 3 +++ .../main/ets/io/flutter/plugins/camera/Camera.ets | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/camera/camera_ohos/example/ohos/hvigor/hvigor-config.json5 b/packages/camera/camera_ohos/example/ohos/hvigor/hvigor-config.json5 index 2a565d5d6..3323568cf 100644 --- a/packages/camera/camera_ohos/example/ohos/hvigor/hvigor-config.json5 +++ b/packages/camera/camera_ohos/example/ohos/hvigor/hvigor-config.json5 @@ -16,5 +16,8 @@ { "modelVersion": "5.0.0", "dependencies": { + }, + "properties": { + "ohos.nativeResolver": false } } \ No newline at end of file diff --git a/packages/camera/camera_ohos/ohos/src/main/ets/io/flutter/plugins/camera/Camera.ets b/packages/camera/camera_ohos/ohos/src/main/ets/io/flutter/plugins/camera/Camera.ets index ac26d2819..804d3bbf2 100644 --- a/packages/camera/camera_ohos/ohos/src/main/ets/io/flutter/plugins/camera/Camera.ets +++ b/packages/camera/camera_ohos/ohos/src/main/ets/io/flutter/plugins/camera/Camera.ets @@ -270,6 +270,10 @@ export class Camera implements CameraCaptureStateListener { } setFocusMode(result: MethodResult, newMode: camera.FocusMode) { + if (!this.getCurSession().isFocusModeSupported(newMode)) { + result.error("setFocusModeFailed", "The focus mode is unsupported.", null); + return; + } const autoFocusFeature: AutoFocusFeature = this.cameraFeatures.getAutoFocus(); autoFocusFeature.setValue(newMode); @@ -370,10 +374,10 @@ export class Camera implements CameraCaptureStateListener { // 设置曝光模式。 // 进行设置之前,需要先检查设备是否支持指定的曝光模式,可使用方法isExposureModeSupported。 setExposureMode(result: MethodResult, newMode: camera.ExposureMode) { - // if (CameraUtils.isExposureModeSupported(this.photoSession!, newMode)) { - // result.error("setExposureModeFailed", "The exposure mode is unsupported.", null); - // return; - // } + if (!CameraUtils.isExposureModeSupported(this.photoSession!, newMode)) { + result.error("setExposureModeFailed", "The exposure mode is unsupported.", null); + return; + } let modeExistence: boolean = false; Object.values(camera.ExposureMode).forEach(async (value) => { @@ -760,7 +764,7 @@ export class Camera implements CameraCaptureStateListener { this.captureFile = fs.openSync(videoUri, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); let fd = this.captureFile.fd; let displayRotation = display.getDefaultDisplaySync().rotation; - let previewRotation = this.previewOutput?.getPreviewRotation(displayRotation); + let previewRotation: camera.ImageRotation | undefined = this.previewOutput?.getPreviewRotation(displayRotation); // 当前录像配置 let aVRecorderConfig: media.AVRecorderConfig = { audioSourceType: media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC, -- Gitee