HarmonyOS 关于系统相机拍照染回的resultUri的问题

结果里面发现resultUri一直没有值

代码如下

try {
  let pickerProfile: picker.PickerProfile = {
    cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK
  };
  picker.pick(getContext(),
    [picker.PickerMediaType.PHOTO, picker.PickerMediaType.VIDEO], pickerProfile).then((pickerResult: picker.PickerResult) => {
    callBack('1111')
  }).catch((err: BusinessError) => {
  })
} catch (error) {
  let err = error as BusinessError;
  console.error(`the pick call failed. error code: ${err.code}`);
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.

其中pickerResult里面的resultUri一直处于undefined

HarmonyOS
2024-12-26 14:25:36
1318浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
FengTianYa

进入相机后,如果直接按下"X"会返回的空,如果拍了照片按下"√"才会有uri值:

import picker from '@ohos.multimedia.cameraPicker';
import camera from '@ohos.multimedia.camera';
import common from '@ohos.app.ability.common';
import { BusinessError } from '@ohos.base';

let mContext = getContext(this) as common.Context;

async function demo() {
  try {
    let pickerProfile: picker.PickerProfile = {
      cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK
    };
    let pickerResult: picker.PickerResult = await picker.pick(mContext,
      [picker.PickerMediaType.PHOTO, picker.PickerMediaType.VIDEO], pickerProfile);
    console.log("demo the pick pickerResult is:" + JSON.stringify(pickerResult));
  } catch (error) {
    let err = error as BusinessError;
    console.error(`the pick call failed. error code: ${err.code}`);
  }
}

async function demo2() {
  try {
    let pickerProfile: picker.PickerProfile = {
      cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK
    };
    picker.pick(getContext(),
      [picker.PickerMediaType.PHOTO, picker.PickerMediaType.VIDEO], pickerProfile)
      .then((pickerResult: picker.PickerResult) => {
        console.log("demo2 the pick pickerResult is:" + JSON.stringify(pickerResult));
    }).catch((err: BusinessError) => {
    })
  } catch (error) {
    let err = error as BusinessError;
    console.error(`the pick call failed. error code: ${err.code}`);
  }
}

@Entry
@Component
struct Index {
  @State message: string = 'Hello World';

  build() {
    Row() {
      Column() {
        Button("test").onClick(() => {
          demo2();
        })
      }
      .width('100%')
    }
    .height('100%')
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
分享
微博
QQ
微信
回复
2024-12-26 15:46:40
相关问题
关于如何使用相机拍照模块拍照问题
2569浏览 • 0回复 待解决
如何调用系统相机拍照
2520浏览 • 1回复 待解决
HarmonyOS 调用相机拍照问题
809浏览 • 1回复 待解决
HarmonyOS 如何调用系统相机进行拍照
1350浏览 • 1回复 待解决
HarmonyOS 相机拍照镜头问题
628浏览 • 1回复 待解决
HarmonyOS 关于切换前后相机问题
847浏览 • 1回复 待解决
HarmonyOS 相机旋转横屏拍照问题
1087浏览 • 1回复 待解决
如何调用系统相机拍照、录视频?
985浏览 • 1回复 待解决
有哪位知道怎样调用系统相机拍照
2493浏览 • 1回复 待解决
HarmonyOS h5调用系统相机进行拍照
824浏览 • 1回复 待解决
HarmonyOS 拉起相机拍照
978浏览 待解决
HarmonyOS 相机拍照模糊
1293浏览 • 0回复 待解决
HarmonyOS 相机-拍照之后预览
1401浏览 • 1回复 待解决