1# 媒体子系统JS API变更Changelog 2 3## camera接口变更 4基于以下原因新增部分功能接口以及废弃部分接口: 51. 提升开发者使用相机接口的便利。 62. 帮助开发者快速掌握相机开发接口,快速投入到开发当中。 73. 易于后续版本中框架功能的扩展,降低框架模块之间的耦合度。 8 9具体参考下方变更内容,开发者需要根据以下说明对应用进行适配。 10 11 **变更影响** 12 13影响API9版本的JS接口,应用需要进行适配才可以在新版本SDK环境正常实现功能。 14 15**关键的接口/组件变更** 16 17| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | 18| ---------------------- | ----------------------- | ------------------------------------------------------------ | -------- | 19| ohos.multimedia.camera | Profile | readonly format:CameraFormat; | 新增 | 20| ohos.multimedia.camera | Profile | readonly size: Size; | 新增 | 21| ohos.multimedia.camera | FrameRateRange | readonly min: number; | 新增 | 22| ohos.multimedia.camera | FrameRateRange | readonly max: number; | 新增 | 23| ohos.multimedia.camera | VideoProfile | readonly frameRateRange: FrameRateRange; | 新增 | 24| ohos.multimedia.camera | CameraOutputCapability | readonly previewProfiles: Array<Profile>; | 新增 | 25| ohos.multimedia.camera | CameraOutputCapability | readonly photoProfiles: Array<Profile>; | 新增 | 26| ohos.multimedia.camera | CameraOutputCapability | readonly videoProfiles: Array<VideoProfile>; | 新增 | 27| ohos.multimedia.camera | CameraOutputCapability | readonly supportedMetadataObjectTypes: Array<MetadataObjectType>; | 新增 | 28| ohos.multimedia.camera | CameraManager | getSupportedCameras(callback: AsyncCallback<Array<CameraDevice>>): void;<br/>getSupportedCameras(): Promise<Array<CameraDevice>>; | 新增 | 29| ohos.multimedia.camera | CameraManager | getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback<CameraOutputCapability>): void;<br/>getSupportedOutputCapability(camera: CameraDevice): Promise<CameraOutputCapability>; | 新增 | 30| ohos.multimedia.camera | CameraManager | isCameraMuted(): boolean; | 新增 | 31| ohos.multimedia.camera | CameraManager | isCameraMuteSupported(): boolean; | 新增 | 32| ohos.multimedia.camera | CameraManager | muteCamera(mute: boolean): void; | 新增 | 33| ohos.multimedia.camera | CameraManager | createCameraInput(camera: CameraDevice, callback: AsyncCallback<CameraInput>): void;<br/>createCameraInput(camera: CameraDevice): Promise<CameraInput>; | 新增 | 34| ohos.multimedia.camera | CameraManager | createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<PreviewOutput>): void;<br/>createPreviewOutput(profile: Profile, surfaceId: string): Promise<PreviewOutput>; | 新增 | 35| ohos.multimedia.camera | CameraManager | createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<PhotoOutput>): void;<br/>createPhotoOutput(profile: Profile, surfaceId: string): Promise<PhotoOutput>; | 新增 | 36| ohos.multimedia.camera | CameraManager | createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback<VideoOutput>): void;<br/>createVideoOutput(profile: VideoProfile, surfaceId: string): Promise<VideoOutput>; | 新增 | 37| ohos.multimedia.camera | CameraManager | createMetadataOutput(metadataObjectTypes: Array<MetadataObjectType>, callback: AsyncCallback<MetadataOutput>): void;<br/>createMetadataOutput(metadataObjectTypes: Array<MetadataObjectType>): Promise<MetadataOutput>; | 新增 | 38| ohos.multimedia.camera | CameraManager | createCaptureSession(callback: AsyncCallback<CaptureSession>): void;<br/>createCaptureSession(): Promise<CaptureSession>; | 新增 | 39| ohos.multimedia.camera | CameraManager | on(type: 'cameraMute', callback: AsyncCallback<boolean>): void; | 新增 | 40| ohos.multimedia.camera | CameraManager | getCameras(callback: AsyncCallback<Array<Camera>>): void;<br/>getCameras(): Promise<Array<Camera>>; | 废弃 | 41| ohos.multimedia.camera | CameraManager | createCameraInput(cameraId: string, callback: AsyncCallback<CameraInput>): void;<br/>createCameraInput(cameraId: string): Promise<CameraInput>; | 废弃 | 42| ohos.multimedia.camera | CameraManager | createCaptureSession(context: Context, callback: AsyncCallback<CaptureSession>): void;<br/>createCaptureSession(context: Context): Promise<CaptureSession>; | 废弃 | 43| ohos.multimedia.camera | CameraManager | createPreviewOutput(surfaceId: string, callback: AsyncCallback<PreviewOutput>): void;<br/>createPreviewOutput(surfaceId: string): Promise<PreviewOutput>; | 废弃 | 44| ohos.multimedia.camera | CameraManager | CreatePhotoOutput(surfaceId: string, callback: AsyncCallback<PhotoOutput>): void;<br/>CreatePhotoOutput(surfaceId: string): Promise<PhotoOutput>; | 废弃 | 45| ohos.multimedia.camera | CameraManager | createVideoOutput(surfaceId: string, callback: AsyncCallback<VideoOutput>): void;<br/>createVideoOutput(surfaceId: string): Promise<VideoOutput>; | 废弃 | 46| ohos.multimedia.camera | CameraManager | createMetadataOutput(callback: AsyncCallback<MetadataOutput>): void;<br/>createVideoOutput(): Promise<MetadataOutput>; | 废弃 | 47| ohos.multimedia.camera | CameraStatusInfo | camera: CameraDevice; | 新增 | 48| ohos.multimedia.camera | CameraStatusInfo | camera: Camera; | 废弃 | 49| ohos.multimedia.camera | CameraDevice | interface CameraDevice | 新增 | 50| ohos.multimedia.camera | Camera | interface Camera | 废弃 | 51| ohos.multimedia.camera | CameraInput | open(callback: AsyncCallback<void>): void;<br/>open(): Promise<void>; | 新增 | 52| ohos.multimedia.camera | CameraInput | close(callback: AsyncCallback<void>): void;<br/>close(): Promise<void>; | 新增 | 53| ohos.multimedia.camera | CameraInput | on(type: 'error', camera: CameraDevice, callback: ErrorCallback<CameraInputError>): void; | 新增 | 54| ohos.multimedia.camera | CameraInput | isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback<boolean>): void;<br/>isFocusModeSupported(afMode: FocusMode): Promise<boolean>; | 废弃 | 55| ohos.multimedia.camera | CameraInput | getFocusMode(callback: AsyncCallback<FocusMode>): void;<br/>getFocusMode(): Promise<FocusMode>; | 废弃 | 56| ohos.multimedia.camera | CameraInput | setFocusMode(afMode: FocusMode, callback: AsyncCallback<void>): void;<br/>setFocusMode(afMode: FocusMode): Promise<void>; | 废弃 | 57| ohos.multimedia.camera | CameraInput | getZoomRatioRange(callback: AsyncCallback<Array<number>>): void;<br/>getZoomRatioRange(): Promise<Array<number>>; | 废弃 | 58| ohos.multimedia.camera | CameraInput | getZoomRatio(callback: AsyncCallback<number>): void;<br/>getZoomRatio(): Promise<number>; | 废弃 | 59| ohos.multimedia.camera | CameraInput | setZoomRatio(zoomRatio: number, callback: AsyncCallback<void>): void;<br/>setZoomRatio(zoomRatio: number): Promise<void>; | 废弃 | 60| ohos.multimedia.camera | CameraInput | getCameraId(callback: AsyncCallback<string>): void;<br/>getCameraId(): Promise<string>; | 废弃 | 61| ohos.multimedia.camera | CameraInput | getExposurePoint(callback: AsyncCallback<Point>): void;<br/>getExposurePoint(): Promise<Point>; | 废弃 | 62| ohos.multimedia.camera | CameraInput | setExposurePoint(exposurePoint: Point, callback: AsyncCallback<void>): void;<br/>setExposurePoint(exposurePoint: Point): Promise<void>; | 废弃 | 63| ohos.multimedia.camera | CameraInput | hasFlash(callback: AsyncCallback<boolean>): void;<br/>hasFlash(): Promise<boolean>; | 废弃 | 64| ohos.multimedia.camera | CameraInput | isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback<boolean>): void;<br/>isFlashModeSupported(flashMode: FlashMode): Promise<boolean>; | 废弃 | 65| ohos.multimedia.camera | CameraInput | getFlashMode(callback: AsyncCallback<FlashMode>): void;<br/>getFlashMode(): Promise<FlashMode>; | 废弃 | 66| ohos.multimedia.camera | CameraInput | setFlashMode(flashMode: FlashMode, callback: AsyncCallback<void>): void;<br/>setFlashMode(flashMode: FlashMode): Promise<void>; | 废弃 | 67| ohos.multimedia.camera | CameraInput | isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback<boolean>): void;<br/>isExposureModeSupported(aeMode: ExposureMode): Promise<boolean>; | 废弃 | 68| ohos.multimedia.camera | CameraInput | getExposureMode(callback: AsyncCallback<ExposureMode>): void;<br/>getExposureMode(): Promise<ExposureMode>; | 废弃 | 69| ohos.multimedia.camera | CameraInput | setExposureMode(aeMode: ExposureMode, callback: AsyncCallback<void>): void;<br/>setExposureMode(aeMode: ExposureMode): Promise<void>; | 废弃 | 70| ohos.multimedia.camera | CameraInput | getMeteringPoint(callback: AsyncCallback<Point>): void;<br/>getMeteringPoint(): Promise<Point>; | 废弃 | 71| ohos.multimedia.camera | CameraInput | setMeteringPoint(point: Point, callback: AsyncCallback<void>): void;<br/>setMeteringPoint(point: Point): Promise<void>; | 废弃 | 72| ohos.multimedia.camera | CameraInput | getExposureBiasRange(callback: AsyncCallback<Array<number>>): void;<br/>getExposureBiasRange(): Promise<Array<number>>; | 废弃 | 73| ohos.multimedia.camera | CameraInput | setExposureBias(exposureBias: number, callback: AsyncCallback<void>): void;<br/>setExposureBias(exposureBias: number): Promise<void>; | 废弃 | 74| ohos.multimedia.camera | CameraInput | getExposureValue(callback: AsyncCallback<number>): void;<br/>getExposureValue(): Promise<number>; | 废弃 | 75| ohos.multimedia.camera | CameraInput | isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback<boolean>): void;<br/>isFocusModeSupported(afMode: FocusMode): Promise<boolean>; | 废弃 | 76| ohos.multimedia.camera | CameraInput | getFocusMode(callback: AsyncCallback<FocusMode>): void;<br/>getFocusMode(): Promise<FocusMode>; | 废弃 | 77| ohos.multimedia.camera | CameraInput | setFocusMode(afMode: FocusMode, callback: AsyncCallback<void>): void;<br/>setFocusMode(afMode: FocusMode): Promise<void>; | 废弃 | 78| ohos.multimedia.camera | CameraInput | setFocusPoint(point: Point, callback: AsyncCallback<void>): void;<br/>setFocusPoint(point: Point): Promise<void>; | 废弃 | 79| ohos.multimedia.camera | CameraInput | getFocusPoint(callback: AsyncCallback<Point>): void;<br/>getFocusPoint(): Promise<Point>; | 废弃 | 80| ohos.multimedia.camera | CameraInput | getFocalLength(callback: AsyncCallback<number>): void;<br/>getFocalLength(): Promise<number>; | 废弃 | 81| ohos.multimedia.camera | CameraInput | getZoomRatioRange(callback: AsyncCallback<Array<number>>): void;<br/>getZoomRatioRange(): Promise<Array<number>>; | 废弃 | 82| ohos.multimedia.camera | CameraInput | getZoomRatio(callback: AsyncCallback<number>): void;<br/>getZoomRatio(): Promise<number>; | 废弃 | 83| ohos.multimedia.camera | CameraInput | setZoomRatio(zoomRatio: number, callback: AsyncCallback<void>): void;<br/>setZoomRatio(zoomRatio: number): Promise<void>; | 废弃 | 84| ohos.multimedia.camera | CameraInput | on(type: 'focusStateChange', callback: AsyncCallback<FocusState>): void; | 废弃 | 85| ohos.multimedia.camera | CameraInput | on(type: 'exposureStateChange', callback: AsyncCallback<ExposureState>): void; | 废弃 | 86| ohos.multimedia.camera | CameraInput | on(type: 'error', callback: ErrorCallback<CameraInputError>): void; | 废弃 | 87| ohos.multimedia.camera | CameraInputErrorCode | ERROR_NO_PERMISSION = 0 | 新增 | 88| ohos.multimedia.camera | CameraInputErrorCode | ERROR_DEVICE_PREEMPTED = 1 | 新增 | 89| ohos.multimedia.camera | CameraInputErrorCode | ERROR_DEVICE_DISCONNECTED = 2 | 新增 | 90| ohos.multimedia.camera | CameraInputErrorCode | ERROR_DEVICE_IN_USE = 3 | 新增 | 91| ohos.multimedia.camera | CameraInputErrorCode | ERROR_DRIVER_ERROR = 4 | 新增 | 92| ohos.multimedia.camera | CameraFormat | CAMERA_FORMAT_RGBA_8888 = 3 | 新增 | 93| ohos.multimedia.camera | ExposureMode | EXPOSURE_MODE_AUTO = 1 | 新增 | 94| ohos.multimedia.camera | ExposureMode | EXPOSURE_MODE_CONTINUOUS_AUTO = 2 | 新增 | 95| ohos.multimedia.camera | ExposureMode | EXPOSURE_MODE_AUTO | 废弃 | 96| ohos.multimedia.camera | ExposureMode | EXPOSURE_MODE_CONTINUOUS_AUTO | 废弃 | 97| ohos.multimedia.camera | VideoStabilizationMode | LOW = 1 | 新增 | 98| ohos.multimedia.camera | VideoStabilizationMode | MIDDLE = 2 | 新增 | 99| ohos.multimedia.camera | VideoStabilizationMode | HIGH = 3 | 新增 | 100| ohos.multimedia.camera | VideoStabilizationMode | AUTO = 4 | 新增 | 101| ohos.multimedia.camera | VideoStabilizationMode | LOW | 废弃 | 102| ohos.multimedia.camera | VideoStabilizationMode | MIDDLE | 废弃 | 103| ohos.multimedia.camera | VideoStabilizationMode | HIGH | 废弃 | 104| ohos.multimedia.camera | VideoStabilizationMode | AUTO | 废弃 | 105| ohos.multimedia.camera | CaptureSession | addOutput(cameraOutput: CameraOutput, callback: AsyncCallback<void>): void;<br/>addOutput(cameraOutput: CameraOutput): Promise<void>; | 新增 | 106| ohos.multimedia.camera | CaptureSession | removeOutput(cameraOutput: CameraOutput, callback: AsyncCallback<void>): void;<br/>removeOutput(cameraOutput: CameraOutput): Promise<void>; | 新增 | 107| ohos.multimedia.camera | CaptureSession | isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode, callback: AsyncCallback<boolean>): void;<br/>isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): Promise<boolean>; | 新增 | 108| ohos.multimedia.camera | CaptureSession | getActiveVideoStabilizationMode(callback: AsyncCallback<VideoStabilizationMode>): void;<br/>getActiveVideoStabilizationMode(): Promise<VideoStabilizationMode>; | 新增 | 109| ohos.multimedia.camera | CaptureSession | setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback<void>): void;<br/>setVideoStabilizationMode(mode: VideoStabilizationMode): Promise<void>; | 新增 | 110| ohos.multimedia.camera | CaptureSession | on(type: 'focusStateChange', callback: AsyncCallback<FocusState>): void; | 新增 | 111| ohos.multimedia.camera | CaptureSession | hasFlash(callback: AsyncCallback<boolean>): void;<br/>hasFlash(): Promise<boolean>; | 新增 | 112| ohos.multimedia.camera | CaptureSession | isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback<boolean>): void;<br/>isFlashModeSupported(flashMode: FlashMode): Promise<boolean>; | 新增 | 113| ohos.multimedia.camera | CaptureSession | getFlashMode(callback: AsyncCallback<FlashMode>): void;<br/>getFlashMode(): Promise<FlashMode>; | 新增 | 114| ohos.multimedia.camera | CaptureSession | setFlashMode(flashMode: FlashMode, callback: AsyncCallback<void>): void;<br/>setFlashMode(flashMode: FlashMode): Promise<void>; | 新增 | 115| ohos.multimedia.camera | CaptureSession | isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback<boolean>): void;<br/>isExposureModeSupported(aeMode: ExposureMode): Promise<boolean>; | 新增 | 116| ohos.multimedia.camera | CaptureSession | getExposureMode(callback: AsyncCallback<ExposureMode>): void;<br/>getExposureMode(): Promise<ExposureMode>; | 新增 | 117| ohos.multimedia.camera | CaptureSession | setExposureMode(aeMode: ExposureMode, callback: AsyncCallback<void>): void;<br/>setExposureMode(aeMode: ExposureMode): Promise<void>; | 新增 | 118| ohos.multimedia.camera | CaptureSession | getMeteringPoint(callback: AsyncCallback<Point>): void;<br/>getMeteringPoint(): Promise<Point>; | 新增 | 119| ohos.multimedia.camera | CaptureSession | setMeteringPoint(point: Point, callback: AsyncCallback<void>): void;<br/>setMeteringPoint(point: Point): Promise<void>; | 新增 | 120| ohos.multimedia.camera | CaptureSession | getExposureBiasRange(callback: AsyncCallback<Array<number>>): void;<br/>getExposureBiasRange(): Promise<Array<number>>; | 新增 | 121| ohos.multimedia.camera | CaptureSession | setExposureBias(exposureBias: number, callback: AsyncCallback<void>): void;<br/>setExposureBias(exposureBias: number): Promise<void>; | 新增 | 122| ohos.multimedia.camera | CaptureSession | getExposureValue(callback: AsyncCallback<number>): void;<br/>getExposureValue(): Promise<number>; | 新增 | 123| ohos.multimedia.camera | CaptureSession | isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback<boolean>): void;<br/>isFocusModeSupported(afMode: FocusMode): Promise<boolean>; | 新增 | 124| ohos.multimedia.camera | CaptureSession | getFocusMode(callback: AsyncCallback<FocusMode>): void;<br/>getFocusMode(): Promise<FocusMode>; | 新增 | 125| ohos.multimedia.camera | CaptureSession | setFocusMode(afMode: FocusMode, callback: AsyncCallback<void>): void;<br/>setFocusMode(afMode: FocusMode): Promise<void>; | 新增 | 126| ohos.multimedia.camera | CaptureSession | setFocusPoint(point: Point, callback: AsyncCallback<void>): void;<br/>setFocusPoint(point: Point): Promise<void>; | 新增 | 127| ohos.multimedia.camera | CaptureSession | getFocusPoint(callback: AsyncCallback<Point>): void;<br/>getFocusPoint(): Promise<Point>; | 新增 | 128| ohos.multimedia.camera | CaptureSession | getFocalLength(callback: AsyncCallback<number>): void;<br/>getFocalLength(): Promise<number>; | 新增 | 129| ohos.multimedia.camera | CaptureSession | getZoomRatioRange(callback: AsyncCallback<Array<number>>): void;<br/>getZoomRatioRange(): Promise<Array<number>>; | 新增 | 130| ohos.multimedia.camera | CaptureSession | getZoomRatio(callback: AsyncCallback<number>): void;<br/>getZoomRatio(): Promise<number>; | 新增 | 131| ohos.multimedia.camera | CaptureSession | setZoomRatio(zoomRatio: number, callback: AsyncCallback<void>): void;<br/>setZoomRatio(zoomRatio: number): Promise<void>; | 新增 | 132| ohos.multimedia.camera | CaptureSession | addOutput(previewOutput: PreviewOutput, callback: AsyncCallback<void>): void;<br/>addOutput(previewOutput: PreviewOutput): Promise<void>;<br/>addOutput(photoOutput: PhotoOutput, callback: AsyncCallback<void>): void;<br/>addOutput(photoOutput: PhotoOutput): Promise<void>;<br/>addOutput(videoOutput: VideoOutput, callback: AsyncCallback<void>): void;<br/>addOutput(videoOutput: VideoOutput): Promise<void>; | 废弃 | 133| ohos.multimedia.camera | CaptureSession | removeOutput(previewOutput: PreviewOutput, callback: AsyncCallback<void>): void;<br/>removeOutput(previewOutput: PreviewOutput): Promise<void>;<br/>removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback<void>): void;<br/>removeOutput(photoOutput: PhotoOutput): Promise<void>;removeOutput(videoOutput: VideoOutput, callback: AsyncCallback<void>): void;<br/>removeOutput(videoOutput: VideoOutput): Promise<void>;<br/>removeOutput(metadataOutput: MetadataOutput, callback: AsyncCallback<void>): void;<br/>removeOutput(metadataOutput: MetadataOutput): Promise<void>; | 废弃 | 134| ohos.multimedia.camera | CaptureSessionErrorCode | ERROR_INSUFFICIENT_RESOURCES = 0 | 新增 | 135| ohos.multimedia.camera | CaptureSessionErrorCode | ERROR_TIMEOUT = 1 | 新增 | 136| ohos.multimedia.camera | CameraOutput | release(callback: AsyncCallback<void>): void;<br/>release(): Promise<void>; | 新增 | 137| ohos.multimedia.camera | PreviewOutput | start(callback: AsyncCallback<void>): void;<br/>start(): Promise<void>; | 新增 | 138| ohos.multimedia.camera | PreviewOutput | stop(callback: AsyncCallback<void>): void;<br/>stop(): Promise<void>; | 新增 | 139| ohos.multimedia.camera | PreviewOutput | release(callback: AsyncCallback<void>): void;<br/>release(): Promise<void>; | 废弃 | 140| ohos.multimedia.camera | PhotoOutput | release(callback: AsyncCallback<void>): void;<br/>release(): Promise<void>; | 废弃 | 141| ohos.multimedia.camera | VideoOutput | release(callback: AsyncCallback<void>): void;<br/>release(): Promise<void>; | 废弃 | 142| ohos.multimedia.camera | PhotoCaptureSetting | mirror?: boolean; | 新增 | 143| ohos.multimedia.camera | PhotoOutputErrorCode | ERROR_DRIVER_ERROR = 0 | 新增 | 144| ohos.multimedia.camera | PhotoOutputErrorCode | ERROR_INSUFFICIENT_RESOURCES = 1 | 新增 | 145| ohos.multimedia.camera | PhotoOutputErrorCode | ERROR_TIMEOUT = 2 | 新增 | 146| ohos.multimedia.camera | VideoOutputErrorCode | ERROR_DRIVER_ERROR = 0 | 新增 | 147| ohos.multimedia.camera | MetadataObjectType | FACE_DETECTION = 0 | 新增 | 148| ohos.multimedia.camera | MetadataObjectType | FACE = 0 | 废弃 | 149| ohos.multimedia.camera | MetadataOutput | on(type: 'error', callback: ErrorCallback<MetadataOutputError>): void; | 新增 | 150| ohos.multimedia.camera | MetadataOutput | setCapturingMetadataObjectTypes(metadataObjectTypes: Array<MetadataObjectType>, callback: AsyncCallback<void>): void;<br/>setCapturingMetadataObjectTypes(metadataObjectTypes: Array<MetadataObjectType>): Promise<void>; | 废弃 | 151| ohos.multimedia.camera | MetadataOutput | getSupportedMetadataObjectTypes(callback: AsyncCallback<Array<MetadataObjectType>>): void;<br/>getSupportedMetadataObjectTypes(): Promise<Array<MetadataObjectType>>; | 废弃 | 152| ohos.multimedia.camera | MetadataOutputErrorCode | ERROR_UNKNOWN = -1 | 新增 | 153| ohos.multimedia.camera | MetadataOutputErrorCode | ERROR_INSUFFICIENT_RESOURCES = 0 | 新增 | 154| ohos.multimedia.camera | MetadataOutputError | code: MetadataOutputErrorCode; | 新增 | 155 156**适配指导** 157 158除新增接口,和废弃接口之外,开发者需要关注变更的接口的适配: 159 160从Beta4版本开始,对以下接口进行调整: 161 162**新增接口** 163 1641. Profile接口 165 166 属性1:readonly format,类型:CameraFormat; 167 168 属性2:readonly size,类型:Size; 169 1702. FrameRateRange接口 171 172 属性1:readonly min,类型:number; 173 174 属性2:readonly max,类型:number; 175 1763. VideoProfile接口,继承自Profile 177 178 属性:readonly frameRateRange,类型:FrameRateRange; 179 1804. CameraOutputCapability接口 181 182 属性1:readonly previewProfiles,类型:Array<Profile>; 183 184 属性2:readonly photoProfiles,类型:Array<Profile>; 185 186 属性3:readonly videoProfiles,类型:Array<VideoProfile>; 187 188 属性4:readonly supportedMetadataObjectTypes,类型:Array<MetadataObjectType>; 189 1905. CameraManager中新增 191 192 getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback<CameraOutputCapability>): void; 193 194 getSupportedOutputCapability(camera: CameraDevice): Promise<CameraOutputCapability>; 195 196 参考代码如下: 197 198 ``` 199 cameraManager.getSupportedCameras().then((cameras) => { 200 let cameraDevice = cameras[0]; 201 cameraManager.getSupportedOutputCapability(cameraDevice, (err, CameraOutputCapability) => { 202 if (err) { 203 console.error(`Failed to get the outputCapability. ${err.message}`); 204 return; 205 } 206 console.log('Callback returned with an array of supported outputCapability'); 207 }) 208 }) 209 ``` 210 211 ``` 212 cameraManager.getSupportedCameras().then((cameras) => { 213 let cameraDevice = cameras[0]; 214 cameraManager.getSupportedOutputCapability(cameraDevice).then((cameraoutputcapability) => { 215 console.log('Promise returned with an array of supported outputCapability'); 216 }) 217 }) 218 ``` 219 2206. CameraManager中新增isCameraMuted(): boolean; 221 222 参考代码如下: 223 224 ``` 225 let ismuted = cameraManager.isCameraMuted(); 226 ``` 227 2287. CameraManager中新增isCameraMuteSupported(): boolean; 229 230 参考代码如下: 231 232 ``` 233 let ismutesuppotred = cameraManager.isCameraMuteSupported(); 234 ``` 235 2368. CameraManager中新增muteCamera(mute: boolean): void; 237 238 参考代码如下: 239 240 ``` 241 let mute = true; 242 cameraManager.muteCamera(mute); 243 ``` 244 2459. CameraManager中新增on(type: 'cameraMute', callback: AsyncCallback<boolean>): void; 246 247 参考代码如下: 248 249 ``` 250 cameraManager.on('cameraMute', (err, curMuetd) => { 251 if (err) { 252 console.error(`Failed to get cameraMute callback. ${err.message}`); 253 return; 254 } 255 }) 256 ``` 257 25810. CameraInput中新增open(callback: AsyncCallback<void>): void;以及open(): Promise<void>; 259 260参考代码如下: 261 262``` 263cameraInput.open((err) => { 264 if (err) { 265 console.error(`Failed to open the camera. ${err.message}`); 266 return; 267 } 268 console.log('Callback returned with camera opened.'); 269}) 270``` 271 272``` 273cameraInput.open().then(() => { 274 console.log('Promise returned with camera opened.'); 275}) 276``` 277 27811. CameraInput中新增close(callback: AsyncCallback<void>): void;以及close(): Promise<void>; 279 280 参考代码如下: 281 282 ``` 283 cameraInput.close((err) => { 284 if (err) { 285 console.error(`Failed to close the cameras. ${err.message}`); 286 return; 287 } 288 console.log('Callback returned with camera closed.'); 289 }) 290 ``` 291 292 ``` 293 cameraInput.close().then(() => { 294 console.log('Promise returned with camera closed.'); 295 }) 296 ``` 297 29812. 枚举CameraInputErrorCode中新增 299 300 枚举值名称:ERROR_NO_PERMISSION,值:0; 301 302 枚举值名称:ERROR_DEVICE_PREEMPTED,值:1; 303 304 枚举值名称:ERROR_DEVICE_DISCONNECTED,值:2; 305 306 枚举值名称:ERROR_DEVICE_IN_USE,值:3; 307 308 枚举值名称:ERROR_DRIVER_ERROR,值:4; 309 31013. 枚举CameraFormat中新增 311 312 枚举值名称:CAMERA_FORMAT_RGBA_8888,值:3; 313 31414. CaptureSession中新增getMeteringPoint(callback: AsyncCallback<Point>): void;以及getMeteringPoint(): Promise<Point>; 315 316 参考代码如下: 317 318 ``` 319 captureSession.getMeteringPoint((err, exposurePoint) => { 320 if (err) { 321 console.log(`Failed to get the current exposure point ${err.message}`); 322 return ; 323 } 324 console.log(`Callback returned with current exposure point: ${exposurePoint}`); 325 }) 326 ``` 327 328 ``` 329 captureSession.getMeteringPoint().then((exposurePoint) => { 330 console.log(`Promise returned with current exposure point : ${exposurePoint}`); 331 }) 332 ``` 333 33415. CaptureSession中新增setMeteringPoint(point: Point, callback: AsyncCallback<void>): void;以及setMeteringPoint(point: Point): Promise<void>; 335 336 参考代码如下: 337 338 ``` 339 const Point1 = {x: 1, y: 1}; 340 341 captureSession.setMeteringPoint(Point1,(err) => { 342 if (err) { 343 console.log(`Failed to set the exposure point ${err.message}`); 344 return ; 345 } 346 console.log('Callback returned with the successful execution of setMeteringPoint'); 347 }) 348 ``` 349 350 ``` 351 const Point2 = {x: 2, y: 2}; 352 353 captureSession.setMeteringPoint(Point2).then(() => { 354 console.log('Promise returned with the successful execution of setMeteringPoint'); 355 }) 356 ``` 357 35816. 枚举CaptureSessionErrorCode中新增 359 360 枚举值名称:ERROR_INSUFFICIENT_RESOURCES,值:0; 361 362 枚举值名称:ERROR_TIMEOUT,值:1; 363 36417. 新增接口CameraOutput,接口下有release(callback: AsyncCallback<void>): void;以及release(): Promise<void>;方法 365 366 参考代码如下:用previewOutput做示例 367 368 ``` 369 previewOutput.release((err) => { 370 if (err) { 371 console.error(`Failed to release the PreviewOutput instance ${err.message}`); 372 return; 373 } 374 console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); 375 }); 376 ``` 377 378 ``` 379 previewOutput.release().then(() => { 380 console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); 381 }) 382 ``` 383 38418. PreviewOutput中新增start(callback: AsyncCallback<void>): void;以及start(): Promise<void>; 385 386 参考代码如下 387 388 ``` 389 previewOutput.start((err) => { 390 if (err) { 391 console.error(`Failed to start the previewOutput. ${err.message}`); 392 return; 393 } 394 console.log('Callback returned with previewOutput started.'); 395 }) 396 ``` 397 398 ``` 399 previewOutput.start().then(() => { 400 console.log('Promise returned with previewOutput started.'); 401 }) 402 ``` 403 40419. PreviewOutput中新增stop(callback: AsyncCallback<void>): void;以及stop(): Promise<void>; 405 406 参考代码如下 407 408 ``` 409 previewOutput.stop((err) => { 410 if (err) { 411 console.error(`Failed to stop the previewOutput. ${err.message}`); 412 return; 413 } 414 console.log('Callback returned with previewOutput stopped.'); 415 }) 416 ``` 417 418 ``` 419 previewOutput.stop().then(() => { 420 console.log('Callback returned with previewOutput stopped.'); 421 }) 422 ``` 423 42420. PhotoCaptureSetting接口 425 426 属性1:mirror?,类型:boolean; 427 42821. 枚举PhotoOutputErrorCode中新增 429 430 枚举值名称:ERROR_DRIVER_ERROR,值:0; 431 432 枚举值名称:ERROR_INSUFFICIENT_RESOURCES,值:1; 433 434 枚举值名称:ERROR_TIMEOUT,值:2; 435 43622. 枚举VideoOutputErrorCode中新增 437 438 枚举值名称:ERROR_DRIVER_ERROR,值:0; 439 44023. MetadataOutput中新增on(type: 'error', callback: ErrorCallback<MetadataOutputError>): void; 441 442 参考代码如下 443 444 ``` 445 metadataOutput.on('error', (metadataOutputError) => { 446 console.log(`Metadata output error code: ${metadataOutputError.code}`); 447 }) 448 ``` 449 45024. MetadataOutputErrorCode枚举 451 452 枚举值名称:ERROR_UNKNOWN,值:-1; 453 454 枚举值名称:ERROR_INSUFFICIENT_RESOURCES,值:0; 455 45625. MetadataOutputError接口 457 458 属性名称:code,值:MetadataOutputErrorCode 459 460**废弃接口** 461 4621. CameraInput中废弃接口on(type: 'exposureStateChange', callback: AsyncCallback<ExposureState>): void; 463 4642. previewOutput中废弃接口release(callback: AsyncCallback<void>): void;以及release(): Promise<void>; 465 4663. metadataOutput中废弃接口 467 468 setCapturingMetadataObjectTypes(metadataObjectTypes: Array<MetadataObjectType>, callback: AsyncCallback<void>): void;<br/>setCapturingMetadataObjectTypes(metadataObjectTypes: Array<MetadataObjectType>): Promise<void>; 469 4704. metadataOutput中废弃接口 471 472 getSupportedMetadataObjectTypes(callback: AsyncCallback<Array<MetadataObjectType>>): void;<br/>getSupportedMetadataObjectTypes(): Promise<Array<MetadataObjectType>>; 473 4745. PreviewOutput中废弃接口release(callback: AsyncCallback<void>): void;以及release(): Promise<void>; 475 4766. PhotoOutput中废弃接口release(callback: AsyncCallback<void>): void;以及release(): Promise<void>; 477 4787. VideoOutput中废弃接口release(callback: AsyncCallback<void>): void;以及release(): Promise<void>; 479 4808. CameraInput中废弃接口getCameraId(callback: AsyncCallback<string>): void;以及getCameraId(): Promise<string>; 481 4829. CameraInput中废弃接口getExposurePoint(callback: AsyncCallback<Point>): void;以及getExposurePoint(): Promise<Point>; 483 48410. CameraInput中废弃接口setExposurePoint(exposurePoint: Point, callback: AsyncCallback<void>): void;以及setExposurePoint(exposurePoint: Point): Promise<void>; 485 486**接口变更** 487 4881. CameraManager中接口getCameras返回值由Array<Camera>变更为Array<CameraDevice>,接口名由getCameras 更换为 getSupportedCameras,因此旧接口getCameras(callback: AsyncCallback<Array<Camera>>): void;以及getCameras(): Promise<Array<Camera>>;变更为getSupportedCameras(callback: AsyncCallback<Array<CameraDevice>>): void和getSupportedCameras(): Promise<Array<CameraDevice>>; 489 490 参考代码如下: 491 492 ``` 493 cameraManager.getSupportedCameras((err, cameras) => { 494 if (err) { 495 console.error(`Failed to get the cameras. ${err.message}`); 496 return; 497 } 498 console.log(`Callback returned with an array of supported cameras: ${cameras.length}`); 499 }) 500 ``` 501 502 ``` 503 cameraManager.getSupportedCameras().then((cameras) => { 504 console.log(`Promise returned with an array of supported cameras: ${cameras.length}`); 505 }) 506 ``` 507 5082. CameraManager中接口createCameraInput传递参数由原来cameraId: string变更为camera: CameraDevice,因此旧接口createCameraInput(cameraId: string, callback: AsyncCallback<CameraInput>): void;以及createCameraInput(cameraId: string): Promise<CameraInput>;变更为createCameraInput(camera: CameraDevice, callback: AsyncCallback<CameraInput>): void;和createCameraInput(camera: CameraDevice): Promise<CameraInput>; 509 510 参考代码如下: 511 512 ``` 513 let cameraDevice = cameras[0]; 514 cameraManager.createCameraInput(cameraDevice, (err, cameraInput) => { 515 if (err) { 516 console.error(`Failed to create the CameraInput instance. ${err.message}`); 517 return; 518 } 519 console.log('Callback returned with the CameraInput instance.'); 520 }) 521 ``` 522 523 ``` 524 let cameraDevice = cameras[0]; 525 cameraManager.createCameraInput(cameraDevice).then((cameraInput) => { 526 console.log('Promise returned with the CameraInput instance'); 527 }) 528 ``` 529 5303. CameraManager中接口createPreviewOutput新增传递参数profile: Profile,profile参数由getSupportedOutputCapability接口获取,因此旧接口createPreviewOutput(surfaceId: string, callback: AsyncCallback<PreviewOutput>): void;以及createPreviewOutput(surfaceId: string): Promise<PreviewOutput>;变更为createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<PreviewOutput>): void;createPreviewOutput(profile: Profile, surfaceId: string): Promise<PreviewOutput>; 531 532 参考代码如下: 533 534 ``` 535 let profile = cameraoutputcapability.previewProfiles[0]; 536 cameraManager.createPreviewOutput(profile, surfaceId, (err, previewOutput) => { 537 if (err) { 538 console.error(`Failed to gcreate previewOutput. ${err.message}`); 539 return; 540 } 541 console.log('Callback returned with previewOutput created.'); 542 }) 543 ``` 544 545 ``` 546 let profile = cameraoutputcapability.previewProfiles[0]; 547 cameraManager.createPreviewOutput(profile, surfaceId).then((previewOutput) => { 548 console.log('Promise returned with previewOutput created.'); 549 }) 550 ``` 551 5524. CameraManager中接口createPhotoOutput新增传递参数profile: Profile,profile参数由getSupportedOutputCapability接口获取,因此旧接口CreatePhotoOutput(surfaceId: string, callback: AsyncCallback<PhotoOutput>): void;以及CreatePhotoOutput(surfaceId: string): Promise<PhotoOutput>;变更为createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<PhotoOutput>): void;和createPhotoOutput(profile: Profile, surfaceId: string): Promise<PhotoOutput>; 553 554 参考代码如下: 555 556 ``` 557 let profile = cameraoutputcapability.photoProfiles[0]; 558 cameraManager.createPhotoOutput(profile, surfaceId, (err, photoOutput) => { 559 if (err) { 560 console.error(`Failed to create photoOutput. ${err.message}`); 561 return; 562 } 563 console.log('Callback returned with photoOutput created.'); 564 }) 565 ``` 566 567 ``` 568 let profile = cameraoutputcapability.photoProfiles[0]; 569 cameraManager.createPhotoOutput(profile, surfaceId).then((photoOutput) => { 570 console.log('Promise returned with photoOutput created.'); 571 }) 572 ``` 573 5745. CameraManager中接口createVideoOutput新增传递参数profile: Profile,profile参数由getSupportedOutputCapability接口获取,因此旧接口createVideoOutput(surfaceId: string, callback: AsyncCallback<VideoOutput>): void;以及createVideoOutput(surfaceId: string): Promise<VideoOutput>;变更为createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback<VideoOutput>): void;和createVideoOutput(profile: VideoProfile, surfaceId: string): Promise<VideoOutput>; 575 576 参考代码如下: 577 578 ``` 579 let profile = cameraoutputcapability.videoProfiles[0]; 580 cameraManager.createVideoOutput(profile, surfaceId, (err, videoOutput) => { 581 if (err) { 582 console.error(`Failed to create videoOutput. ${err.message}`); 583 return; 584 } 585 console.log('Callback returned with an array of supported outputCapability' ); 586 }) 587 ``` 588 589 ``` 590 let profile = cameraoutputcapability.videoProfiles[0]; 591 cameraManager.createVideoOutput(profile, surfaceId).then((videoOutput) => { 592 console.log('Promise returned with videoOutput created.'); 593 }) 594 ``` 595 5966. CameraManager中接口createMetadataOutput新增传递参数metadataObjectTypes: Array<MetadataObjectType>,metadataObjectTypes参数由getSupportedOutputCapability接口获取,因此旧接口function createMetadataOutput(callback: AsyncCallback<MetadataOutput>): void;以及function createMetadataOutput(): Promise<MetadataOutput>;变更为createMetadataOutput(metadataObjectTypes: Array<MetadataObjectType>, callback: AsyncCallback<MetadataOutput>): void;和createMetadataOutput(metadataObjectTypes: Array<MetadataObjectType>): Promise<MetadataOutput>; 597 598 参考代码如下: 599 600 ``` 601 let metadataObjectTypes = cameraoutputcapability.supportedMetadataObjectTypes; 602 cameraManager.createMetadataOutput(metadataObjectTypes, (err, metadataOutput) => { 603 if (err) { 604 console.error(`Failed to create metadataOutput. ${err.message}`); 605 return; 606 } 607 console.log('Callback returned with metadataOutput created.'); 608 }) 609 ``` 610 611 ``` 612 let metadataObjectTypes = cameraoutputcapability.supportedMetadataObjectTypes; 613 cameraManager.createMetadataOutput(metadataObjectTypes).then((metadataOutput) => { 614 console.log('Promise returned with metadataOutput created.'); 615 }) 616 ``` 617 6187. CameraManager中createCaptureSession不需要考虑context属性,因此旧接口createCaptureSession(context: Context, callback: AsyncCallback<CaptureSession>): void;以及createCaptureSession(context: Context): Promise<CaptureSession>;改为createCaptureSession(callback: AsyncCallback<CaptureSession>): void;和createCaptureSession(): Promise<CaptureSession>; 619 620 参考代码如下: 621 622 ```typescript 623 cameraManager.createCaptureSession((err, captureSession) => { 624 if (err) { 625 console.error(`Failed to create captureSession. ${err.message}`); 626 return; 627 } 628 console.log('Callback returned with captureSession created.'); 629 }) 630 ``` 631 632 ``` 633 cameraManager.createCaptureSession().then((captureSession) => { 634 console.log('Promise returned with captureSession created.'); 635 }) 636 ``` 637 6388. CameraStatusInfo接口下属性camera类型由Camera变更为CameraDevice 639 6409. CameraInput中接口on(type: 'error')新增传递参数camera: CameraDevice,因此旧接口on(type: 'error', callback: ErrorCallback<CameraInputError>): void;变更为on(type: 'error', camera: CameraDevice, callback: ErrorCallback<CameraInputError>): void; 641 642 参考代码如下: 643 644 ``` 645 let cameraDevice = cameras[0]; 646 cameraInput.on('error', cameraDevice, (cameraInputError) => { 647 console.log(`Camera input error code: ${cameraInputError.code}`); 648 }) 649 ``` 650 65110. CameraInput中以下接口调整到CaptureSession中 652 653 hasFlash(callback: AsyncCallback<boolean>): void;<br/>hasFlash(): Promise<boolean>;<br/> 654 655 isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback<boolean>): void;<br/>isFlashModeSupported(flashMode: FlashMode): Promise<boolean>;<br/> 656 657 getFlashMode(callback: AsyncCallback<FlashMode>): void;<br/>getFlashMode(): Promise<FlashMode>;<br/> 658 659 setFlashMode(flashMode: FlashMode, callback: AsyncCallback<void>): void;<br/>setFlashMode(flashMode: FlashMode): Promise<void>;<br/> 660 661 isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback<boolean>): void;<br/>isExposureModeSupported(aeMode: ExposureMode): Promise<boolean>;<br/> 662 663 getExposureMode(callback: AsyncCallback<ExposureMode>): void;<br/>getExposureMode(): Promise<ExposureMode>;<br/> 664 665 setExposureMode(aeMode: ExposureMode, callback: AsyncCallback<void>): void;<br/>setExposureMode(aeMode: ExposureMode): Promise<void>;<br/> 666 667 getMeteringPoint(callback: AsyncCallback<Point>): void;<br/>getMeteringPoint(): Promise<Point>;<br/> 668 669 setMeteringPoint(point: Point, callback: AsyncCallback<void>): void;<br/>setMeteringPoint(point: Point): Promise<void>;<br/> 670 671 getExposureBiasRange(callback: AsyncCallback<Array<number>>): void;<br/>getExposureBiasRange(): Promise<Array<number>>;<br/> 672 673 setExposureBias(exposureBias: number, callback: AsyncCallback<void>): void;<br/>setExposureBias(exposureBias: number): Promise<void>;<br/> 674 675 getExposureValue(callback: AsyncCallback<number>): void;<br/>getExposureValue(): Promise<number>;<br/> 676 677 isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback<boolean>): void;<br/>isFocusModeSupported(afMode: FocusMode): Promise<boolean>;<br/> 678 679 getFocusMode(callback: AsyncCallback<FocusMode>): void;<br/>getFocusMode(): Promise<FocusMode>;<br/> 680 681 setFocusMode(afMode: FocusMode, callback: AsyncCallback<void>): void;<br/>setFocusMode(afMode: FocusMode): Promise<void>;<br/> 682 683 setFocusPoint(point: Point, callback: AsyncCallback<void>): void;<br/>setFocusPoint(point: Point): Promise<void>;<br/> 684 685 getFocusPoint(callback: AsyncCallback<Point>): void;<br/>getFocusPoint(): Promise<Point>;<br/> 686 687 getFocalLength(callback: AsyncCallback<number>): void;<br/>getFocalLength(): Promise<number>;<br/> 688 689 getZoomRatioRange(callback: AsyncCallback<Array<number>>): void;<br/>getZoomRatioRange(): Promise<Array<number>>;<br/> 690 691 getZoomRatio(callback: AsyncCallback<number>): void;<br/>getZoomRatio(): Promise<number>;<br/> 692 693 setZoomRatio(zoomRatio: number, callback: AsyncCallback<void>): void;<br/>setZoomRatio(zoomRatio: number): Promise<void>; 694 69511. CameraInput中接口on(type: 'focusStateChange', callback: AsyncCallback<FocusState>): void;调整到CaptureSession中,对应接口on(type: 'focusStateChange', callback: AsyncCallback<FocusState>): void; 696 697 参考代码如下: 698 699 ``` 700 captureSession.on('focusStateChange', (focusState) => { 701 console.log(`Focus state : ${focusState}`); 702 }) 703 ``` 704 70512. 枚举ExposureMode中 706 707 枚举值名称:EXPOSURE_MODE_AUTO,初值由默认变更为1; 708 709 枚举值名称:EXPOSURE_MODE_CONTINUOUS_AUTO,初值由默认变更为2; 710 71113. 枚举VideoStabilizationMode中 712 713 枚举值名称:LOW,初值由默认变更为1; 714 715 枚举值名称:MIDDLE,初值由默认变更为2; 716 717 枚举值名称:HIGH,初值由默认变更为3; 718 719 枚举值名称:AUTO,初值由默认变更为4; 720 72114. CaptureSession中接口addOutput参数由原来子类类型(PreviewOutput,PhotoOutput,VideoOutput,MetadataOutput)统一修改为基类类型(CameraOutput),变更后由原来8个接口缩减为2个接口。 722 723 改变前接口为: 724 725 addOutput(previewOutput: PreviewOutput, callback: AsyncCallback<void>): void;<br/>addOutput(previewOutput: PreviewOutput): Promise<void>;<br/>addOutput(photoOutput: PhotoOutput, callback: AsyncCallback<void>): void;<br/>addOutput(photoOutput: PhotoOutput): Promise<void>;<br/>addOutput(videoOutput: VideoOutput, callback: AsyncCallback<void>): void;<br/>addOutput(videoOutput: VideoOutput): Promise<void>;<br/>addOutput(metadataOutput: MetadataOutput, callback: AsyncCallback<void>): void;<br/>addOutput(metadataOutput: MetadataOutput): Promise<void>; 726 727 改变后接口为: 728 729 addOutput(cameraOutput: CameraOutput, callback: AsyncCallback<void>): void;<br/>addOutput(cameraOutput: CameraOutput): Promise<void>; 730 731 参考代码如下:以PreviewOutput为例 732 733 ``` 734 captureSession.addOutput(previewOutput, (err) => { 735 if (err) { 736 console.error(`Failed to add output. ${err.message}`); 737 return; 738 } 739 console.log('Callback returned with output added.'); 740 }) 741 ``` 742 743 ``` 744 captureSession.addOutput(previewOutput).then(() => { 745 console.log('Promise returned with cameraOutput added.'); 746 }) 747 ``` 748 74915. CaptureSession中接口removeOutput参数由原来子类类型(PreviewOutput,PhotoOutput,VideoOutput,MetadataOutput)统一修改为基类类型(CameraOutput),变更后由原来8个接口缩减为2个接口。 750 751 改变前接口为: 752 753 removeOutput(previewOutput: PreviewOutput, callback: AsyncCallback<void>): void;<br/>removeOutput(previewOutput: PreviewOutput): Promise<void>;<br/>removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback<void>): void;<br/>removeOutput(photoOutput: PhotoOutput): Promise<void>;<br/>removeOutput(videoOutput: VideoOutput, callback: AsyncCallback<void>): void;<br/>removeOutput(videoOutput: VideoOutput): Promise<void>;<br/>removeOutput(metadataOutput: MetadataOutput, callback: AsyncCallback<void>): void;<br/>removeOutput(metadataOutput: MetadataOutput): Promise<void>; 754 755 改变后接口为: 756 757 removeOutput(cameraOutput: CameraOutput, callback: AsyncCallback<void>): void;<br/>removeOutput(cameraOutput: CameraOutput): Promise<void>; 758 759 参考代码如下:以PreviewOutput为例 760 761 ``` 762 captureSession.removeOutput(previewOutput, (err) => { 763 if (err) { 764 console.error(`Failed to remove the CameraOutput instance. ${err.message}`); 765 return; 766 } 767 console.log('Callback invoked to indicate that the CameraOutput instance is removed.'); 768 }); 769 ``` 770 771 ``` 772 captureSession.removeOutput(previewOutput).then(() => { 773 console.log('Promise returned to indicate that the CameraOutput instance is removed.'); 774 }) 775 ``` 776 77716. 枚举MetadataObjectType中 778 779 枚举值名称由FACE变更为FACE_DETECTION; 780 78117. 接口Camera名称更改为CameraDevice 782