harmony 鸿蒙媒体子系统 JS API 变更 Changelog

  • 2023-06-24
  • 浏览 (690)

媒体子系统 JS API 变更 Changelog

cl.subsystemname.1 camera 接口变更

  1. camera 部件在 API9 版本全量改为 SystemAPI
  2. 基于以下原因新增部分功能接口以及废弃部分接口:

提升开发者使用相机接口的便利。 帮助开发者快速掌握相机开发接口,快速投入到开发当中。 易于后续版本中框架功能的扩展,降低框架模块之间的耦合度。

具体参考下方变更内容,开发者需要根据以下说明对应用进行适配。

变更影响

影响 API9 版本的 JS 接口,应用需要进行适配才可以在新版本 SDK 环境正常实现功能。

关键的接口/组件变更

模块名 类名 方法/属性/枚举/常量 是否为 SystemApi 变更类型
ohos.multimedia.camera camera function getCameraManager(context: Context): CameraManager; 新增
ohos.multimedia.camera camera function getCameraManager(context: Context, callback: AsyncCallback): void;
function getCameraManager(context: Context): Promise;
废弃
ohos.multimedia.camera CameraErrorCode INVALID_ARGUMENT = 7400101,
OPERATION_NOT_ALLOWED = 7400102,
SESSION_NOT_CONFIG = 7400103,
SESSION_NOT_RUNNING = 7400104,
SESSION_CONFIG_LOCKED = 7400105,
DEVICE_SETTING_LOCKED = 7400106,
CONFILICT_CAMERA = 7400107,
DEVICE_DISABLED = 7400108,
SERVICE_FATAL_ERROR = 7400201
新增
ohos.multimedia.camera CameraManager getSupportedCameras(): Array;
getSupportedOutputCapability(camera: CameraDevice): CameraOutputCapability;
createCameraInput(camera: CameraDevice): CameraInput;
createCameraInput(position: CameraPosition, type: CameraType): CameraInput;
createPreviewOutput(profile: Profile, surfaceId: string): PreviewOutput;
createPhotoOutput(profile: Profile, surfaceId: string): PhotoOutput;
createVideoOutput(profile: VideoProfile, surfaceId: string): VideoOutput;
createMetadataOutput(metadataObjectTypes: Array): MetadataOutput;
createCaptureSession(): CaptureSession;
新增
ohos.multimedia.camera CameraManager getSupportedCameras(callback: AsyncCallback>): void;
getSupportedCameras(): Promise>;
getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback): void;
getSupportedOutputCapability(camera: CameraDevice): Promise;
createCameraInput(camera: CameraDevice, callback: AsyncCallback): void;
createCameraInput(camera: CameraDevice): Promise;
createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void;
createCameraInput(position: CameraPosition, type: CameraType): Promise;
createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void;
createPreviewOutput(profile: Profile, surfaceId: string): Promise;
createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void;
createPhotoOutput(profile: Profile, surfaceId: string): Promise;
createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback): void;
createVideoOutput(profile: VideoProfile, surfaceId: string): Promise;
createMetadataOutput(metadataObjectTypes: Array, callback: AsyncCallback): void;
createMetadataOutput(metadataObjectTypes: Array): Promise;
createCaptureSession(callback: AsyncCallback): void;
createCaptureSession(): Promise;
废弃
ohos.multimedia.camera CameraType CAMERA_TYPE_DEFAULT = 0 新增
ohos.multimedia.camera CameraType CAMERA_TYPE_UNSPECIFIED = 0 废弃
ohos.multimedia.camera CameraInput on(type: ‘error’, camera: CameraDevice, callback: ErrorCallback): void; 新增
ohos.multimedia.camera CameraInput release(callback: AsyncCallback): void;
release(): Promise;
on(type: ‘error’, camera: CameraDevice, callback: ErrorCallback): void;
废弃
ohos.multimedia.camera CameraInputErrorCode ERROR_UNKNOWN = -1
ERROR_NO_PERMISSION = 0
ERROR_DEVICE_PREEMPTED = 1
ERROR_DEVICE_DISCONNECTED = 2
ERROR_DEVICE_IN_USE = 3
ERROR_DRIVER_ERROR = 4
废弃
ohos.multimedia.camera CameraInputError code: CameraInputErrorCode 废弃
ohos.multimedia.camera CaptureSession beginConfig(): void;
addInput(cameraInput: CameraInput): void;
removeInput(cameraInput: CameraInput): void;
addOutput(cameraOutput: CameraOutput): void;
removeOutput(cameraOutput: CameraOutput): void;
hasFlash(): boolean;
isFlashModeSupported(flashMode: FlashMode): boolean;
getFlashMode(): FlashMode;
setFlashMode(flashMode: FlashMode): void;
isExposureModeSupported(aeMode: ExposureMode): boolean;
getExposureMode(): ExposureMode;
setExposureMode(aeMode: ExposureMode): void;
getMeteringPoint(): Point;
setMeteringPoint(point: Point): void;
getExposureBiasRange(): Array;
setExposureBias(exposureBias: number): void;
getExposureValue(): number;
isFocusModeSupported(afMode: FocusMode): boolean;
getFocusMode(): FocusMode;
setFocusMode(afMode: FocusMode): void;
setFocusPoint(point: Point): void;
getFocusPoint(): Point;
getFocalLength(): number;
getZoomRatioRange(): Array;
getZoomRatio(): number;
setZoomRatio(zoomRatio: number): void;
isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean;
getActiveVideoStabilizationMode(): VideoStabilizationMode;
setVideoStabilizationMode(mode: VideoStabilizationMode): void;
on(type: ‘error’, callback: ErrorCallback): void;
新增
ohos.multimedia.camera CaptureSession beginConfig(callback: AsyncCallback): void;
beginConfig(): Promise;
addInput(cameraInput: CameraInput, callback: AsyncCallback): void;
addInput(cameraInput: CameraInput): Promise;
removeInput(cameraInput: CameraInput, callback: AsyncCallback): void;
removeInput(cameraInput: CameraInput): Promise;
addOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void;
addOutput(cameraOutput: CameraOutput): Promise;
removeOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void;
removeOutput(cameraOutput: CameraOutput): Promise;
hasFlash(callback: AsyncCallback): void;
hasFlash(): Promise;
isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void;
isFlashModeSupported(flashMode: FlashMode): Promise;
getFlashMode(callback: AsyncCallback): void;
getFlashMode(): Promise;
setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void;
setFlashMode(flashMode: FlashMode): Promise;
isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback): void;
isExposureModeSupported(aeMode: ExposureMode): Promise;
getExposureMode(callback: AsyncCallback): void;
getExposureMode(): Promise;
setExposureMode(aeMode: ExposureMode, callback: AsyncCallback): void;
setExposureMode(aeMode: ExposureMode): Promise;
getMeteringPoint(callback: AsyncCallback): void;
getMeteringPoint(): Promise;
setMeteringPoint(point: Point, callback: AsyncCallback): void;
setMeteringPoint(point: Point): Promise;
getExposureBiasRange(callback: AsyncCallback>): void;
getExposureBiasRange(): Promise>;
setExposureBias(exposureBias: number, callback: AsyncCallback): void;
setExposureBias(exposureBias: number): Promise;
getExposureValue(callback: AsyncCallback): void;
getExposureValue(): Promise;
isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void;
isFocusModeSupported(afMode: FocusMode): Promise;
getFocusMode(callback: AsyncCallback): void;
getFocusMode(): Promise;
setFocusMode(afMode: FocusMode, callback: AsyncCallback): void;
setFocusMode(afMode: FocusMode): Promise;
setFocusPoint(point: Point, callback: AsyncCallback): void;
setFocusPoint(point: Point): Promise;
getFocusPoint(callback: AsyncCallback): void;
getFocusPoint(): Promise;
getFocalLength(callback: AsyncCallback): void;
getFocalLength(): Promise;
getZoomRatioRange(callback: AsyncCallback>): void;
getZoomRatioRange(): Promise>;
getZoomRatio(callback: AsyncCallback): void;
getZoomRatio(): Promise;
setZoomRatio(zoomRatio: number, callback: AsyncCallback): void;
setZoomRatio(zoomRatio: number): Promise;
isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode, callback: AsyncCallback): void;
isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): Promise;
getActiveVideoStabilizationMode(callback: AsyncCallback): void;
getActiveVideoStabilizationMode(): Promise;
setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback): void;
setVideoStabilizationMode(mode: VideoStabilizationMode): Promise;
on(type: ‘error’, callback: ErrorCallback): void;
废弃
ohos.multimedia.camera CaptureSessionErrorCode ERROR_UNKNOWN = -1
ERROR_INSUFFICIENT_RESOURCES = 0
ERROR_TIMEOUT = 1
废弃
ohos.multimedia.camera CaptureSessionError code: CaptureSessionErrorCode 废弃
ohos.multimedia.camera PreviewOutput on(type: ‘error’, callback: ErrorCallback): void; 新增
ohos.multimedia.camera PreviewOutput on(type: ‘error’, callback: ErrorCallback): void; 废弃
ohos.multimedia.camera PreviewOutputErrorCode ERROR_UNKNOWN = -1 废弃
ohos.multimedia.camera PreviewOutputError code: PreviewOutputErrorCode 废弃
ohos.multimedia.camera PhotoOutput capture(): Promise;
isMirrorSupported(): boolean;
on(type: ‘error’, callback: ErrorCallback): void;
新增
ohos.multimedia.camera PhotoOutput isMirrorSupported(callback: AsyncCallback): void;
isMirrorSupported(): Promise;
on(type: ‘error’, callback: ErrorCallback): void;
废弃
ohos.multimedia.camera PhotoOutputErrorCode ERROR_UNKNOWN = -1
ERROR_DRIVER_ERROR = 0
ERROR_INSUFFICIENT_RESOURCES = 1
ERROR_TIMEOUT = 2
废弃
ohos.multimedia.camera PhotoOutputError code: PhotoOutputErrorCode 废弃
ohos.multimedia.camera VideoOutput on(type: ‘error’, callback: ErrorCallback): void; 新增
ohos.multimedia.camera VideoOutput on(type: ‘error’, callback: ErrorCallback): void; 废弃
ohos.multimedia.camera VideoOutputErrorCode ERROR_UNKNOWN = -1
ERROR_DRIVER_ERROR = 0
废弃
ohos.multimedia.camera VideoOutputError code: VideoOutputErrorCode 废弃
ohos.multimedia.camera MetadataObject readonly type: MetadataObjectType;
readonly timestamp: number;
新增
ohos.multimedia.camera MetadataObject getType(callback: AsyncCallback): void;
getType(): Promise;
getTimestamp(callback: AsyncCallback): void;
getTimestamp(): Promise;
getBoundingBox(callback: AsyncCallback): void;
getBoundingBox(): Promise;
废弃
ohos.multimedia.camera MetadataFaceObject readonly boundingBox: Rect 新增
ohos.multimedia.camera MetadataOutput on(type: ‘error’, callback: ErrorCallback): void; 新增
ohos.multimedia.camera MetadataOutput on(type: ‘error’, callback: ErrorCallback): void; 废弃
ohos.multimedia.camera MetadataOutputErrorCode ERROR_UNKNOWN = -1
ERROR_INSUFFICIENT_RESOURCES = 0
废弃
ohos.multimedia.camera MetadataOutputError code: MetadataOutputErrorCode 废弃

适配指导

除新增接口,和废弃接口之外,开发者需要关注变更的接口的适配:

从 Beta4 版本开始,对以下接口进行调整:

新增接口

  1. CameraErrorCode 枚举

枚举值名称:INVALID_ARGUMENT, 值:7400101;

枚举值名称:OPERATION_NOT_ALLOWED, 值:7400102;

枚举值名称:SESSION_NOT_CONFIG, 值:7400103;

枚举值名称:SESSION_NOT_RUNNING, 值:7400104;

枚举值名称:SESSION_CONFIG_LOCKED, 值:7400105;

枚举值名称:DEVICE_SETTING_LOCKED, 值:7400106;

枚举值名称:CONFILICT_CAMERA, 值:7400107;

枚举值名称:DEVICE_DISABLED, 值:7400108;

枚举值名称:SERVICE_FATAL_ERROR, 值:7400201;

  1. PhotoOutput 接口新增 capture(): Promise;

  2. MetadataObject 接口中新增 readonly type: MetadataObjectType;

  3. MetadataObject 接口中新增 readonly timestamp: number;

  4. MetadataObject 接口中新增 readonly boundingBox: Rect;

废弃接口

  1. CameraInput 中废弃接口 release(callback: AsyncCallback): void; 以及 release(): Promise;

  2. 废弃枚举 CameraInputErrorCode 以及所有它里边的枚举值(ERROR_UNKNOWN = -1,ERROR_NO_PERMISSION = 0,ERROR_DEVICE_PREEMPTED = 1,ERROR_DEVICE_DISCONNECTED = 2,ERROR_DEVICE_IN_USE = 3,ERROR_DRIVER_ERROR = 4);

  3. 废弃接口 CameraInputError 以及接口属性 code:CameraInputErrorCode;

  4. 废弃枚举 CaptureSessionErrorCode 以及所有它里边的枚举值(ERROR_UNKNOWN = -1,ERROR_INSUFFICIENT_RESOURCES = 0,ERROR_TIMEOUT = 1);

  5. 废弃接口 CaptureSessionError 以及接口属性 code: CaptureSessionErrorCode;

  6. 废弃枚举 PreviewOutputErrorCode 以及所有它里边的枚举值(ERROR_UNKNOWN = -1);

  7. 废弃接口 PreviewOutputError 以及接口属性 code: PreviewOutputErrorCode;

  8. 废弃枚举 PhotoOutputErrorCode 以及所有它里边的枚举值(ERROR_UNKNOWN = -1,ERROR_DRIVER_ERROR = 0,ERROR_INSUFFICIENT_RESOURCES = 1,ERROR_TIMEOUT = 2);

  9. 废弃接口 PhotoOutputError 以及接口属性 code:PhotoOutputErrorCode;

  10. 废弃枚举 VideoOutputErrorCode 以及所有它里边的枚举值(ERROR_UNKNOWN = -1,ERROR_DRIVER_ERROR = 0);

  11. 废弃接口 VideoOutputError 以及接口属性 code:VideoOutputErrorCode;

  12. 废弃接口 MetadataObject 中 getType(callback: AsyncCallback): void;

  13. 废弃接口 MetadataObject 中 getType(): Promise;

  14. 废弃接口 MetadataObject 中 getTimestamp(callback: AsyncCallback): void;

  15. 废弃接口 MetadataObject 中 getTimestamp(): Promise;

  16. 废弃接口 MetadataObject 中 getBoundingBox(callback: AsyncCallback): void;

  17. 废弃接口 MetadataObject 中 getBoundingBox(): Promise;

  18. 废弃枚举 MetadataOutputErrorCode 以及所有它里边的枚举值(ERROR_UNKNOWN = -1,ERROR_INSUFFICIENT_RESOURCES = 0);

  19. 废弃接口 MetadataOutputError 以及接口属性 code:MetadataOutputErrorCode;

接口变更

  1. camera 模块中接口 getCameraManager 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 getCameraManager(context: Context, callback: AsyncCallback): void; 以及 getCameraManager(context: Context): Promise; 变更为 getCameraManager(context: Context): CameraManager;

参考代码如下:

   let cameraManager = camera.getCameraManager(context);
  1. CameraManager 中接口 getSupportedCameras 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 getSupportedCameras(callback: AsyncCallback>): void; 以及 getSupportedCameras(): Promise>; 变更为 getSupportedCameras(): Array;

参考代码如下:

   let cameras = cameraManager.getSupportedCameras();
  1. CameraManager 中接口 getSupportedOutputCapability 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback): void; 以及 getSupportedOutputCapability(camera: CameraDevice): Promise; 变更为 getSupportedOutputCapability(camera: CameraDevice): CameraOutputCapability;

参考代码如下:

   let cameraDevice = cameras[0];
   let CameraOutputCapability = cameraManager.getSupportedOutputCapability(cameraDevice);
  1. CameraManager 中接口 createCameraInput(camera: CameraDevice) 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 createCameraInput(camera: CameraDevice, callback: AsyncCallback): void; 以及 createCameraInput(camera: CameraDevice): Promise; 变更为 createCameraInput(camera: CameraDevice): CameraInput;

参考代码如下:

   let cameraDevice = cameras[0];
   let cameraInput = cameraManager.createCameraInput(cameraDevice);
  1. CameraManager 中接口 createCameraInput(position: CameraPosition, type: CameraType) 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void; 以及 createCameraInput(position: CameraPosition, type: CameraType): Promise; 变更为 createCameraInput(position: CameraPosition, type: CameraType): CameraInput;

参考代码如下:

   let cameraDevice = cameras[0];
   let position = cameraDevice.cameraPosition;
   let type = cameraDevice.cameraType;
   let cameraInput = cameraManager.createCameraInput(position, type);
  1. CameraManager 中接口 createPreviewOutput 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void; 以及 createPreviewOutput(profile: Profile, surfaceId: string): Promise; 变更为 createPreviewOutput(profile: Profile, surfaceId: string): PreviewOutput;

参考代码如下:

   let profile = cameraoutputcapability.previewProfiles[0];
   let previewOutput = cameraManager.createPreviewOutput(profile, surfaceId);
  1. CameraManager 中接口 createPhotoOutput 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void; 以及 createPhotoOutput(profile: Profile, surfaceId: string): Promise; 变更为 createPhotoOutput(profile: Profile, surfaceId: string): PhotoOutput;

参考代码如下:

   let profile = cameraoutputcapability.photoProfiles[0];
   let photoOutput = cameraManager.createPhotoOutput(profile, surfaceId);
  1. CameraManager 中接口 createVideoOutput 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback): void; 以及 createVideoOutput(profile: VideoProfile, surfaceId: string): Promise; 变更为 createVideoOutput(profile: VideoProfile, surfaceId: string): VideoOutput;

参考代码如下:

   let profile = cameraoutputcapability.videoProfiles[0];
   let videoOutput = cameraManager.createVideoOutput(profile, surfaceId);
  1. CameraManager 中接口 createMetadataOutput 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 createMetadataOutput(metadataObjectTypes: Array, callback: AsyncCallback): void; 以及 createMetadataOutput(metadataObjectTypes: Array): Promise; 变更为 createMetadataOutput(metadataObjectTypes: Array): MetadataOutput;

参考代码如下:

   let metadataObjectTypes = cameraoutputcapability.supportedMetadataObjectTypes;
   let metadataOutput = cameraManager.createMetadataOutput(metadataObjectTypes);
  1. CameraManager 中接口 createCaptureSession 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 createCaptureSession(callback: AsyncCallback): void; 以及 createCaptureSession(): Promise; 变更为 createCaptureSession(): CaptureSession;

参考代码如下:

   let captureSession = cameraManager.createCaptureSession();
  1. 枚举 CameraType 中,枚举值名称 CAMERA_TYPE_UNSPECIFIED 变更为 CAMERA_TYPE_DEFAULT。

  2. CameraInput 中,on 接口返回值类型由 CameraInputError 变更为 BusinessError,因此旧接口 on(type: ‘error’, camera: CameraDevice, callback: ErrorCallback): void; 变更为 on(type: ‘error’, camera: CameraDevice, callback: ErrorCallback): void;

参考代码如下:

   let cameraDevice = cameras[0];
   cameraInput.on('error', cameraDevice, (BusinessError) => {
   
   })
  1. CaptureSession 中接口 beginConfig 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 beginConfig(callback: AsyncCallback): void; 以及 beginConfig(): Promise; 变更为 beginConfig(): void;

参考代码如下:

   captureSession.beginConfig();
  1. CaptureSession 中接口 addInput 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 addInput(cameraInput: CameraInput, callback: AsyncCallback): void; 以及 addInput(cameraInput: CameraInput): Promise; 变更为 addInput(cameraInput: CameraInput): void;

参考代码如下:

   captureSession.addInput(cameraInput);
  1. CaptureSession 中接口 removeInput 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 removeInput(cameraInput: CameraInput, callback: AsyncCallback): void; 以及 removeInput(cameraInput: CameraInput): Promise; 变更为 removeInput(cameraInput: CameraInput): void;

参考代码如下:

   captureSession.removeInput(cameraInput);
  1. CaptureSession 中接口 addOutput 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 addOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void; 以及 addOutput(cameraOutput: CameraOutput): Promise; 变更为 addOutput(cameraOutput: CameraOutput): void;

参考代码如下:

   captureSession.addOutput(previewOutput);
  1. CaptureSession 中接口 removeOutput 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 removeOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void; 以及 removeOutput(cameraOutput: CameraOutput): Promise; 变更为 removeOutput(cameraOutput: CameraOutput): void;

参考代码如下:

   captureSession.removeOutput(previewOutput);
  1. CaptureSession 中接口 hasFlash 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 hasFlash(callback: AsyncCallback): void; 以及 hasFlash(): Promise; 变更为 hasFlash(): boolean;

参考代码如下:

   let status = captureSession.hasFlash();
  1. CaptureSession 中接口 isFlashModeSupported 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void; 以及 isFlashModeSupported(flashMode: FlashMode): Promise; 变更为 isFlashModeSupported(flashMode: FlashMode): boolean;

参考代码如下:

   let status = captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO);
  1. CaptureSession 中接口 getFlashMode 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 getFlashMode(callback: AsyncCallback): void; 以及 getFlashMode(): Promise; 变更为 getFlashMode(): FlashMode;

参考代码如下:

   let flashMode = captureSession.getFlashMode();
  1. CaptureSession 中接口 isExposureModeSupported 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback): void; 以及 isExposureModeSupported(aeMode: ExposureMode): Promise; 变更为 isExposureModeSupported(aeMode: ExposureMode): boolean;

参考代码如下:

   let isSupported = captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
  1. CaptureSession 中接口 getExposureMode 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 getExposureMode(callback: AsyncCallback): void; 以及 getExposureMode(): Promise; 变更为 getExposureMode(): ExposureMode;

参考代码如下:

   let exposureMode = captureSession.getExposureMode();
  1. CaptureSession 中接口 setExposureMode 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 setExposureMode(aeMode: ExposureMode, callback: AsyncCallback): void; 以及 setExposureMode(aeMode: ExposureMode): Promise; 变更为 setExposureMode(aeMode: ExposureMode): void;

参考代码如下:

   captureSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
  1. CaptureSession 中接口 getMeteringPoint 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 getMeteringPoint(callback: AsyncCallback): void; 以及 getMeteringPoint(): Promise; 变更为 getMeteringPoint(): Point;

参考代码如下:

   let exposurePoint = captureSession.getMeteringPoint();
  1. CaptureSession 中接口 setMeteringPoint 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 setMeteringPoint(point: Point, callback: AsyncCallback): void; 以及 setMeteringPoint(point: Point): Promise; 变更为 setMeteringPoint(point: Point): void;

参考代码如下:

   let Point2 = {x: 2, y: 2};
   captureSession.setMeteringPoint(Point2);
  1. CaptureSession 中接口 getExposureBiasRange 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 getExposureBiasRange(callback: AsyncCallback>): void; 以及 getExposureBiasRange(): Promise>; 变更为 getExposureBiasRange(): Array;

参考代码如下:

   let biasRangeArray = captureSession.getExposureBiasRange();
  1. CaptureSession 中接口 setExposureBias 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 setExposureBias(exposureBias: number, callback: AsyncCallback): void; 以及 setExposureBias(exposureBias: number): Promise; 变更为 setExposureBias(exposureBias: number): void;

参考代码如下:

   let exposureBias = biasRangeArray[0];
   captureSession.setExposureBias(exposureBias);
  1. CaptureSession 中接口 getExposureValue 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 getExposureValue(callback: AsyncCallback): void; 以及 getExposureValue(): Promise; 变更为 getExposureValue(): number;

参考代码如下:

   let exposureValue = captureSession.getExposureValue();
  1. CaptureSession 中接口 isFocusModeSupported 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void; 以及 isFocusModeSupported(afMode: FocusMode): Promise; 变更为 isFocusModeSupported(afMode: FocusMode): boolean;

参考代码如下:

   let status = captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO);
  1. CaptureSession 中接口 getFocusMode 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 getFocusMode(callback: AsyncCallback): void; 以及 getFocusMode(): Promise; 变更为 getFocusMode(): FocusMode;

参考代码如下:

   let afMode = captureSession.getFocusMode();
  1. CaptureSession 中接口 setFocusMode 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 setFocusMode(afMode: FocusMode, callback: AsyncCallback): void; 以及 setFocusMode(afMode: FocusMode): Promise; 变更为 setFocusMode(afMode: FocusMode): void;

参考代码如下:

   captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO);
  1. CaptureSession 中接口 setFocusPoint 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 setFocusPoint(point: Point, callback: AsyncCallback): void; 以及 setFocusPoint(point: Point): Promise; 变更为 setFocusPoint(point: Point): void;

参考代码如下:

   let Point2 = {x: 2, y: 2};
   captureSession.setFocusPoint(Point2);
  1. CaptureSession 中接口 getFocusPoint 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 getFocusPoint(callback: AsyncCallback): void; 以及 getFocusPoint(): Promise; 变更为 getFocusPoint(): Point;

参考代码如下:

   let point = captureSession.getFocusPoint();
  1. CaptureSession 中接口 getFocalLength 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 getFocalLength(callback: AsyncCallback): void; 以及 getFocalLength(): Promise; 变更为 getFocalLength(): number;

参考代码如下:

   let focalLength = captureSession.getFocalLength();
  1. CaptureSession 中接口 getZoomRatioRange 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 getZoomRatioRange(callback: AsyncCallback>): void; 以及 getZoomRatioRange(): Promise>; 变更为 getZoomRatioRange(): Array;

参考代码如下:

   let zoomRatioRange = captureSession.getZoomRatioRange();
  1. CaptureSession 中接口 getZoomRatio 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 getZoomRatio(callback: AsyncCallback): void; 以及 getZoomRatio(): Promise; 变更为 getZoomRatio(): number;

参考代码如下:

   let zoomRatio = captureSession.getZoomRatio();
  1. CaptureSession 中接口 setZoomRatio 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 setZoomRatio(zoomRatio: number, callback: AsyncCallback): void; 以及 setZoomRatio(zoomRatio: number): Promise; 变更为 setZoomRatio(zoomRatio: number): void;

参考代码如下:

   let zoomRatio = zoomRatioRange[0];
   captureSession.setZoomRatio(zoomRatio);
  1. CaptureSession 中接口 isVideoStabilizationModeSupported 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode, callback: AsyncCallback): void; 以及 isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): Promise; 变更为 isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean;

参考代码如下:

   let isSupported = captureSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF);
  1. CaptureSession 中接口 getActiveVideoStabilizationMode 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 getActiveVideoStabilizationMode(callback: AsyncCallback): void; 以及 getActiveVideoStabilizationMode(): Promise; 变更为 getActiveVideoStabilizationMode(): VideoStabilizationMode;

参考代码如下:

   let vsMode = captureSession.getActiveVideoStabilizationMode();
  1. CaptureSession 中接口 setVideoStabilizationMode 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback): void; 以及 setVideoStabilizationMode(mode: VideoStabilizationMode): Promise; 变更为 setVideoStabilizationMode(mode: VideoStabilizationMode): void;

参考代码如下:

   captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF);
  1. CaptureSession 中,on(type: ‘error’) callback 类型由 ErrorCallback 变更为 ErrorCallback,因此旧接口 on(type: ‘error’, callback: ErrorCallback): void; 变更为 on(type: ‘error’, callback: ErrorCallback): void;

参考代码如下:

   captureSession.on('error', (BusinessError) => {
   
   })
  1. PreviewOutput 中,on(type: ‘error’) callback 类型由 ErrorCallback 变更为 ErrorCallback,因此旧接口 on(type: ‘error’, callback: ErrorCallback): void; 变更为 on(type: ‘error’, callback: ErrorCallback): void;

参考代码如下:

   previewOutput.on('error', (BusinessError) => {
   
   })
  1. PhotoOutput 中接口 isMirrorSupported 返回方式由异步 callback 跟异步 promise 变更为同步返回,因此旧接口 isMirrorSupported(callback: AsyncCallback): void; 以及 isMirrorSupported(): Promise; 变更为 isMirrorSupported(): boolean;

参考代码如下:

   let isSupported = photoOutput.isMirrorSupported();
  1. PhotoOutput 中,on(type: ‘error’) callback 类型由 ErrorCallback 变更为 ErrorCallback,因此旧接口 on(type: ‘error’, callback: ErrorCallback): void; 变更为 on(type: ‘error’, callback: ErrorCallback): void;

参考代码如下:

   PhotoOutput.on('error', (BusinessError) => {
   
   })
  1. VideoOutput 中,on(type: ‘error’) callback 类型由 ErrorCallback 变更为 ErrorCallback,因此旧接口 on(type: ‘error’, callback: ErrorCallback): void; 变更为 on(type: ‘error’, callback: ErrorCallback): void;

参考代码如下:

   VideoOutput.on('error', (BusinessError) => {
   
   })
  1. MetadataOutput 中,on(type: ‘error’) callback 类型由 ErrorCallback 变更为 ErrorCallback,因此旧接口 on(type: ‘error’, callback: ErrorCallback): void; 变更为 on(type: ‘error’, callback: ErrorCallback): void;

参考代码如下:

   MetadataOutput.on('error', (BusinessError) => {
   
   })

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Readme

harmony 鸿蒙xxx子系统ChangeLog

harmony 鸿蒙元能力子系统JS API变更Changelog

harmony 鸿蒙帐号子系统changeLog

harmony 鸿蒙arkui子系统ChangeLog

harmony 鸿蒙公共基础类库子系统JS API变更Changelog

harmony 鸿蒙分布式数据管理子系统JS API变更Changelog

harmony 鸿蒙文件管理子系统ChangeLog

harmony 鸿蒙输入法框架changeLog

harmony 鸿蒙文件子系统ChangeLog

0  赞