媒体子系统JS API变更Changelog
camera接口变更
基于以下原因新增部分功能接口以及废弃部分接口:
- 提升开发者使用相机接口的便利。
- 帮助开发者快速掌握相机开发接口,快速投入到开发当中。
- 易于后续版本中框架功能的扩展,降低框架模块之间的耦合度。
具体参考下方变更内容,开发者需要根据以下说明对应用进行适配。
变更影响
影响API9版本的JS接口,应用需要进行适配才可以在新版本SDK环境正常实现功能。
关键的接口/组件变更
模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 |
---|---|---|---|
ohos.multimedia.camera | Profile | readonly format:CameraFormat; | 新增 |
ohos.multimedia.camera | Profile | readonly size: Size; | 新增 |
ohos.multimedia.camera | FrameRateRange | readonly min: number; | 新增 |
ohos.multimedia.camera | FrameRateRange | readonly max: number; | 新增 |
ohos.multimedia.camera | VideoProfile | readonly frameRateRange: FrameRateRange; | 新增 |
ohos.multimedia.camera | CameraOutputCapability | readonly previewProfiles: Array |
新增 |
ohos.multimedia.camera | CameraOutputCapability | readonly photoProfiles: Array |
新增 |
ohos.multimedia.camera | CameraOutputCapability | readonly videoProfiles: Array |
新增 |
ohos.multimedia.camera | CameraOutputCapability | readonly supportedMetadataObjectTypes: Array |
新增 |
ohos.multimedia.camera | CameraManager | getSupportedCameras(callback: AsyncCallback<Array getSupportedCameras(): Promise<Array |
新增 |
ohos.multimedia.camera | CameraManager | getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback getSupportedOutputCapability(camera: CameraDevice): Promise |
新增 |
ohos.multimedia.camera | CameraManager | isCameraMuted(): boolean; | 新增 |
ohos.multimedia.camera | CameraManager | isCameraMuteSupported(): boolean; | 新增 |
ohos.multimedia.camera | CameraManager | muteCamera(mute: boolean): void; | 新增 |
ohos.multimedia.camera | CameraManager | createCameraInput(camera: CameraDevice, callback: AsyncCallback createCameraInput(camera: CameraDevice): Promise |
新增 |
ohos.multimedia.camera | CameraManager | createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback createPreviewOutput(profile: Profile, surfaceId: string): Promise |
新增 |
ohos.multimedia.camera | CameraManager | createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback createPhotoOutput(profile: Profile, surfaceId: string): Promise |
新增 |
ohos.multimedia.camera | CameraManager | createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback createVideoOutput(profile: VideoProfile, surfaceId: string): Promise |
新增 |
ohos.multimedia.camera | CameraManager | createMetadataOutput(metadataObjectTypes: Array createMetadataOutput(metadataObjectTypes: Array |
新增 |
ohos.multimedia.camera | CameraManager | createCaptureSession(callback: AsyncCallback createCaptureSession(): Promise |
新增 |
ohos.multimedia.camera | CameraManager | on(type: 'cameraMute', callback: AsyncCallback |
新增 |
ohos.multimedia.camera | CameraManager | getCameras(callback: AsyncCallback<Array getCameras(): Promise<Array |
废弃 |
ohos.multimedia.camera | CameraManager | createCameraInput(cameraId: string, callback: AsyncCallback createCameraInput(cameraId: string): Promise |
废弃 |
ohos.multimedia.camera | CameraManager | createCaptureSession(context: Context, callback: AsyncCallback createCaptureSession(context: Context): Promise |
废弃 |
ohos.multimedia.camera | CameraManager | createPreviewOutput(surfaceId: string, callback: AsyncCallback createPreviewOutput(surfaceId: string): Promise |
废弃 |
ohos.multimedia.camera | CameraManager | CreatePhotoOutput(surfaceId: string, callback: AsyncCallback CreatePhotoOutput(surfaceId: string): Promise |
废弃 |
ohos.multimedia.camera | CameraManager | createVideoOutput(surfaceId: string, callback: AsyncCallback createVideoOutput(surfaceId: string): Promise |
废弃 |
ohos.multimedia.camera | CameraManager | createMetadataOutput(callback: AsyncCallback createVideoOutput(): Promise |
废弃 |
ohos.multimedia.camera | CameraStatusInfo | camera: CameraDevice; | 新增 |
ohos.multimedia.camera | CameraStatusInfo | camera: Camera; | 废弃 |
ohos.multimedia.camera | CameraDevice | interface CameraDevice | 新增 |
ohos.multimedia.camera | Camera | interface Camera | 废弃 |
ohos.multimedia.camera | CameraInput | open(callback: AsyncCallback open(): Promise |
新增 |
ohos.multimedia.camera | CameraInput | close(callback: AsyncCallback close(): Promise |
新增 |
ohos.multimedia.camera | CameraInput | on(type: 'error', camera: CameraDevice, callback: ErrorCallback |
新增 |
ohos.multimedia.camera | CameraInput | isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback isFocusModeSupported(afMode: FocusMode): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | getFocusMode(callback: AsyncCallback getFocusMode(): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | setFocusMode(afMode: FocusMode, callback: AsyncCallback setFocusMode(afMode: FocusMode): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | getZoomRatioRange(callback: AsyncCallback<Array getZoomRatioRange(): Promise<Array |
废弃 |
ohos.multimedia.camera | CameraInput | getZoomRatio(callback: AsyncCallback getZoomRatio(): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | setZoomRatio(zoomRatio: number, callback: AsyncCallback setZoomRatio(zoomRatio: number): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | getCameraId(callback: AsyncCallback getCameraId(): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | getExposurePoint(callback: AsyncCallback getExposurePoint(): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | setExposurePoint(exposurePoint: Point, callback: AsyncCallback setExposurePoint(exposurePoint: Point): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | hasFlash(callback: AsyncCallback hasFlash(): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback isFlashModeSupported(flashMode: FlashMode): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | getFlashMode(callback: AsyncCallback getFlashMode(): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | setFlashMode(flashMode: FlashMode, callback: AsyncCallback setFlashMode(flashMode: FlashMode): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback isExposureModeSupported(aeMode: ExposureMode): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | getExposureMode(callback: AsyncCallback getExposureMode(): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | setExposureMode(aeMode: ExposureMode, callback: AsyncCallback setExposureMode(aeMode: ExposureMode): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | getMeteringPoint(callback: AsyncCallback getMeteringPoint(): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | setMeteringPoint(point: Point, callback: AsyncCallback setMeteringPoint(point: Point): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | getExposureBiasRange(callback: AsyncCallback<Array getExposureBiasRange(): Promise<Array |
废弃 |
ohos.multimedia.camera | CameraInput | setExposureBias(exposureBias: number, callback: AsyncCallback setExposureBias(exposureBias: number): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | getExposureValue(callback: AsyncCallback getExposureValue(): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback isFocusModeSupported(afMode: FocusMode): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | getFocusMode(callback: AsyncCallback getFocusMode(): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | setFocusMode(afMode: FocusMode, callback: AsyncCallback setFocusMode(afMode: FocusMode): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | setFocusPoint(point: Point, callback: AsyncCallback setFocusPoint(point: Point): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | getFocusPoint(callback: AsyncCallback getFocusPoint(): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | getFocalLength(callback: AsyncCallback getFocalLength(): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | getZoomRatioRange(callback: AsyncCallback<Array getZoomRatioRange(): Promise<Array |
废弃 |
ohos.multimedia.camera | CameraInput | getZoomRatio(callback: AsyncCallback getZoomRatio(): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | setZoomRatio(zoomRatio: number, callback: AsyncCallback setZoomRatio(zoomRatio: number): Promise |
废弃 |
ohos.multimedia.camera | CameraInput | on(type: 'focusStateChange', callback: AsyncCallback |
废弃 |
ohos.multimedia.camera | CameraInput | on(type: 'exposureStateChange', callback: AsyncCallback |
废弃 |
ohos.multimedia.camera | CameraInput | on(type: 'error', callback: ErrorCallback |
废弃 |
ohos.multimedia.camera | CameraInputErrorCode | ERROR_NO_PERMISSION = 0 | 新增 |
ohos.multimedia.camera | CameraInputErrorCode | ERROR_DEVICE_PREEMPTED = 1 | 新增 |
ohos.multimedia.camera | CameraInputErrorCode | ERROR_DEVICE_DISCONNECTED = 2 | 新增 |
ohos.multimedia.camera | CameraInputErrorCode | ERROR_DEVICE_IN_USE = 3 | 新增 |
ohos.multimedia.camera | CameraInputErrorCode | ERROR_DRIVER_ERROR = 4 | 新增 |
ohos.multimedia.camera | CameraFormat | CAMERA_FORMAT_RGBA_8888 = 3 | 新增 |
ohos.multimedia.camera | ExposureMode | EXPOSURE_MODE_AUTO = 1 | 新增 |
ohos.multimedia.camera | ExposureMode | EXPOSURE_MODE_CONTINUOUS_AUTO = 2 | 新增 |
ohos.multimedia.camera | ExposureMode | EXPOSURE_MODE_AUTO | 废弃 |
ohos.multimedia.camera | ExposureMode | EXPOSURE_MODE_CONTINUOUS_AUTO | 废弃 |
ohos.multimedia.camera | VideoStabilizationMode | LOW = 1 | 新增 |
ohos.multimedia.camera | VideoStabilizationMode | MIDDLE = 2 | 新增 |
ohos.multimedia.camera | VideoStabilizationMode | HIGH = 3 | 新增 |
ohos.multimedia.camera | VideoStabilizationMode | AUTO = 4 | 新增 |
ohos.multimedia.camera | VideoStabilizationMode | LOW | 废弃 |
ohos.multimedia.camera | VideoStabilizationMode | MIDDLE | 废弃 |
ohos.multimedia.camera | VideoStabilizationMode | HIGH | 废弃 |
ohos.multimedia.camera | VideoStabilizationMode | AUTO | 废弃 |
ohos.multimedia.camera | CaptureSession | addOutput(cameraOutput: CameraOutput, callback: AsyncCallback addOutput(cameraOutput: CameraOutput): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | removeOutput(cameraOutput: CameraOutput, callback: AsyncCallback removeOutput(cameraOutput: CameraOutput): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode, callback: AsyncCallback isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | getActiveVideoStabilizationMode(callback: AsyncCallback getActiveVideoStabilizationMode(): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback setVideoStabilizationMode(mode: VideoStabilizationMode): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | on(type: 'focusStateChange', callback: AsyncCallback |
新增 |
ohos.multimedia.camera | CaptureSession | hasFlash(callback: AsyncCallback hasFlash(): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback isFlashModeSupported(flashMode: FlashMode): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | getFlashMode(callback: AsyncCallback getFlashMode(): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | setFlashMode(flashMode: FlashMode, callback: AsyncCallback setFlashMode(flashMode: FlashMode): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback isExposureModeSupported(aeMode: ExposureMode): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | getExposureMode(callback: AsyncCallback getExposureMode(): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | setExposureMode(aeMode: ExposureMode, callback: AsyncCallback setExposureMode(aeMode: ExposureMode): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | getMeteringPoint(callback: AsyncCallback getMeteringPoint(): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | setMeteringPoint(point: Point, callback: AsyncCallback setMeteringPoint(point: Point): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | getExposureBiasRange(callback: AsyncCallback<Array getExposureBiasRange(): Promise<Array |
新增 |
ohos.multimedia.camera | CaptureSession | setExposureBias(exposureBias: number, callback: AsyncCallback setExposureBias(exposureBias: number): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | getExposureValue(callback: AsyncCallback getExposureValue(): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback isFocusModeSupported(afMode: FocusMode): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | getFocusMode(callback: AsyncCallback getFocusMode(): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | setFocusMode(afMode: FocusMode, callback: AsyncCallback setFocusMode(afMode: FocusMode): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | setFocusPoint(point: Point, callback: AsyncCallback setFocusPoint(point: Point): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | getFocusPoint(callback: AsyncCallback getFocusPoint(): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | getFocalLength(callback: AsyncCallback getFocalLength(): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | getZoomRatioRange(callback: AsyncCallback<Array getZoomRatioRange(): Promise<Array |
新增 |
ohos.multimedia.camera | CaptureSession | getZoomRatio(callback: AsyncCallback getZoomRatio(): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | setZoomRatio(zoomRatio: number, callback: AsyncCallback setZoomRatio(zoomRatio: number): Promise |
新增 |
ohos.multimedia.camera | CaptureSession | addOutput(previewOutput: PreviewOutput, callback: AsyncCallback addOutput(previewOutput: PreviewOutput): Promise addOutput(photoOutput: PhotoOutput, callback: AsyncCallback addOutput(photoOutput: PhotoOutput): Promise addOutput(videoOutput: VideoOutput, callback: AsyncCallback addOutput(videoOutput: VideoOutput): Promise |
废弃 |
ohos.multimedia.camera | CaptureSession | removeOutput(previewOutput: PreviewOutput, callback: AsyncCallback removeOutput(previewOutput: PreviewOutput): Promise removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback removeOutput(photoOutput: PhotoOutput): Promise removeOutput(videoOutput: VideoOutput): Promise removeOutput(metadataOutput: MetadataOutput, callback: AsyncCallback removeOutput(metadataOutput: MetadataOutput): Promise |
废弃 |
ohos.multimedia.camera | CaptureSessionErrorCode | ERROR_INSUFFICIENT_RESOURCES = 0 | 新增 |
ohos.multimedia.camera | CaptureSessionErrorCode | ERROR_TIMEOUT = 1 | 新增 |
ohos.multimedia.camera | CameraOutput | release(callback: AsyncCallback release(): Promise |
新增 |
ohos.multimedia.camera | PreviewOutput | start(callback: AsyncCallback start(): Promise |
新增 |
ohos.multimedia.camera | PreviewOutput | stop(callback: AsyncCallback stop(): Promise |
新增 |
ohos.multimedia.camera | PreviewOutput | release(callback: AsyncCallback release(): Promise |
废弃 |
ohos.multimedia.camera | PhotoOutput | release(callback: AsyncCallback release(): Promise |
废弃 |
ohos.multimedia.camera | VideoOutput | release(callback: AsyncCallback release(): Promise |
废弃 |
ohos.multimedia.camera | PhotoCaptureSetting | mirror?: boolean; | 新增 |
ohos.multimedia.camera | PhotoOutputErrorCode | ERROR_DRIVER_ERROR = 0 | 新增 |
ohos.multimedia.camera | PhotoOutputErrorCode | ERROR_INSUFFICIENT_RESOURCES = 1 | 新增 |
ohos.multimedia.camera | PhotoOutputErrorCode | ERROR_TIMEOUT = 2 | 新增 |
ohos.multimedia.camera | VideoOutputErrorCode | ERROR_DRIVER_ERROR = 0 | 新增 |
ohos.multimedia.camera | MetadataObjectType | FACE_DETECTION = 0 | 新增 |
ohos.multimedia.camera | MetadataObjectType | FACE = 0 | 废弃 |
ohos.multimedia.camera | MetadataOutput | on(type: 'error', callback: ErrorCallback |
新增 |
ohos.multimedia.camera | MetadataOutput | setCapturingMetadataObjectTypes(metadataObjectTypes: Array setCapturingMetadataObjectTypes(metadataObjectTypes: Array |
废弃 |
ohos.multimedia.camera | MetadataOutput | getSupportedMetadataObjectTypes(callback: AsyncCallback<Array getSupportedMetadataObjectTypes(): Promise<Array |
废弃 |
ohos.multimedia.camera | MetadataOutputErrorCode | ERROR_UNKNOWN = -1 | 新增 |
ohos.multimedia.camera | MetadataOutputErrorCode | ERROR_INSUFFICIENT_RESOURCES = 0 | 新增 |
ohos.multimedia.camera | MetadataOutputError | code: MetadataOutputErrorCode; | 新增 |
适配指导
除新增接口,和废弃接口之外,开发者需要关注变更的接口的适配:
从Beta4版本开始,对以下接口进行调整:
新增接口
-
Profile接口
属性1:readonly format,类型:CameraFormat;
属性2:readonly size,类型:Size;
-
FrameRateRange接口
属性1:readonly min,类型:number;
属性2:readonly max,类型:number;
-
VideoProfile接口,继承自Profile
属性:readonly frameRateRange,类型:FrameRateRange;
-
CameraOutputCapability接口
属性1:readonly previewProfiles,类型:Array
; 属性2:readonly photoProfiles,类型:Array
; 属性3:readonly videoProfiles,类型:Array
; 属性4:readonly supportedMetadataObjectTypes,类型:Array
; -
CameraManager中新增
getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback
): void; getSupportedOutputCapability(camera: CameraDevice): Promise
; 参考代码如下:
cameraManager.getSupportedCameras().then((cameras) => { let cameraDevice = cameras[0]; cameraManager.getSupportedOutputCapability(cameraDevice, (err, CameraOutputCapability) => { if (err) { console.error(`Failed to get the outputCapability. ${err.message}`); return; } console.log('Callback returned with an array of supported outputCapability'); }) })
cameraManager.getSupportedCameras().then((cameras) => { let cameraDevice = cameras[0]; cameraManager.getSupportedOutputCapability(cameraDevice).then((cameraoutputcapability) => { console.log('Promise returned with an array of supported outputCapability'); }) })
-
CameraManager中新增isCameraMuted(): boolean;
参考代码如下:
let ismuted = cameraManager.isCameraMuted();
-
CameraManager中新增isCameraMuteSupported(): boolean;
参考代码如下:
let ismutesuppotred = cameraManager.isCameraMuteSupported();
-
CameraManager中新增muteCamera(mute: boolean): void;
参考代码如下:
let mute = true; cameraManager.muteCamera(mute);
-
CameraManager中新增on(type: 'cameraMute', callback: AsyncCallback
): void; 参考代码如下:
cameraManager.on('cameraMute', (err, curMuetd) => { if (err) { console.error(`Failed to get cameraMute callback. ${err.message}`); return; } })
-
CameraInput中新增open(callback: AsyncCallback
): void;以及open(): Promise ;
参考代码如下:
cameraInput.open((err) => {
if (err) {
console.error(`Failed to open the camera. ${err.message}`);
return;
}
console.log('Callback returned with camera opened.');
})
cameraInput.open().then(() => {
console.log('Promise returned with camera opened.');
})
-
CameraInput中新增close(callback: AsyncCallback
): void;以及close(): Promise ; 参考代码如下:
cameraInput.close((err) => { if (err) { console.error(`Failed to close the cameras. ${err.message}`); return; } console.log('Callback returned with camera closed.'); })
cameraInput.close().then(() => { console.log('Promise returned with camera closed.'); })
-
枚举CameraInputErrorCode中新增
枚举值名称:ERROR_NO_PERMISSION,值:0;
枚举值名称:ERROR_DEVICE_PREEMPTED,值:1;
枚举值名称:ERROR_DEVICE_DISCONNECTED,值:2;
枚举值名称:ERROR_DEVICE_IN_USE,值:3;
枚举值名称:ERROR_DRIVER_ERROR,值:4;
-
枚举CameraFormat中新增
枚举值名称:CAMERA_FORMAT_RGBA_8888,值:3;
-
CaptureSession中新增getMeteringPoint(callback: AsyncCallback
): void;以及getMeteringPoint(): Promise ; 参考代码如下:
captureSession.getMeteringPoint((err, exposurePoint) => { if (err) { console.log(`Failed to get the current exposure point ${err.message}`); return ; } console.log(`Callback returned with current exposure point: ${exposurePoint}`); })
captureSession.getMeteringPoint().then((exposurePoint) => { console.log(`Promise returned with current exposure point : ${exposurePoint}`); })
-
CaptureSession中新增setMeteringPoint(point: Point, callback: AsyncCallback
): void;以及setMeteringPoint(point: Point): Promise ; 参考代码如下:
const Point1 = {x: 1, y: 1}; captureSession.setMeteringPoint(Point1,(err) => { if (err) { console.log(`Failed to set the exposure point ${err.message}`); return ; } console.log('Callback returned with the successful execution of setMeteringPoint'); })
const Point2 = {x: 2, y: 2}; captureSession.setMeteringPoint(Point2).then(() => { console.log('Promise returned with the successful execution of setMeteringPoint'); })
-
枚举CaptureSessionErrorCode中新增
枚举值名称:ERROR_INSUFFICIENT_RESOURCES,值:0;
枚举值名称:ERROR_TIMEOUT,值:1;
-
新增接口CameraOutput,接口下有release(callback: AsyncCallback
): void;以及release(): Promise ;方法 参考代码如下:用previewOutput做示例
previewOutput.release((err) => { if (err) { console.error(`Failed to release the PreviewOutput instance ${err.message}`); return; } console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); });
previewOutput.release().then(() => { console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); })
-
PreviewOutput中新增start(callback: AsyncCallback
): void;以及start(): Promise ; 参考代码如下
previewOutput.start((err) => { if (err) { console.error(`Failed to start the previewOutput. ${err.message}`); return; } console.log('Callback returned with previewOutput started.'); })
previewOutput.start().then(() => { console.log('Promise returned with previewOutput started.'); })
-
PreviewOutput中新增stop(callback: AsyncCallback
): void;以及stop(): Promise ; 参考代码如下
previewOutput.stop((err) => { if (err) { console.error(`Failed to stop the previewOutput. ${err.message}`); return; } console.log('Callback returned with previewOutput stopped.'); })
previewOutput.stop().then(() => { console.log('Callback returned with previewOutput stopped.'); })
-
PhotoCaptureSetting接口
属性1:mirror?,类型:boolean;
-
枚举PhotoOutputErrorCode中新增
枚举值名称:ERROR_DRIVER_ERROR,值:0;
枚举值名称:ERROR_INSUFFICIENT_RESOURCES,值:1;
枚举值名称:ERROR_TIMEOUT,值:2;
-
枚举VideoOutputErrorCode中新增
枚举值名称:ERROR_DRIVER_ERROR,值:0;
-
MetadataOutput中新增on(type: 'error', callback: ErrorCallback
): void; 参考代码如下
metadataOutput.on('error', (metadataOutputError) => { console.log(`Metadata output error code: ${metadataOutputError.code}`); })
-
MetadataOutputErrorCode枚举
枚举值名称:ERROR_UNKNOWN,值:-1;
枚举值名称:ERROR_INSUFFICIENT_RESOURCES,值:0;
-
MetadataOutputError接口
属性名称:code,值:MetadataOutputErrorCode
废弃接口
-
CameraInput中废弃接口on(type: 'exposureStateChange', callback: AsyncCallback
): void; -
previewOutput中废弃接口release(callback: AsyncCallback
): void;以及release(): Promise ; -
metadataOutput中废弃接口
setCapturingMetadataObjectTypes(metadataObjectTypes: Array
, callback: AsyncCallback ): void;
setCapturingMetadataObjectTypes(metadataObjectTypes: Array): Promise ; -
metadataOutput中废弃接口
getSupportedMetadataObjectTypes(callback: AsyncCallback<Array
>): void;
getSupportedMetadataObjectTypes(): Promise<Array>; -
PreviewOutput中废弃接口release(callback: AsyncCallback
): void;以及release(): Promise ; -
PhotoOutput中废弃接口release(callback: AsyncCallback
): void;以及release(): Promise ; -
VideoOutput中废弃接口release(callback: AsyncCallback
): void;以及release(): Promise ; -
CameraInput中废弃接口getCameraId(callback: AsyncCallback
): void;以及getCameraId(): Promise ; -
CameraInput中废弃接口getExposurePoint(callback: AsyncCallback
): void;以及getExposurePoint(): Promise ; -
CameraInput中废弃接口setExposurePoint(exposurePoint: Point, callback: AsyncCallback
): void;以及setExposurePoint(exposurePoint: Point): Promise ;
接口变更
-
CameraManager中接口getCameras返回值由Array
变更为Array ,接口名由getCameras 更换为 getSupportedCameras,因此旧接口getCameras(callback: AsyncCallback<Array >): void;以及getCameras(): Promise<Array >;变更为getSupportedCameras(callback: AsyncCallback<Array >): void和getSupportedCameras(): Promise<Array >; 参考代码如下:
cameraManager.getSupportedCameras((err, cameras) => { if (err) { console.error(`Failed to get the cameras. ${err.message}`); return; } console.log(`Callback returned with an array of supported cameras: ${cameras.length}`); })
cameraManager.getSupportedCameras().then((cameras) => { console.log(`Promise returned with an array of supported cameras: ${cameras.length}`); })
-
CameraManager中接口createCameraInput传递参数由原来cameraId: string变更为camera: CameraDevice,因此旧接口createCameraInput(cameraId: string, callback: AsyncCallback
): void;以及createCameraInput(cameraId: string): Promise ;变更为createCameraInput(camera: CameraDevice, callback: AsyncCallback ): void;和createCameraInput(camera: CameraDevice): Promise ; 参考代码如下:
let cameraDevice = cameras[0]; cameraManager.createCameraInput(cameraDevice, (err, cameraInput) => { if (err) { console.error(`Failed to create the CameraInput instance. ${err.message}`); return; } console.log('Callback returned with the CameraInput instance.'); })
let cameraDevice = cameras[0]; cameraManager.createCameraInput(cameraDevice).then((cameraInput) => { console.log('Promise returned with the CameraInput instance'); })
-
CameraManager中接口createPreviewOutput新增传递参数profile: Profile,profile参数由getSupportedOutputCapability接口获取,因此旧接口createPreviewOutput(surfaceId: string, callback: AsyncCallback
): void;以及createPreviewOutput(surfaceId: string): Promise ;变更为createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback ): void;createPreviewOutput(profile: Profile, surfaceId: string): Promise ; 参考代码如下:
let profile = cameraoutputcapability.previewProfiles[0]; cameraManager.createPreviewOutput(profile, surfaceId, (err, previewOutput) => { if (err) { console.error(`Failed to gcreate previewOutput. ${err.message}`); return; } console.log('Callback returned with previewOutput created.'); })
let profile = cameraoutputcapability.previewProfiles[0]; cameraManager.createPreviewOutput(profile, surfaceId).then((previewOutput) => { console.log('Promise returned with previewOutput created.'); })
-
CameraManager中接口createPhotoOutput新增传递参数profile: Profile,profile参数由getSupportedOutputCapability接口获取,因此旧接口CreatePhotoOutput(surfaceId: string, callback: AsyncCallback
): void;以及CreatePhotoOutput(surfaceId: string): Promise ;变更为createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback ): void;和createPhotoOutput(profile: Profile, surfaceId: string): Promise ; 参考代码如下:
let profile = cameraoutputcapability.photoProfiles[0]; cameraManager.createPhotoOutput(profile, surfaceId, (err, photoOutput) => { if (err) { console.error(`Failed to create photoOutput. ${err.message}`); return; } console.log('Callback returned with photoOutput created.'); })
let profile = cameraoutputcapability.photoProfiles[0]; cameraManager.createPhotoOutput(profile, surfaceId).then((photoOutput) => { console.log('Promise returned with photoOutput created.'); })
-
CameraManager中接口createVideoOutput新增传递参数profile: Profile,profile参数由getSupportedOutputCapability接口获取,因此旧接口createVideoOutput(surfaceId: string, callback: AsyncCallback
): void;以及createVideoOutput(surfaceId: string): Promise ;变更为createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback ): void;和createVideoOutput(profile: VideoProfile, surfaceId: string): Promise ; 参考代码如下:
let profile = cameraoutputcapability.videoProfiles[0]; cameraManager.createVideoOutput(profile, surfaceId, (err, videoOutput) => { if (err) { console.error(`Failed to create videoOutput. ${err.message}`); return; } console.log('Callback returned with an array of supported outputCapability' ); })
let profile = cameraoutputcapability.videoProfiles[0]; cameraManager.createVideoOutput(profile, surfaceId).then((videoOutput) => { console.log('Promise returned with videoOutput created.'); })
-
CameraManager中接口createMetadataOutput新增传递参数metadataObjectTypes: Array
,metadataObjectTypes参数由getSupportedOutputCapability接口获取,因此旧接口function createMetadataOutput(callback: AsyncCallback ): void;以及function createMetadataOutput(): Promise ;变更为createMetadataOutput(metadataObjectTypes: Array , callback: AsyncCallback ): void;和createMetadataOutput(metadataObjectTypes: Array ): Promise ; 参考代码如下:
let metadataObjectTypes = cameraoutputcapability.supportedMetadataObjectTypes; cameraManager.createMetadataOutput(metadataObjectTypes, (err, metadataOutput) => { if (err) { console.error(`Failed to create metadataOutput. ${err.message}`); return; } console.log('Callback returned with metadataOutput created.'); })
let metadataObjectTypes = cameraoutputcapability.supportedMetadataObjectTypes; cameraManager.createMetadataOutput(metadataObjectTypes).then((metadataOutput) => { console.log('Promise returned with metadataOutput created.'); })
-
CameraManager中createCaptureSession不需要考虑context属性,因此旧接口createCaptureSession(context: Context, callback: AsyncCallback
): void;以及createCaptureSession(context: Context): Promise ;改为createCaptureSession(callback: AsyncCallback ): void;和createCaptureSession(): Promise ; 参考代码如下:
cameraManager.createCaptureSession((err, captureSession) => { if (err) { console.error(`Failed to create captureSession. ${err.message}`); return; } console.log('Callback returned with captureSession created.'); })
cameraManager.createCaptureSession().then((captureSession) => { console.log('Promise returned with captureSession created.'); })
-
CameraStatusInfo接口下属性camera类型由Camera变更为CameraDevice
-
CameraInput中接口on(type: 'error')新增传递参数camera: CameraDevice,因此旧接口on(type: 'error', callback: ErrorCallback
): void;变更为on(type: 'error', camera: CameraDevice, callback: ErrorCallback ): void; 参考代码如下:
let cameraDevice = cameras[0]; cameraInput.on('error', cameraDevice, (cameraInputError) => { console.log(`Camera input error code: ${cameraInputError.code}`); })
-
CameraInput中以下接口调整到CaptureSession中
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<Array
>): void;
getExposureBiasRange(): Promise<Array>; 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<Array
>): void;
getZoomRatioRange(): Promise<Array>; getZoomRatio(callback: AsyncCallback
): void;
getZoomRatio(): Promise; setZoomRatio(zoomRatio: number, callback: AsyncCallback
): void;
setZoomRatio(zoomRatio: number): Promise; -
CameraInput中接口on(type: 'focusStateChange', callback: AsyncCallback
): void;调整到CaptureSession中,对应接口on(type: 'focusStateChange', callback: AsyncCallback ): void; 参考代码如下:
captureSession.on('focusStateChange', (focusState) => { console.log(`Focus state : ${focusState}`); })
-
枚举ExposureMode中
枚举值名称:EXPOSURE_MODE_AUTO,初值由默认变更为1;
枚举值名称:EXPOSURE_MODE_CONTINUOUS_AUTO,初值由默认变更为2;
-
枚举VideoStabilizationMode中
枚举值名称:LOW,初值由默认变更为1;
枚举值名称:MIDDLE,初值由默认变更为2;
枚举值名称:HIGH,初值由默认变更为3;
枚举值名称:AUTO,初值由默认变更为4;
-
CaptureSession中接口addOutput参数由原来子类类型(PreviewOutput,PhotoOutput,VideoOutput,MetadataOutput)统一修改为基类类型(CameraOutput),变更后由原来8个接口缩减为2个接口。
改变前接口为:
addOutput(previewOutput: PreviewOutput, callback: AsyncCallback
): void;
addOutput(previewOutput: PreviewOutput): Promise;
addOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void;
addOutput(photoOutput: PhotoOutput): Promise;
addOutput(videoOutput: VideoOutput, callback: AsyncCallback): void;
addOutput(videoOutput: VideoOutput): Promise;
addOutput(metadataOutput: MetadataOutput, callback: AsyncCallback): void;
addOutput(metadataOutput: MetadataOutput): Promise; 改变后接口为:
addOutput(cameraOutput: CameraOutput, callback: AsyncCallback
): void;
addOutput(cameraOutput: CameraOutput): Promise; 参考代码如下:以PreviewOutput为例
captureSession.addOutput(previewOutput, (err) => { if (err) { console.error(`Failed to add output. ${err.message}`); return; } console.log('Callback returned with output added.'); })
captureSession.addOutput(previewOutput).then(() => { console.log('Promise returned with cameraOutput added.'); })
-
CaptureSession中接口removeOutput参数由原来子类类型(PreviewOutput,PhotoOutput,VideoOutput,MetadataOutput)统一修改为基类类型(CameraOutput),变更后由原来8个接口缩减为2个接口。
改变前接口为:
removeOutput(previewOutput: PreviewOutput, callback: AsyncCallback
): void;
removeOutput(previewOutput: PreviewOutput): Promise;
removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void;
removeOutput(photoOutput: PhotoOutput): Promise;
removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void;
removeOutput(videoOutput: VideoOutput): Promise;
removeOutput(metadataOutput: MetadataOutput, callback: AsyncCallback): void;
removeOutput(metadataOutput: MetadataOutput): Promise; 改变后接口为:
removeOutput(cameraOutput: CameraOutput, callback: AsyncCallback
): void;
removeOutput(cameraOutput: CameraOutput): Promise; 参考代码如下:以PreviewOutput为例
captureSession.removeOutput(previewOutput, (err) => { if (err) { console.error(`Failed to remove the CameraOutput instance. ${err.message}`); return; } console.log('Callback invoked to indicate that the CameraOutput instance is removed.'); });
captureSession.removeOutput(previewOutput).then(() => { console.log('Promise returned to indicate that the CameraOutput instance is removed.'); })
-
枚举MetadataObjectType中
枚举值名称由FACE变更为FACE_DETECTION;
-
接口Camera名称更改为CameraDevice