HarmonyOS 使用相机预览功能是否会导致在Mate60上黑屏和闪退?

参考代码:

XComponent组件:

createXComponent(){
  XComponent({
    id: 'componentId',
    type: 'surface',
    controller: this.mXComponentController
  }) .gesture(
    PinchGesture({ fingers: 2 })
      .onActionUpdate((event: GestureEvent) => {
        if (event && !this.isStabilization) {
          this.zoom = this.zoom * ((event.scale - 1) * 0.07 + 1)
          this.isShowZoom = true
          if (this.zoom > zoomRatioRange[1]) {
            this.zoom = zoomRatioRange[1]
          } else if (this.zoom < zoomRatioRange[0]) {
            this.zoom = zoomRatioRange[0]
          }
          if (this.isPhoto) {
            CameraShooter.setPhotoZoom(this.zoom);
          } else {
            setVideoZoom(this.zoom);
          }
        }
      })
      .onActionEnd(() => {
        this.isShowZoom = false
      })
  )
    .onLoad(async () => {
      this.mXComponentController.setXComponentSurfaceSize({
        surfaceWidth: previewSize.height,
        surfaceHeight: previewSize.width
      });
      surfaceId = this.mXComponentController.getXComponentSurfaceId();

    })
    .height(CameraConstants.SURFACE_HEIGHT)
    .width(CameraConstants.FULL_SCREEN)
}

let previewSize: camera.Size = {
  width: CameraConstants.PREVIEW_WIDTH,
  height: CameraConstants.PREVIEW_HEIGHT
};
/**
 * camera preview size
 */
static readonly PREVIEW_WIDTH: number = 2592;
/**
 * camera preview size
 */
static readonly PREVIEW_HEIGHT: number = 1944;
static readonly SURFACE_HEIGHT: string = '1650px';
static readonly FULL_SCREEN: string = '100%';
阅读 435
1 个回答

将参数改为demo里的相机参数:

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