diff --git a/packages/image_picker/image_picker_ohos/example/ohos/entry/src/main/module.json5 b/packages/image_picker/image_picker_ohos/example/ohos/entry/src/main/module.json5 index 76168ed35e427f6297aafae9f062322dc0178cfa..1aeeb2da1b769819c2fdf57c01c550109e20938a 100644 --- a/packages/image_picker/image_picker_ohos/example/ohos/entry/src/main/module.json5 +++ b/packages/image_picker/image_picker_ohos/example/ohos/entry/src/main/module.json5 @@ -57,16 +57,6 @@ "when": "inuse" } }, - { - "name" : "ohos.permission.READ_IMAGEVIDEO", - "reason": "$string:EntryAbility_desc", - "usedScene": { - "abilities": [ - "EntryAbility" - ], - "when": "inuse" - } - } ] } } \ No newline at end of file diff --git a/packages/image_picker/image_picker_ohos/ohos/src/main/ets/image_picker/ImagePickerDelegate.ets b/packages/image_picker/image_picker_ohos/ohos/src/main/ets/image_picker/ImagePickerDelegate.ets index 6f689741772b3824ae80125e11d5b49ea6151119..7452eab44b9390694d04dc8c66558cd5b66a9d65 100644 --- a/packages/image_picker/image_picker_ohos/ohos/src/main/ets/image_picker/ImagePickerDelegate.ets +++ b/packages/image_picker/image_picker_ohos/ohos/src/main/ets/image_picker/ImagePickerDelegate.ets @@ -37,6 +37,7 @@ import HashMap from '@ohos.util.HashMap'; import UIAbility from '@ohos.app.ability.UIAbility'; import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; import { BusinessError } from '@ohos.base'; +import { cameraPicker, camera } from '@kit.CameraKit'; export default class ImagePickerDelegate { readonly REQUEST_CODE_CHOOSE_IMAGE_FROM_GALLERY = 2342; @@ -254,31 +255,14 @@ export default class ImagePickerDelegate { } async launchTakeVideoWithCameraWant(duration: number): Promise { - let want: Want = { - "action": wantConstant.Action.ACTION_VIDEO_CAPTURE, - parameters: { - callBundleName: "flutter_embedding", - "supportMultiMode": false, - durationLimit: duration - } + let pickerProfile: cameraPicker.PickerProfile = { + cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK, + videoDuration: duration } - abilityAccessCtrl.createAtManager() - .requestPermissionsFromUser(this.context, ['ohos.permission.READ_IMAGEVIDEO']) - .then(async (permission) => { - if(permission.authResults[0] !== 0){ - return - } - let result: ESObject = null; - if (this.context) { - result = await this.context.startAbilityForResult(want); - } - if (result && result.want && result.want.parameters) { - let uri = result["want"]["parameters"].resourceUri as string; - let code = result["resultCode"] as number; - this.handlerCaptureImageResult(code, uri); - } - }); + cameraPicker.pick(this.context, [cameraPicker.PickerMediaType.VIDEO], pickerProfile).then((pickerResult: cameraPicker.PickerResult) => { + this.handlerCaptureImageResult(pickerResult.resultCode, pickerResult.resultUri); + }) } async chooseImageFromGallery(options: ImageSelectionOptions, usePhotoPicker: boolean, result: Result>): Promise {