HarmonyOS cameraPicker录像时,相机黑屏?

cameraPicker录像时,若传入了saveUri,相机会黑屏。

参考代码:

let fileUri = getContext(this).cacheDir + '/test.mp4';
let file = fileIo.openSync(fileUri, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE);
const pickerProfile: cameraPicker.PickerProfile = {
  cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK,
  saveUri: fileUri
};
const mediaTypes = [cameraPicker.PickerMediaType.VIDEO];
const pickRes = await cameraPicker.pick(getContext(), mediaTypes, pickerProfile);
阅读 502
1 个回答

使用saveUri需要传入完整的Uri例如:

file://com.example.myapplicationssss/data/storage/el2/base/haps/entry/cache/test.mp4 

通过getContext(this).cacheDir + '/test.mp4’获取的缺少file://com.example.myapplicationssss(package)部分,需要补足或用其他方式获取完整uri。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进