1# @ohos.multimedia.camera (Camera Management) (System API) 2 3The camera module provides a set of camera service APIs for you to easily develop a camera application. The application can access and operate the camera hardware to implement basic operations, such as preview, taking photos, and recording videos. It can also perform more operations, for example, controlling the flash and exposure time, and focusing or adjusting the focus. 4 5> **NOTE** 6> 7> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> - This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.multimedia.camera (Camera Management)](js-apis-camera.md). 9 10## Modules to Import 11 12```ts 13import { camera } from '@kit.CameraKit'; 14``` 15 16## CameraDevice 17 18Defines the camera device information. 19 20**System capability**: SystemCapability.Multimedia.Camera.Core 21 22| Name | Type | Read-only| Mandatory| Description | 23| -------------- | --------------------------------- | ---- | ---- |---------- | 24| hostDeviceName | string | Yes | Yes | Name of the remote device. **System API**: This is a system API.| 25| hostDeviceType | [HostDeviceType](#hostdevicetype) | Yes | Yes | Type of the remote device. **System API**: This is a system API.| 26 27## HostDeviceType 28 29Enumerates the remote camera types. 30 31**System API**: This is a system API. 32 33**System capability**: SystemCapability.Multimedia.Camera.Core 34 35| Name | Value | Description | 36| ---------------------------- | ---- | ------------- | 37| UNKNOWN_TYPE | 0 | Unknown type. | 38| PHONE | 0x0E | Phone camera.| 39| TABLET | 0x11 | Tablet camera.| 40 41## SceneMode<sup>11+</sup> 42 43Enumerates the camera scene modes. 44 45**System capability**: SystemCapability.Multimedia.Camera.Core 46 47| Name | Value | Description | 48| ----------------------- | --------- | ------------ | 49| PORTRAIT_PHOTO | 3 | Portrait photo mode. **System API**: This is a system API. | 50| NIGHT_PHOTO | 4 | Night photo mode. **System API**: This is a system API. | 51| PROFESSIONAL_PHOTO<sup>12+</sup> | 5 | Professional photo mode. **System API**: This is a system API. | 52| PROFESSIONAL_VIDEO<sup>12+</sup> | 6 | Professional video mode. **System API**: This is a system API. | 53| SLOW_MOTION_VIDEO<sup>12+</sup> | 7 | Slow-motion video mode. **System API**: This is a system API. | 54| HIGH_RESOLUTION_PHOTO<sup>12+</sup> | 11 | High-resolution photo mode. **System API**: This is a system API. | 55| PANORAMA_PHOTO<sup>12+</sup> | 15 | Panoramic photo mode. **System API**: This is a system API. | 56| TIME_LAPSE_PHOTO<sup>12+</sup> | 16 | Time-lapse photo mode. **System API**: This is a system API. | 57 58## SlowMotionStatus<sup>12+</sup> 59 60Enumerates the slow-motion states. 61 62**System capability**: SystemCapability.Multimedia.Camera.Core 63 64| Name | Value | Description | 65|----------------|-----|---------------| 66| DISABLED | 0 | Disabled. | 67| READY | 1 | Ready. | 68| VIDEO_START | 2 | Video start. | 69| VIDEO_DONE | 3 | Video complete. | 70| FINISHED | 4 | Finished. | 71 72## LcdFlashStatus<sup>12+</sup> 73 74Describes the LCD flash information. 75 76**System API**: This is a system API. 77 78**System capability**: SystemCapability.Multimedia.Camera.Core 79 80| Name | Type | Read-only| Optional | Description | 81| -------- | ----------------------------- |---- |-----| ------------- | 82| isLcdFlashNeeded | boolean | Yes | No | Whether the LCD flash is required. | 83| lcdCompensation | number | Yes | No | LCD flash compensation. | 84 85## Photo<sup>11+</sup> 86 87Defines a higher-resolution image object. 88 89**System API**: This is a system API. 90 91**System capability**: SystemCapability.Multimedia.Camera.Core 92 93| Name | Type | Read-only | Optional | Description| 94| ------ | ----------------------------- |-----| ---------- | ---------- | 95| raw<sup>12+</sup> | [image.Image](../apis-image-kit/js-apis-image.md#image9)| NA | Yes | Raw image.| 96 97## ExposureMode 98 99Enumerates the exposure modes. 100 101**System API**: This is a system API. 102 103**System capability**: SystemCapability.Multimedia.Camera.Core 104 105| Name | Value | Description | 106| ----------------------------- |-----|---------| 107| EXPOSURE_MODE_MANUAL<sup>12+</sup> | 3 | Manual exposure mode.| 108 109## PolicyType<sup>12+</sup> 110 111Enumerates the policy types. 112 113**System API**: This is a system API. 114 115**System capability**: SystemCapability.Multimedia.Camera.Core 116 117| Name | Value | Description | 118| ----------------------------- |-----|---------| 119| PRIVACY<sup>12+</sup> | 1 | Privacy.| 120 121## LightPaintingType<sup>12+</sup> 122 123Enumerates the types of light painting shutter modes. 124 125**System API**: This is a system API. 126 127**System capability**: SystemCapability.Multimedia.Camera.Core 128 129| Name | Value | Description | 130| ----------------------------- |-----|---------| 131| TRAFFIC_TRAILS | 0 | Traffic trails.| 132| STAR_TRAILS | 1 | Star trails.| 133| SILKY_WATER | 2 | Silky water.| 134| LIGHT_GRAFFITI | 3 | Light graffiti.| 135 136## CameraManager 137 138Implements camera management. Before calling any API in **CameraManager**, you must use [getCameraManager](js-apis-camera.md#cameragetcameramanager) to obtain a **CameraManager** instance. 139 140### createDepthDataOutput<sup>12+</sup> 141 142createDepthDataOutput(profile: Profile): DepthDataOutput 143 144Creates a **DepthDataOutput** instance. This API returns the result synchronously. 145 146**System API**: This is a system API. 147 148**System capability**: SystemCapability.Multimedia.Camera.Core 149 150**Parameters** 151 152| Name | Type | Mandatory| Description | 153| -------- | ----------------------------------------------- | ---- | ------------------------------- | 154| profile | [Profile](js-apis-camera.md#profile) | Yes | Supported preview profile, which is obtained through [getSupportedOutputCapability](js-apis-camera.md#getsupportedoutputcapability11).| 155 156**Return value** 157 158| Type | Description | 159| ---------- | ----------------------------- | 160| [DepthDataOutput](#depthdataoutput12) | **DepthDataOutput** instance. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 161 162**Error codes** 163 164For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 165 166| ID | Error Message | 167| --------------- | --------------- | 168| 7400101 | Parameter missing or parameter type incorrect. | 169| 7400201 | Camera service fatal error. | 170 171**Example** 172 173```ts 174import { BusinessError } from '@kit.BasicServicesKit'; 175 176function createDepthDataOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager): camera.DepthDataOutput | undefined { 177 let profile: camera.Profile = cameraOutputCapability.depthProfiles[0]; 178 let depthDataOutput: camera.DepthDataOutput | undefined = undefined; 179 try { 180 depthDataOutput = cameraManager.createDepthDataOutput(profile); 181 } catch (error) { 182 // If the operation fails, error.code is returned and processed. 183 let err = error as BusinessError; 184 console.error(`The createDepthDataOutput call failed. error code: ${err.code}`); 185 } 186 return depthDataOutput; 187} 188``` 189 190### isCameraMuteSupported 191 192isCameraMuteSupported(): boolean 193 194Checks whether the camera device can be muted. 195 196**System API**: This is a system API. 197 198**System capability**: SystemCapability.Multimedia.Camera.Core 199 200**Return value** 201 202| Type | Description | 203| ---------- | ----------------------------- | 204| boolean | **true**: The camera device can be muted.<br>**false**: The camera device cannot be muted.| 205 206**Example** 207 208```ts 209function isCameraMuteSupported(cameraManager: camera.CameraManager): boolean { 210 let isMuteSupported: boolean = cameraManager.isCameraMuteSupported(); 211 return isMuteSupported; 212} 213``` 214 215### muteCamera 216 217muteCamera(mute: boolean): void 218 219Mutes or unmutes the camera device. 220 221> **NOTE** 222> 223> This API is supported since API version 10 and deprecated since API version 12. You are advised to use [muteCameraPersistent](#mutecamerapersistent12) instead. 224 225**System API**: This is a system API. 226 227**System capability**: SystemCapability.Multimedia.Camera.Core 228 229**Parameters** 230 231| Name | Type | Mandatory | Description | 232| -------- | --------------------------------- | ---- | ---------- | 233| mute | boolean | Yes | Whether to mute the camera device. The value **true** means to mute the camera device, and **false** means the opposite. | 234 235**Example** 236 237```ts 238function muteCamera(cameraManager: camera.CameraManager): void { 239 let mute: boolean = true; 240 cameraManager.muteCamera(mute); 241} 242``` 243 244### muteCameraPersistent<sup>12+</sup> 245 246muteCameraPersistent(mute: boolean, type: PolicyType): void 247 248Disables the camera in a persistent manner. 249 250**System API**: This is a system API. 251 252**System capability**: SystemCapability.Multimedia.Camera.Core 253 254**Parameters** 255 256| Name | Type | Mandatory | Description | 257| -------- |-----------------------------| ---- |--------------------------------------------| 258| mute | boolean | Yes | Whether to mute the camera device. The value **true** means to mute the camera device, and **false** means the opposite. | 259| type | [PolicyType](#policytype12) | Yes | Policy type. For details about the available options, see [PolicyType](#policytype12).| 260 261**Example** 262 263```ts 264function muteCameraPersistent(cameraManager: camera.CameraManager): void { 265 let mute: boolean = true; 266 cameraManager.muteCameraPersistent(mute, camera.PolicyType.PRIVACY); 267} 268``` 269 270### on('cameraMute') 271 272on(type: 'cameraMute', callback: AsyncCallback\<boolean\>): void 273 274Subscribes to camera mute status events. This API uses an asynchronous callback to return the result. 275 276**System API**: This is a system API. 277 278**System capability**: SystemCapability.Multimedia.Camera.Core 279 280**Parameters** 281 282| Name | Type | Mandatory| Description | 283| -------- | --------------- | ---- | --------- | 284| type | string | Yes | Event type. The value is fixed at **'cameraMute'**, indicating the camera mute status. The event can be listened for when a **CameraManager** instance is obtained. This event is triggered and the status is returned when the camera device is muted or unmuted.| 285| callback | AsyncCallback\<boolean> | Yes | Callback used to return the mute status. The value **true** means that the camera is enabled, and **false** means that the camera is disabled. | 286 287**Example** 288 289```ts 290import { BusinessError } from '@kit.BasicServicesKit'; 291 292function callback(err: BusinessError, curMuted: boolean): void { 293 if (err !== undefined && err.code !== 0) { 294 console.error(`Callback Error, errorCode: ${err.code}`); 295 return; 296 } 297 let isMuted: boolean = curMuted; 298 console.info(`cameraMute status: ${isMuted}`); 299} 300 301function registerCameraMute(cameraManager: camera.CameraManager): void { 302 cameraManager.on('cameraMute', callback); 303} 304``` 305 306### off('cameraMute') 307 308off(type: 'cameraMute', callback?: AsyncCallback\<boolean\>): void 309 310Unsubscribes from camera mute status events. 311 312**System API**: This is a system API. 313 314**System capability**: SystemCapability.Multimedia.Camera.Core 315 316**Parameters** 317 318| Name | Type | Mandatory| Description | 319| -------- | --------------- | ---- |---------------------------------------------------------| 320| type | string | Yes | Event type. The value is fixed at **'cameraMute'**, indicating the camera mute status. The event can be listened for when a **CameraManager** instance is obtained.| 321| callback | AsyncCallback\<boolean> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('cameraMute')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 322 323**Example** 324 325```ts 326import { BusinessError } from '@kit.BasicServicesKit'; 327 328function callback(err: BusinessError, curMuted: boolean): void { 329 let isMuted: boolean = curMuted; 330} 331 332function unregisterCameraMute(cameraManager: camera.CameraManager): void { 333 cameraManager.off('cameraMute', callback); 334} 335``` 336 337### isPrelaunchSupported 338 339isPrelaunchSupported(camera: CameraDevice): boolean 340 341Checks whether a camera device supports prelaunch. 342 343**System API**: This is a system API. 344 345**System capability**: SystemCapability.Multimedia.Camera.Core 346 347**Parameters** 348 349| Name | Type | Mandatory| Description | 350| -------- | --------------- | ---- | --------- | 351| camera | [CameraDevice](#cameradevice) | Yes| Camera device.| 352 353**Return value** 354 355| Type| Description| 356| -------- | --------------- | 357| boolean | **true**: The camera device supports prelaunch.<br>**false**: The camera device does not support prelaunch.| 358 359**Error codes** 360 361For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 362 363| ID | Error Message | 364| --------------- | --------------- | 365| 202 | Not System Application. | 366| 7400101 | Parameter missing or parameter type incorrect. | 367 368**Example** 369 370```ts 371import { common } from '@kit.AbilityKit'; 372 373function isPreLaunchSupported(context: common.BaseContext): boolean { 374 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 375 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 376 let isSupported: boolean = false; 377 if (cameras && cameras.length >= 1) { 378 isSupported = cameraManager.isPrelaunchSupported(cameras[0]); 379 console.info(`PreLaunch supported states: ${isSupported}`); 380 return isSupported; 381 } 382 return isSupported; 383} 384``` 385 386### setPrelaunchConfig 387 388setPrelaunchConfig(prelaunchConfig: PrelaunchConfig): void 389 390Sets prelaunch configuration. 391 392Before the setting, call [isPrelaunchSupported](#isprelaunchsupported) to check whether the camera device supports prelaunch. 393 394**System API**: This is a system API. 395 396**Required permissions**: ohos.permission.CAMERA 397 398**System capability**: SystemCapability.Multimedia.Camera.Core 399 400**Parameters** 401 402| Name | Type | Mandatory| Description | 403| -------- | --------------- | ---- | --------- | 404| prelaunchConfig | [PrelaunchConfig](#prelaunchconfig) | Yes| Prelaunch configuration.| 405 406**Error codes** 407 408For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 409 410| ID | Error Message | 411| --------------- | --------------- | 412| 202 | Not System Application. | 413| 7400101 | Parameter missing or parameter type incorrect. | 414| 7400102 | Operation not allowed. | 415| 7400201 | Camera service fatal error. | 416 417**Example** 418 419```ts 420import { common } from '@kit.AbilityKit'; 421import { BusinessError } from '@kit.BasicServicesKit'; 422 423function setPrelaunchConfig(context: common.BaseContext): void { 424 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 425 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 426 if (cameras && cameras.length >= 1) { 427 let cameraDevice: camera.CameraDevice = cameras[0]; 428 if(cameraManager.isPrelaunchSupported(cameraDevice)) { 429 try { 430 cameraManager.setPrelaunchConfig({cameraDevice: cameraDevice}); 431 } catch (error) { 432 let err = error as BusinessError; 433 console.error(`setPrelaunchConfig error. Code: ${err.code}, message: ${err.message}`); 434 } 435 } 436 } 437} 438``` 439 440### prelaunch 441 442prelaunch(): void 443 444Prelaunches the camera device. This API is called when a user clicks the system camera icon to start the camera application. 445 446**System API**: This is a system API. 447 448**System capability**: SystemCapability.Multimedia.Camera.Core 449 450**Example** 451 452```ts 453import { common } from '@kit.AbilityKit'; 454import { BusinessError } from '@kit.BasicServicesKit'; 455 456function preLaunch(context: common.BaseContext): void { 457 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 458 try { 459 cameraManager.prelaunch(); 460 } catch (error) { 461 let err = error as BusinessError; 462 console.error(`prelaunch error. Code: ${err.code}, message: ${err.message}`); 463 } 464} 465``` 466 467### createDeferredPreviewOutput 468 469createDeferredPreviewOutput(profile: Profile): PreviewOutput 470 471Creates a deferred **PreviewOutput** instance and adds it, instead of a common **PreviewOutput** instance, to the data stream during stream configuration. 472 473**System API**: This is a system API. 474 475**System capability**: SystemCapability.Multimedia.Camera.Core 476 477**Parameters** 478 479| Name | Type | Mandatory| Description | 480| -------- | --------------- | ---- | --------- | 481| profile | [Profile](js-apis-camera.md#profile) | Yes| Configuration file of the camera preview stream.| 482 483**Return value** 484 485| Type| Description| 486| -------- | --------------- | 487| [PreviewOutput](#previewoutput) | **PreviewOutput** instance obtained.| 488 489**Error codes** 490 491For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 492 493| ID | Error Message | 494| --------------- | --------------- | 495| 202 | Not System Application. | 496| 7400101 | Parameter missing or parameter type incorrect. | 497 498**Example** 499 500```ts 501import { common } from '@kit.AbilityKit'; 502 503function getDeferredPreviewOutput(context: common.BaseContext, previewProfile: camera.Profile): camera.PreviewOutput { 504 const cameraManager: camera.CameraManager = camera.getCameraManager(context); 505 const output: camera.PreviewOutput = cameraManager.createDeferredPreviewOutput(previewProfile); 506 return output; 507} 508``` 509 510### preSwitchCamera<sup>11+</sup> 511 512preSwitchCamera(cameraId: string): void 513 514Pre-switches a camera device to speed up its startup. 515 516**System API**: This is a system API. 517 518**System capability**: SystemCapability.Multimedia.Camera.Core 519 520**Parameters** 521 522| Name | Type | Mandatory| Description | 523| -------- | --------------- | ---- | --------- | 524| cameraId | string | Yes| Camera ID.| 525 526**Error codes** 527 528For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 529 530| ID | Error Message | 531| ------- |------------------------------------------------| 532| 202 | Not System Application. | 533| 7400101 | Parameter missing or parameter type incorrect. | 534| 7400201 | Camera service fatal error. | 535 536**Example** 537 538```ts 539import { common } from '@kit.AbilityKit'; 540import { BusinessError } from '@kit.BasicServicesKit'; 541 542function preSwitch(cameraDevice: camera.CameraDevice, context: common.BaseContext): void { 543 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 544 try { 545 cameraManager.preSwitchCamera(cameraDevice.cameraId); 546 } catch (error) { 547 let err = error as BusinessError; 548 console.error(`prelaunch error. Code: ${err.code}, message: ${err.message}`); 549 } 550} 551``` 552 553## CameraOcclusionDetectionResult<sup>12+</sup> 554Describes the status indicating whether the camera is occluded. 555 556**System API**: This is a system API. 557 558**System capability**: SystemCapability.Multimedia.Camera.Core 559 560| Name | Type | Read-only| Optional| Description | 561| ----------------------------- | --------------------------------------------------- | ---- | ---- |-------------------| 562| isCameraOccluded | boolean | Yes | No|Whether the camera is occluded. | 563 564## CameraOutputCapability<sup>12+</sup> 565 566Describes the camera output capability. 567 568**System API**: This is a system API. 569 570**System capability**: SystemCapability.Multimedia.Camera.Core 571 572| Name | Type | Read-only| Optional| Description | 573| ----------------------------- | --------------------------------------------------- | ---- | ---- |-------------------| 574| depthProfiles | Array\<[DepthProfile](#depthprofile12)\> | Yes | No| Supported depth stream profiles. | 575 576## CameraFormat 577 578Enumerates the camera output formats. 579 580**System API**: This is a system API. 581 582**System capability**: SystemCapability.Multimedia.Camera.Core 583 584| Name | Value | Description | 585| ----------------------- | --------- | ------------ | 586| CAMERA_FORMAT_DEPTH_16<sup>12+</sup> | 3000 | Depth map in DEPTH_16 format. | 587| CAMERA_FORMAT_DEPTH_32<sup>12+</sup> | 3001 | Depth map in DEPTH_32 format. | 588 589## CameraInput 590 591Defines the camera input object. 592 593It provides camera device information used in [Session](js-apis-camera.md#session11). 594 595### on('cameraOcclusionDetection')<sup>12+</sup> 596 597on(type: 'cameraOcclusionDetection', callback: AsyncCallback\<CameraOcclusionDetectionResult\>): void 598 599Subscribes to CameraInput occlusion events. This API uses an asynchronous callback to return the result. 600 601**System capability**: SystemCapability.Multimedia.Camera.Core 602 603**Parameters** 604 605| Name | Type | Mandatory| Description | 606| -------- | -------------------------------- | --- | ------------------------------------------- | 607| type | string | Yes | Event type. The value is fixed at **'cameraOcclusionDetection'**. The event can be listened for when a **CameraInput** instance is created. It is triggered when the occlusion status of the camera module changes, and the occlusion status is returned.| 608| callback | AsyncCallback\<[CameraOcclusionDetectionResult](#cameraocclusiondetectionresult12)\> | Yes | Callback used to return the occlusion status. | 609 610**Example** 611 612```ts 613import { BusinessError } from '@kit.BasicServicesKit'; 614 615function callback(err: BusinessError, CameraOcclusionDetectionResult: camera.CameraOcclusionDetectionResult): void { 616 if (err !== undefined && err.code !== 0) { 617 console.error('cameraOcclusionDetection with errorCode = ' + err.code); 618 return; 619 } 620 console.info(`isCameraOccluded : ${CameraOcclusionDetectionResult.isCameraOccluded}`); 621} 622 623function registerCameraOcclusionDetection(cameraInput: camera.CameraInput): void { 624 cameraInput.on('cameraOcclusionDetection', callback); 625} 626``` 627 628### off('cameraOcclusionDetection')<sup>12+</sup> 629 630off(type: 'cameraOcclusionDetection', callback?: AsyncCallback\<CameraOcclusionDetectionResult\>): void 631 632Unsubscribes from CameraInput occlusion events. 633 634**System capability**: SystemCapability.Multimedia.Camera.Core 635 636**Parameters** 637 638| Name | Type | Mandatory| Description | 639| -------- | --------------- | ---- |---------------------------------------------------------| 640| type | string | Yes | Event type. The value is fixed at **'cameraOcclusionDetection'**. The event can be listened for when a **CameraInput** instance is created.| 641| callback | AsyncCallback\<[CameraOcclusionDetectionResult](#cameraocclusiondetectionresult12)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('cameraOcclusionDetection')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 642 643**Example** 644 645```ts 646import { BusinessError } from '@kit.BasicServicesKit'; 647 648function callback(err: BusinessError, CameraOcclusionDetectionResult: camera.CameraOcclusionDetectionResult): void { 649 if (err !== undefined && err.code !== 0) { 650 console.error('cameraOcclusionDetection with errorCode = ' + err.code); 651 return; 652 } 653 console.info(`isCameraOccluded : ${CameraOcclusionDetectionResult.isCameraOccluded}`); 654} 655 656function unregisterCameraOcclusionDetection(cameraInput: camera.CameraInput): void { 657 cameraInput.off('cameraOcclusionDetection', callback); 658} 659``` 660 661## DepthDataAccuracy<sup>12+</sup> 662 663Describes the accuracy of depth data. 664 665**System API**: This is a system API. 666 667**System capability**: SystemCapability.Multimedia.Camera.Core 668 669| Name | Type | Read-only| Optional| Description | 670| -------- | ----------------------------- |----- |---| -------------- | 671| DEPTH_DATA_ACCURACY_RELATIVE | number | Yes | No| Relative accuracy, which is the depth map calculated based on the disparity. | 672| DEPTH_DATA_ACCURACY_ABSOLUTE | number | Yes | No| Absolute accuracy, which is the depth map calculated from distance measurement. | 673 674## DepthProfile<sup>12+</sup> 675 676Describes the profile of depth data. It inherits from [Profile](js-apis-camera.md#profile). 677 678**System API**: This is a system API. 679 680**System capability**: SystemCapability.Multimedia.Camera.Core 681 682| Name | Type | Read-only| Optional| Description | 683| ------------------------- | ----------------------------------------- | --- | ---- |----------- | 684| depthDataAccuracy | [DepthDataAccuracy](#depthdataaccuracy12) | Yes | No | Accuracy of the depth data, which can be either relative accuracy or absolute accuracy.| 685 686## DepthDataQualityLevel<sup>12+</sup> 687 688Enumerates the quality levels of depth data. 689 690**System API**: This is a system API. 691 692**System capability**: SystemCapability.Multimedia.Camera.Core 693 694| Name | Type | Read-only| Optional| Description | 695| -------- | ----------------------------- |----- |---| -------------- | 696| DEPTH_DATA_QUALITY_BAD | number | Yes | No| The depth map is of poor quality and cannot be used for blurring. | 697| DEPTH_DATA_QUALITY_FAIR | number | Yes | No| The depth map is of average quality and cannot be used for high-quality blurring. | 698| DEPTH_DATA_QUALITY_GOOD | number | Yes | No| The depth map is of high quality and can be used for high-quality blurring. | 699 700## DepthData<sup>12+</sup> 701 702Describes a depth data object. 703 704### Properties 705 706**System API**: This is a system API. 707 708**System capability**: SystemCapability.Multimedia.Camera.Core 709 710| Name | Type | Read-only| Optional| Description | 711| -------- | ----------------------------- |----- |---| -------------- | 712| format | [CameraFormat](#cameraformat) | Yes| No | Camera output format.| 713| depthMap | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | Yes| No | Depth map.| 714| qualityLevel | [DepthDataQualityLevel](#depthdataqualitylevel12) | Yes| No | Quality level of the depth map.| 715| accuracy | [DepthDataAccuracy](#depthdataaccuracy12) | Yes| No | Accuracy of the depth map.| 716 717### release<sup>12+</sup> 718 719release(): void 720 721Releases depth data output resources. 722 723**System API**: This is a system API. 724 725**System capability**: SystemCapability.Multimedia.Camera.Core 726 727**Example** 728 729```ts 730function releaseDepthData(depthData: camera.DepthData): void { 731 await depthData.release(); 732} 733``` 734 735## DepthDataOutput<sup>12+</sup> 736 737Implements depth data output. It inherits from [CameraOutput](js-apis-camera.md#cameraoutput). 738 739### start<sup>12+</sup> 740 741start(): Promise\<void\> 742 743Starts a depth data output stream. This API uses a promise to return the result. 744 745**System API**: This is a system API. 746 747**System capability**: SystemCapability.Multimedia.Camera.Core 748 749**Return value** 750 751| Type | Description | 752| -------------- | ----------------------- | 753| Promise\<void\> | Promise that returns no value.| 754 755**Error codes** 756 757For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 758 759| ID | Error Message | 760| --------------- | --------------- | 761| 7400103 | Session not config. | 762| 7400201 | Camera service fatal error. | 763 764**Example** 765 766```ts 767import { BusinessError } from '@kit.BasicServicesKit'; 768 769function startDepthDataOutput(depthDataOutput: camera.DepthDataOutput): void { 770 depthDataOutput.start().then(() => { 771 console.info('Promise returned to indicate that start method execution success.'); 772 }).catch((error: BusinessError) => { 773 console.error(`Failed to depth data output start, error code: ${error.code}.`); 774 }); 775} 776``` 777 778### stop<sup>12+</sup> 779 780stop(): Promise\<void\> 781 782Stops a depth data output stream. This API uses a promise to return the result. 783 784**System API**: This is a system API. 785 786**System capability**: SystemCapability.Multimedia.Camera.Core 787 788**Return value** 789 790| Type | Description | 791| -------------- | ----------------------- | 792| Promise\<void\> | Promise that returns no value.| 793 794**Example** 795 796```ts 797import { BusinessError } from '@kit.BasicServicesKit'; 798 799function stopDepthDataOutput(depthDataOutput: camera.DepthDataOutput): void { 800 depthDataOutput.stop().then(() => { 801 console.info('Promise returned to indicate that stop method execution success.'); 802 }).catch((error: BusinessError) => { 803 console.error(`Failed to depth data output stop, error code: ${error.code}.`); 804 }); 805} 806``` 807 808### on('depthDataAvailable')<sup>12+</sup> 809 810on(type: 'depthDataAvailable', callback: AsyncCallback\<DepthData\>): void 811 812Subscribes to depth data availability events. This API uses an asynchronous callback to return the result. 813 814> **NOTE** 815> 816> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**. 817 818**System API**: This is a system API. 819 820**System capability**: SystemCapability.Multimedia.Camera.Core 821 822**Parameters** 823 824| Name | Type | Mandatory| Description | 825| -------- | ---------- | --- | ------------------------------------ | 826| type | string | Yes | Event type. The value is fixed at **'depthDataAvailable'**. The event can be listened for when a **depthDataOutput** instance is created.| 827| callback | AsyncCallback\<[DepthData](#depthdata12)\> | Yes | Callback used to listen for depth data.| 828 829**Example** 830 831```ts 832import { BusinessError } from '@kit.BasicServicesKit'; 833 834function callback(err: BusinessError, depthData: camera.DepthData): void { 835 if (err !== undefined && err.code !== 0) { 836 console.error(`Callback Error, errorCode: ${err.code}`); 837 return; 838 } 839} 840 841function registerDepthDataAvailable(depthDataOutput: camera.DepthDataOutput): void { 842 depthDataOutput.on('depthDataAvailable', callback); 843} 844``` 845 846### off('depthDataAvailable')<sup>12+</sup> 847 848off(type: 'depthDataAvailable', callback?: AsyncCallback\<DepthData\>): void 849 850Unsubscribes from depth data availability events. 851 852**System API**: This is a system API. 853 854**System capability**: SystemCapability.Multimedia.Camera.Core 855 856**Parameters** 857 858| Name | Type | Mandatory| Description | 859| -------- | ---------------------- | ---- | ------------------------------------------ | 860| type | string | Yes | Event type. The value is fixed at **'depthDataAvailable'**. The event can be listened for when a **depthDataOutput** instance is created.| 861| callback | AsyncCallback\<[DepthData](#depthdata12)\> | No | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.| 862 863**Example** 864 865```ts 866import { BusinessError } from '@kit.BasicServicesKit'; 867 868function callback(err: BusinessError, depthData: camera.DepthData): void { 869 if (err !== undefined && err.code !== 0) { 870 console.error(`Callback Error, errorCode: ${err.code}`); 871 return; 872 } 873} 874 875function unRegisterDepthDataAvailable(depthDataOutput: camera.DepthDataOutput): void { 876 depthDataOutput.off('depthDataAvailable', callback); 877} 878``` 879 880### on('error')<sup>12+</sup> 881 882on(type: 'error', callback: ErrorCallback): void 883 884Subscribes to **DepthDataOutput** error events. This API uses an asynchronous callback to return the result. 885 886> **NOTE** 887> 888> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**. 889 890**System API**: This is a system API. 891 892**System capability**: SystemCapability.Multimedia.Camera.Core 893 894**Parameters** 895 896| Name | Type | Mandatory| Description | 897| -------- | --------------| ---- | ------------------------ | 898| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **depthDataOutput** instance is created.| 899| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes | Callback used to return an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode). | 900 901**Example** 902 903```ts 904import { BusinessError } from '@kit.BasicServicesKit'; 905 906function callback(depthDataOutputError: BusinessError): void { 907 console.error(`Depth data output error code: ${depthDataOutputError.code}`); 908} 909 910function registerDepthDataOutputError(depthDataOutput: camera.DepthDataOutput): void { 911 depthDataOutput.on('error', callback) 912} 913``` 914 915### off('error')<sup>12+</sup> 916 917off(type: 'error', callback?: ErrorCallback): void 918 919Unsubscribes from **DepthDataOutput** error events. 920 921**System API**: This is a system API. 922 923**System capability**: SystemCapability.Multimedia.Camera.Core 924 925**Parameters** 926 927| Name | Type | Mandatory| Description | 928| -------- | --------------| ---- | ------------------------ | 929| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **depthDataOutput** instance is created.| 930| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | No | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.| 931 932**Example** 933 934```ts 935function unregisterDepthDataOutputError(depthDataOutput: camera.DepthDataOutput): void { 936 depthDataOutput.off('error'); 937} 938``` 939 940## PrelaunchConfig 941 942Defines the camera prelaunch configuration. 943 944Currently, the configuration is used for sensor-level prelaunch. It will be used for stream-level prelaunch in a later version. 945 946**System API**: This is a system API. 947 948**System capability**: SystemCapability.Multimedia.Camera.Core 949 950| Name | Type | Read-only | Mandatory | Description | 951| ------------------------------- | ---------------------------------------- | ----------- | ------------ | ---------- | 952| cameraDevice | [CameraDevice](#cameradevice) | No | Yes | Camera device. | 953| restoreParamType<sup>11+</sup> | [RestoreParamType](#restoreparamtype11) | No | No | Type of the parameter used for prelaunch. | 954| activeTime<sup>11+</sup> | number | No | No | Activation time, in minutes.| 955| settingParam<sup>11+</sup> | [SettingParam](#settingparam11) | No | No | Setting parameter. | 956 957## RestoreParamType<sup>11+</sup> 958 959Enumerates the types of the parameters used for prelaunch. 960 961**System API**: This is a system API. 962 963**System capability**: SystemCapability.Multimedia.Camera.Core 964 965| Name | Value | Description | 966| ----------------| ---- | ---------| 967| NO_NEED_RESTORE_PARAM | 0 | The parameter used for prelaunch is not required. | 968| PRESISTENT_DEFAULT_PARAM | 1 | Persistent parameter type. This parameter is used to restore stream information with the specified time point. | 969| TRANSIENT_ACTIVE_PARAM | 2 | Temporary parameter type. This parameter is used to restore stream information only within a period of time after the camera application is closed. Its priority is higher than that of the persistent parameter. | 970 971## SettingParam<sup>11+</sup> 972 973Defines the effect parameters used to preheat an image. 974 975**System API**: This is a system API. 976 977**System capability**: SystemCapability.Multimedia.Camera.Core 978 979| Name | Type | Read-only | Optional | Description | 980| --------------- | ------ | --------- |-----|---------------------------------------------------------------------------------------------------| 981| skinSmoothLevel | number | No | No | Skin smoothing level, which is obtained through [Beauty.getSupportedBeautyRange](#getsupportedbeautyrange12). For example, the value **1** indicates level-1 smoothing. | 982| faceSlender | number | No | No | Face slimming level, which is obtained through [Beauty.getSupportedBeautyRange](#getsupportedbeautyrange12). For example, the value **1** indicates level-1 slimming. | 983| skinTone | number | No | No | Skin tone perfection level, which is obtained through [Beauty.getSupportedBeautyRange](#getsupportedbeautyrange12). For example, the value **0xBF986C** indicates a specific color.| 984 985## PreviewOutput 986 987Implements preview output. It inherits from [CameraOutput](js-apis-camera.md#cameraoutput). 988 989### addDeferredSurface 990 991addDeferredSurface(surfaceId: string): void 992 993Adds a surface for delayed preview. This API can run after [Session.commitConfig](js-apis-camera.md#commitconfig11-1) or [Session.start](js-apis-camera.md#start11-1) is called. 994 995**System API**: This is a system API. 996 997**System capability**: SystemCapability.Multimedia.Camera.Core 998 999**Parameters** 1000 1001| Name | Type | Mandatory| Description | 1002| -------- | --------------| ---- | ------------------------ | 1003| surfaceId | string | Yes| Surface ID, which is obtained from [XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md).| 1004 1005**Error codes** 1006 1007For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1008 1009| ID | Error Message | 1010| --------------- | --------------- | 1011| 7400101 | Parameter missing or parameter type incorrect. | 1012 1013**Example** 1014 1015```ts 1016import { common } from '@kit.AbilityKit'; 1017 1018async function preview(context: common.BaseContext, cameraDevice: camera.CameraDevice, previewProfile: camera.Profile, photoProfile: camera.Profile, mode: camera.SceneMode, previewSurfaceId: string): Promise<void> { 1019 const cameraManager: camera.CameraManager = camera.getCameraManager(context); 1020 const cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameraDevice); 1021 const previewOutput: camera.PreviewOutput = cameraManager.createDeferredPreviewOutput(previewProfile); 1022 const photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 1023 const session: camera.Session = cameraManager.createSession(mode); 1024 session.beginConfig(); 1025 session.addInput(cameraInput); 1026 session.addOutput(previewOutput); 1027 session.addOutput(photoOutput); 1028 await session.commitConfig(); 1029 await session.start(); 1030 previewOutput.addDeferredSurface(previewSurfaceId); 1031} 1032``` 1033 1034### isSketchSupported<sup>11+</sup> 1035 1036isSketchSupported(): boolean 1037 1038Checks whether Picture-in-Picture (PiP) preview is supported. 1039 1040**System API**: This is a system API. 1041 1042**System capability**: SystemCapability.Multimedia.Camera.Core 1043 1044**Return value** 1045 1046| Type | Description | 1047| -------------- | ----------------------- | 1048| boolean | **true**: PiP preview is supported.<br>**false**: PiP preview is not supported.| 1049 1050**Error codes** 1051 1052For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1053 1054| ID | Error Message | 1055| --------------- |-------------------------| 1056| 202 | Not System Application. | 1057 1058**Example** 1059 1060```ts 1061function isSketchSupported(previewOutput: camera.PreviewOutput): boolean { 1062 try { 1063 let isSupported: boolean = previewOutput.isSketchSupported(); 1064 return isSupported; 1065 } catch (error) { 1066 // If the operation fails, error.code is returned and processed. 1067 let err = error as BusinessError; 1068 console.error(`The isSketchSupported call failed. error code: ${err.code}`); 1069 } 1070 return false; 1071} 1072``` 1073 1074### getSketchRatio<sup>11+</sup> 1075 1076getSketchRatio(): number 1077 1078Obtains the zoom ratio when PiP preview is enabled. 1079 1080**System API**: This is a system API. 1081 1082**System capability**: SystemCapability.Multimedia.Camera.Core 1083 1084**Return value** 1085 1086| Type | Description | 1087| -------------- | ----------------------- | 1088| number | Zoom ratio obtained. If PiP preview is not supported, the value **-1** is returned.| 1089 1090**Error codes** 1091 1092For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1093 1094| ID | Error Message | 1095| --------------- | --------------- | 1096| 7400103 | Session not config. | 1097| 202 | Not System Application. | 1098 1099**Example** 1100 1101```ts 1102function getSketchRatio(previewOutput: camera.PreviewOutput): number { 1103 let sketchRatio: number = previewOutput.getSketchRatio(); 1104 return sketchRatio; 1105} 1106``` 1107 1108### enableSketch<sup>11+</sup> 1109 1110enableSketch(enabled: boolean): void 1111 1112Enables or disables PiP preview. 1113 1114**System API**: This is a system API. 1115 1116**System capability**: SystemCapability.Multimedia.Camera.Core 1117 1118**Parameters** 1119 1120| Name | Type | Mandatory| Description | 1121|---------|---------| ---- | ------------------------ | 1122| enabled | boolean | Yes| Whether to enable PiP preview. The value **true** means to enable PiP preview, and **false** means to disable it.| 1123 1124**Error codes** 1125 1126For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1127 1128| ID | Error Message | 1129|-----------|-----------------------------| 1130| 202 | Not System Application. | 1131| 7400102 | Operation not allowed. | 1132| 7400103 | Session not config. | 1133| 7400201 | Camera service fatal error. | 1134 1135**Example** 1136 1137```ts 1138import { BusinessError } from '@kit.BasicServicesKit'; 1139 1140function enableSketch(previewOutput: camera.PreviewOutput, session: camera.Session, cameraInput: camera.CameraInput): void { 1141 try { 1142 session.beginConfig(); 1143 session.addInput(cameraInput); 1144 session.addOutput(previewOutput); 1145 previewOutput.enableSketch(true); 1146 session.commitConfig(); 1147 } catch (error) { 1148 // If the operation fails, error.code is returned and processed. 1149 let err = error as BusinessError; 1150 console.error(`The enableSketch call failed. error code: ${err.code}`); 1151 } 1152} 1153``` 1154 1155### attachSketchSurface<sup>11+</sup> 1156 1157attachSketchSurface(surfaceId: string): void 1158 1159Attaches a surface for PiP preview. 1160 1161**System API**: This is a system API. 1162 1163**System capability**: SystemCapability.Multimedia.Camera.Core 1164 1165**Parameters** 1166 1167| Name | Type | Mandatory| Description | 1168| -------- | --------------| ---- | ------------------------ | 1169| surfaceId | string | Yes| Surface ID, which is obtained from [XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md).| 1170 1171**Error codes** 1172 1173For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1174 1175| ID | Error Message | 1176|---------|------------------------------------------------| 1177| 202 | Not System Application. | 1178| 7400101 | Parameter missing or parameter type incorrect. | 1179| 7400103 | Session not config. | 1180| 7400201 | Camera service fatal error. | 1181 1182**Example** 1183 1184```ts 1185import { BusinessError } from '@kit.BasicServicesKit'; 1186 1187function attachSketchSurface(previewOutput: camera.PreviewOutput, session: camera.Session, cameraInput: camera.CameraInput, sketchSurfaceId: string): void { 1188 try { 1189 session.beginConfig(); 1190 session.addInput(cameraInput); 1191 session.addOutput(previewOutput); 1192 previewOutput.enableSketch(true); 1193 session.commitConfig(); 1194 previewOutput.attachSketchSurface(sketchSurfaceId); 1195 } catch (error) { 1196 // If the operation fails, error.code is returned and processed. 1197 let err = error as BusinessError; 1198 console.error(`The attachSketchSurface call failed. error code: ${err.code}`); 1199 } 1200} 1201``` 1202 1203### on('sketchStatusChanged')<sup>11+</sup> 1204 1205on(type: 'sketchStatusChanged', callback: AsyncCallback\<SketchStatusData\>): void 1206 1207Subscribes to PiP status change events. This API uses an asynchronous callback to return the result. 1208 1209**System API**: This is a system API. 1210 1211**System capability**: SystemCapability.Multimedia.Camera.Core 1212 1213**Parameters** 1214 1215| Name | Type | Mandatory| Description | 1216| -------- | ---------------------- | ---- | ------------------------------------------ | 1217| type | string | Yes | Event type. The value is fixed at **'sketchStatusChanged'**. The event can be listened for when a PiP preview stream is created. This event is triggered when PiP preview is enabled or disabled or the zoom ratio changes while PiP preview is enabled.| 1218| callback | AsyncCallback\<[SketchStatusData](#sketchstatusdata11)\> | Yes | Callback used to return the PiP status data. | 1219 1220**Error codes** 1221 1222For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1223 1224| ID | Error Message | 1225|---------|-------------------------------| 1226| 202 | Not System Application. | 1227 1228**Example** 1229 1230```ts 1231import { BusinessError } from '@kit.BasicServicesKit'; 1232 1233function callback(error: BusinessError, data: camera.SketchStatusData): void { 1234 if (error !== undefined && error.code !== 0) { 1235 console.error(`Callback Error, errorCode: ${error.code}`); 1236 return; 1237 } 1238 console.info(`sketch errorCode is ${error.code}, data is ${JSON.stringify(data)}`); 1239} 1240 1241function registerSketchStatusChanged(previewOutput: camera.PreviewOutput): void { 1242 previewOutput.on('sketchStatusChanged', callback); 1243} 1244``` 1245 1246### off('sketchStatusChanged')<sup>11+</sup> 1247 1248off(type: 'sketchStatusChanged', callback?: AsyncCallback\<SketchStatusData\>): void 1249 1250Unsubscribes from PiP status change events. 1251 1252**System API**: This is a system API. 1253 1254**System capability**: SystemCapability.Multimedia.Camera.Core 1255 1256**Parameters** 1257 1258| Name | Type | Mandatory| Description | 1259| -------- | ---------------------- | ---- | ------------------------------------------ | 1260| type | string | Yes | Event type. The value is fixed at **'sketchStatusChanged'**. The event can be listened for when a PiP preview stream is created.| 1261| callback | AsyncCallback\<[SketchStatusData](#sketchstatusdata11)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('sketchStatusChanged')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 1262 1263**Error codes** 1264 1265For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1266 1267| ID | Error Message | 1268|---------|-------------------------------| 1269| 202 | Not System Application. | 1270 1271**Example** 1272 1273```ts 1274function unregisterSketchStatusChanged(previewOutput: camera.PreviewOutput): void { 1275 previewOutput.off('sketchStatusChanged'); 1276} 1277``` 1278 1279## DeferredDeliveryImageType<sup>11+</sup> 1280 1281Enumerates the deferred delivery image types. In deferred delivery, photo and video capture are divided into two phases. In the first phase, an image or video is output to users at a relatively fast speed. In the second phase, a higher-resolution image or video is output again after optimization processing. 1282 1283**System API**: This is a system API. 1284 1285**System capability**: SystemCapability.Multimedia.Camera.Core 1286 1287| Name | Value | Description | 1288| ------- | ---- | ------------ | 1289| NONE | 0 | Deferred delivery is not supported.| 1290| PHOTO | 1 | Deferred delivery for photo capture.| 1291| VIDEO | 2 | Deferred delivery for video capture.| 1292 1293## DeferredPhotoProxy<sup>11+</sup> 1294 1295A class object that functions as a thumbnail proxy. 1296 1297### getThumbnail<sup>11+</sup> 1298 1299getThumbnail(): Promise<image.PixelMap> 1300 1301Obtains the PixelMap of a thumbnail. 1302 1303**System API**: This is a system API. 1304 1305**System capability**: SystemCapability.Multimedia.Camera.Core 1306 1307**Return value** 1308 1309| Type | Description | 1310| -------------- | ----------------------- | 1311| Promise\<image.PixelMap\> | PixelMap of the thumbnail.| 1312 1313**Error codes** 1314 1315For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1316 1317| ID | Error Message | 1318| --------------- | --------------- | 1319| 202 | Not System Application. | 1320 1321**Example** 1322 1323```ts 1324import { image } from '@kit.ImageKit'; 1325 1326function getThumbnail(proxyObj: camera.DeferredPhotoProxy): void { 1327 proxyObj.getThumbnail().then((thumbnail: image.PixelMap) => { 1328 AppStorage.setOrCreate('proxyThumbnail', thumbnail); 1329 }); 1330} 1331``` 1332 1333### release<sup>11+</sup> 1334 1335release(): Promise\<void\> 1336 1337Releases output resources. This API uses a promise to return the result. 1338 1339**System API**: This is a system API. 1340 1341**System capability**: SystemCapability.Multimedia.Camera.Core 1342 1343**Return value** 1344 1345| Type | Description | 1346| -------------- |------------------| 1347| Promise\<void\> | Promise that returns no value.| 1348 1349**Error codes** 1350 1351For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1352 1353| ID | Error Message | 1354| --------------- | --------------- | 1355| 202 | Not System Application. | 1356 1357**Example** 1358 1359```ts 1360async function releaseDeferredPhotoProxy(proxyObj: camera.DeferredPhotoProxy): Promise<void> { 1361 await proxyObj.release(); 1362} 1363``` 1364 1365## PhotoOutput 1366 1367Implements output information used in a photo session. It inherits from [CameraOutput](js-apis-camera.md#cameraoutput). 1368 1369### burstCapture<sup>12+</sup> 1370 1371burstCapture(setting: PhotoCaptureSetting): Promise\<void\> 1372 1373Starts the burst mode, in which users can capture a series of photos in quick succession. This API is generally used in photo mode. After the burst mode starts, the bottom layer continues displaying photos. You can call [confirmCapture](#confirmcapture11) to cancel the burst mode. 1374 1375**System API**: This is a system API. 1376 1377**System capability**: SystemCapability.Multimedia.Camera.Core 1378 1379**Parameters** 1380 1381| Name | Type | Mandatory| Description | 1382| ------- | ------------------------------------------- | ---- | -------- | 1383| setting | [PhotoCaptureSetting](js-apis-camera.md#photocapturesetting) | Yes | Shooting parameters. The input of **undefined** is processed as if no parameters were passed.| 1384 1385**Return value** 1386 1387| Type | Description | 1388| -------------- | ------------------------ | 1389| Promise\<void\> | Promise that returns no value.| 1390 1391**Error codes** 1392 1393For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1394 1395| ID | Error Message | 1396| --------------- | --------------- | 1397| 202 | Not System Application. | 1398| 7400101 | Parameter missing or parameter type incorrect. | 1399| 7400104 | Session not running. | 1400| 7400201 | Camera service fatal error. | 1401 1402**Example** 1403 1404```ts 1405import { BusinessError } from '@kit.BasicServicesKit'; 1406 1407function burstCapture(photoOutput: camera.PhotoOutput): void { 1408 let captureLocation: camera.Location = { 1409 latitude: 0, 1410 longitude: 0, 1411 altitude: 0 1412 } 1413 let settings: camera.PhotoCaptureSetting = { 1414 quality: camera.QualityLevel.QUALITY_LEVEL_LOW, 1415 rotation: camera.ImageRotation.ROTATION_0, 1416 location: captureLocation, 1417 mirror: false 1418 } 1419 photoOutput.burstCapture(settings).then(() => { 1420 console.info('Promise returned to indicate that photo burstCapture request success.'); 1421 }).catch((error: BusinessError) => { 1422 console.error(`Failed to photo output burstCapture, error code: ${error.code}.`); 1423 }); 1424} 1425``` 1426 1427### confirmCapture<sup>11+</sup> 1428 1429confirmCapture() 1430 1431Confirms photo capture. This API is generally used in night photo mode when users need to stop the exposure countdown and take a photo in advance. 1432 1433This API is used to end the burst mode, which is started by calling [burstCapture](#burstcapture12). 1434 1435**System API**: This is a system API. 1436 1437**System capability**: SystemCapability.Multimedia.Camera.Core 1438 1439**Error codes** 1440 1441For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1442 1443| ID | Error Message | 1444| --------------- | --------------- | 1445| 202 | Not System Application. | 1446| 7400104 | Session not running. | 1447| 7400201 | Camera service fatal error. | 1448 1449**Example** 1450 1451```ts 1452import { BusinessError } from '@kit.BasicServicesKit'; 1453 1454function confirmCapture(photoOutput: camera.PhotoOutput): void { 1455 try { 1456 photoOutput.confirmCapture(); 1457 } catch (error) { 1458 let err = error as BusinessError; 1459 console.error(`The confirmCapture call failed. error code: ${err.code}`); 1460 } 1461} 1462``` 1463 1464### isDeferredImageDeliverySupported<sup>11+</sup> 1465 1466isDeferredImageDeliverySupported(type: DeferredDeliveryImageType): boolean 1467 1468Checks whether deferred delivery of a certain type is supported. 1469 1470**System API**: This is a system API. 1471 1472**System capability**: SystemCapability.Multimedia.Camera.Core 1473 1474**Parameters** 1475 1476| Name | Type | Mandatory| Description | 1477| -------- | -------------------- | ---- | ------------------- | 1478| type | [DeferredDeliveryImageType](#deferreddeliveryimagetype11) | Yes | Deferred delivery image type. | 1479 1480**Return value** 1481 1482| Type | Description | 1483| -------------- | ----------------------- | 1484| boolean | **true**: Deferred delivery is supported.<br>**false**: Deferred delivery is not supported.| 1485 1486**Error codes** 1487 1488For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1489 1490| ID | Error Message | 1491| --------------- |-----------------------------------------------------| 1492| 7400101 | Parameter missing or parameter type incorrect. | 1493| 7400104 | Session not running. | 1494| 7400201 | Camera service fatal error. | 1495| 202 | Not System Application. | 1496 1497**Example** 1498 1499```ts 1500function isDeferredImageDeliverySupported(photoOutput: camera.PhotoOutput, type: camera.DeferredDeliveryImageType): boolean { 1501 let res: boolean = false; 1502 res = photoOutput.isDeferredImageDeliverySupported(type); 1503 return res; 1504} 1505``` 1506 1507### isDeferredImageDeliveryEnabled<sup>11+</sup> 1508 1509isDeferredImageDeliveryEnabled(type: DeferredDeliveryImageType): boolean 1510 1511Checks whether deferred delivery of a certain type is enabled. 1512 1513**System API**: This is a system API. 1514 1515**System capability**: SystemCapability.Multimedia.Camera.Core 1516 1517**Parameters** 1518 1519| Name | Type | Mandatory| Description | 1520| -------- | -------------------- | ---- | ------------------- | 1521| type | [DeferredDeliveryImageType](#deferreddeliveryimagetype11) | Yes | Deferred delivery image type. | 1522 1523**Return value** 1524 1525| Type | Description | 1526| -------------- | ----------------------- | 1527| boolean | **true**: Deferred delivery is enabled. **false**: Deferred delivery is disabled.| 1528 1529**Error codes** 1530 1531For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1532 1533| ID | Error Message | 1534| --------------- | --------------- | 1535| 7400101 | Parameter missing or parameter type incorrect. | 1536| 7400104 | Session not running. | 1537| 7400201 | Camera service fatal error. | 1538| 202 | Not System Application. | 1539 1540**Example** 1541 1542```ts 1543function isDeferredImageDeliveryEnabled(photoOutput: camera.PhotoOutput, type: camera.DeferredDeliveryImageType): boolean { 1544 let res: boolean = false; 1545 res = photoOutput.isDeferredImageDeliveryEnabled(type); 1546 return res; 1547} 1548``` 1549 1550### deferImageDelivery<sup>11+</sup> 1551 1552deferImageDelivery(type: DeferredDeliveryImageType): void 1553 1554Enables deferred delivery of a certain type. 1555 1556**System API**: This is a system API. 1557 1558**System capability**: SystemCapability.Multimedia.Camera.Core 1559 1560**Parameters** 1561 1562| Name | Type | Mandatory| Description | 1563| -------- | -------------------- | ---- | ------------------- | 1564| type | [DeferredDeliveryImageType](#deferreddeliveryimagetype11) | Yes | Deferred delivery image type. | 1565 1566**Error codes** 1567 1568For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1569 1570| ID | Error Message | 1571| --------------- | --------------- | 1572| 7400101 | Parameter missing or parameter type incorrect. | 1573| 7400104 | Session not running. | 1574| 7400201 | Camera service fatal error. | 1575| 202 | Not System Application. | 1576 1577**Example** 1578 1579```ts 1580function deferImageDelivery(photoOutput: camera.PhotoOutput, type: camera.DeferredDeliveryImageType): void { 1581 photoOutput.deferImageDelivery(type); 1582} 1583``` 1584 1585### isAutoHighQualityPhotoSupported<sup>12+</sup> 1586 1587isAutoHighQualityPhotoSupported(): boolean 1588 1589Checks whether automatic high quality is supported for photos. 1590 1591**System API**: This is a system API. 1592 1593**System capability**: SystemCapability.Multimedia.Camera.Core 1594 1595**Return value** 1596 1597| Type | Description | 1598| -------------- | ----------------------- | 1599| boolean | Whether automatic high quality is supported.| 1600 1601**Error codes** 1602 1603For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1604 1605| ID | Error Message | 1606| --------------- | --------------- | 1607| 202 | Not System Application. | 1608| 7400104 | Session not running. | 1609| 7400201 | Camera service fatal error. | 1610 1611**Example** 1612 1613```ts 1614import { BusinessError } from '@kit.BasicServicesKit'; 1615 1616function isAutoHighQualityPhotoSupported(photoOutput: camera.PhotoOutput): boolean { 1617 return photoOutput.isAutoHighQualityPhotoSupported(); 1618} 1619``` 1620 1621### enableAutoHighQualityPhoto<sup>12+</sup> 1622 1623enableAutoHighQualityPhoto(enabled: boolean): void 1624 1625Enables automatic high quality for photos. 1626 1627Before using this API, call [isAutoHighQualityPhotoSupported](#isautohighqualityphotosupported12) to check whether automatic high quality is supported. 1628 1629**System API**: This is a system API. 1630 1631**System capability**: SystemCapability.Multimedia.Camera.Core 1632 1633**Parameters** 1634 1635| Name | Type | Mandatory| Description | 1636| -------- | -------------------- | ---- | ------------------- | 1637| enabled | boolean | Yes | Whether to enable automatic high quality for photos. | 1638 1639**Error codes** 1640 1641For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1642 1643| ID | Error Message | 1644| --------------- | --------------- | 1645| 202 | Not System Application. | 1646| 7400101 | Parameter missing or parameter type incorrect. | 1647| 7400104 | Session not running. | 1648| 7400201 | Camera service fatal error. | 1649 1650**Example** 1651 1652```ts 1653import { BusinessError } from '@kit.BasicServicesKit'; 1654 1655function enableAutoHighQualityPhoto(photoOutput: camera.PhotoOutput): void { 1656 return photoOutput.enableAutoHighQualityPhoto(true); 1657} 1658``` 1659 1660### on('deferredPhotoProxyAvailable')<sup>11+</sup> 1661 1662on(type: 'deferredPhotoProxyAvailable', callback: AsyncCallback\<DeferredPhotoProxy\>): void 1663 1664Subscribes to events indicating available thumbnail proxies. This API uses an asynchronous callback to return the result. 1665 1666**System API**: This is a system API. 1667 1668**System capability**: SystemCapability.Multimedia.Camera.Core 1669 1670**Parameters** 1671 1672| Name | Type | Mandatory| Description | 1673| -------- | ---------- | --- | ------------------------------------ | 1674| type | string | Yes | Event type. The value is fixed at **'deferredPhotoProxyAvailable'**. The event can be listened for when a **photoOutput** instance is created.| 1675| callback | AsyncCallback\<[DeferredPhotoProxy](#deferredphotoproxy11)\> | Yes | Callback used to return the thumbnail proxy.| 1676 1677**Error codes** 1678 1679For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1680 1681| ID | Error Message | 1682| --------------- | --------------- | 1683| 202 | Not System Application. | 1684 1685**Example** 1686 1687```ts 1688import { BusinessError } from '@kit.BasicServicesKit'; 1689import { image } from '@kit.ImageKit'; 1690 1691function callback(err: BusinessError, proxyObj: camera.DeferredPhotoProxy): void { 1692 if (err !== undefined && err.code !== 0) { 1693 console.error(`Callback Error, errorCode: ${err.code}`); 1694 return; 1695 } 1696 proxyObj.getThumbnail().then((thumbnail: image.PixelMap) => { 1697 AppStorage.setOrCreate('proxyThumbnail', thumbnail); 1698 }); 1699} 1700 1701function registerPhotoOutputDeferredPhotoProxyAvailable(photoOutput: camera.PhotoOutput): void { 1702 photoOutput.on('deferredPhotoProxyAvailable', callback); 1703} 1704``` 1705 1706### off('deferredPhotoProxyAvailable')<sup>11+</sup> 1707 1708off(type: 'deferredPhotoProxyAvailable', callback?: AsyncCallback\<DeferredPhotoProxy\>): void 1709 1710Unsubscribes from events indicating available thumbnail proxies. 1711 1712**System API**: This is a system API. 1713 1714**System capability**: SystemCapability.Multimedia.Camera.Core 1715 1716**Parameters** 1717 1718| Name | Type | Mandatory| Description | 1719| -------- | ---------------------- | ---- | ------------------------------------------ | 1720| type | string | Yes | Event type. The value is fixed at **'deferredPhotoProxyAvailable'**. The event can be listened for when a **photoOutput** instance is created.| 1721| callback | AsyncCallback\<[DeferredPhotoProxy](#deferredphotoproxy11)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('deferredPhotoProxyAvailable')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 1722 1723**Error codes** 1724 1725For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1726 1727| ID | Error Message | 1728| --------------- | --------------- | 1729| 202 | Not System Application. | 1730 1731**Example** 1732 1733```ts 1734import { BusinessError } from '@kit.BasicServicesKit'; 1735import { image } from '@kit.ImageKit'; 1736 1737function callback(err: BusinessError, proxyObj: camera.DeferredPhotoProxy): void { 1738 proxyObj.getThumbnail().then((thumbnail: image.PixelMap) => { 1739 AppStorage.setOrCreate('proxyThumbnail', thumbnail); 1740 }); 1741} 1742 1743function unRegisterPhotoOutputDeferredPhotoProxyAvailable(photoOutput: camera.PhotoOutput): void { 1744 photoOutput.off('deferredPhotoProxyAvailable', callback); 1745} 1746``` 1747 1748### isQuickThumbnailSupported 1749 1750isQuickThumbnailSupported(): boolean 1751 1752Checks whether the quick thumbnail feature is supported. 1753 1754This API must be called after [addOutput](js-apis-camera.md#addoutput11) or [addInput](js-apis-camera.md#addinput11) and before [commitConfig](js-apis-camera.md#commitconfig11-1). 1755 1756**System API**: This is a system API. 1757 1758**System capability**: SystemCapability.Multimedia.Camera.Core 1759 1760**Return value** 1761 1762| Type| Description| 1763| --------- | ------ | 1764| boolean | **true**: The quick thumbnail feature is supported.<br>**false**: The quick thumbnail feature is not supported.| 1765 1766**Error codes** 1767 1768For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1769 1770| ID | Error Message | 1771| --------------- | --------------- | 1772| 202 | Not System Application. | 1773| 7400104 | session is not running. | 1774 1775**Example** 1776 1777```ts 1778import { common } from '@kit.AbilityKit'; 1779 1780async function isQuickThumbnailSupported(context: common.BaseContext, mode: camera.SceneMode, photoProfile: camera.Profile): Promise<boolean> { 1781 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 1782 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 1783 // Create a CaptureSession instance. 1784 let session: camera.Session = cameraManager.createSession(mode); 1785 // Start configuration for the session. 1786 session.beginConfig(); 1787 // Add a CameraInput instance to the session. 1788 let cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameras[0]); 1789 await cameraInput.open(); 1790 session.addInput(cameraInput); 1791 // Add a PhotoOutput instance to the session. 1792 let photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 1793 session.addOutput(photoOutput); 1794 let isSupported: boolean = photoOutput.isQuickThumbnailSupported(); 1795 return isSupported; 1796} 1797``` 1798 1799### enableQuickThumbnail 1800 1801enableQuickThumbnail(enabled: boolean): void 1802 1803Enables or disables the quick thumbnail feature. 1804 1805This API must be called after [addOutput](js-apis-camera.md#addoutput11) or [addInput](js-apis-camera.md#addinput11) and before [commitConfig](js-apis-camera.md#commitconfig11-1). 1806 1807**System API**: This is a system API. 1808 1809**System capability**: SystemCapability.Multimedia.Camera.Core 1810 1811**Parameters** 1812 1813| Name | Type | Mandatory| Description | 1814| -------- | ------------- | ---- | ----------------------------------- | 1815| enabled | boolean | Yes | Whether to enable the quick thumbnail feature. The value **true** means to enable the quick thumbnail feature, and **false** means to disable it.| 1816 1817**Error codes** 1818 1819For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1820 1821| ID | Error Message | 1822| --------------- | --------------- | 1823| 202 | Not System Application. | 1824| 7400101 | Parameter missing or parameter type incorrect. | 1825| 7400104 | session is not running. | 1826| 7400201 | Camera service fatal error. | 1827 1828**Example** 1829 1830```ts 1831import { common } from '@kit.AbilityKit'; 1832import { BusinessError } from '@kit.BasicServicesKit'; 1833 1834async function enableQuickThumbnail(context: common.BaseContext, mode: camera.SceneMode, photoProfile: camera.Profile): Promise<void> { 1835 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 1836 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 1837 // Create a CaptureSession instance. 1838 let session: camera.Session = cameraManager.createSession(mode); 1839 // Start configuration for the session. 1840 session.beginConfig(); 1841 // Add a CameraInput instance to the session. 1842 let cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameras[0]); 1843 await cameraInput.open(); 1844 session.addInput(cameraInput); 1845 // Add a PhotoOutput instance to the session. 1846 let photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 1847 session.addOutput(photoOutput); 1848 let isSupported: boolean = photoOutput.isQuickThumbnailSupported(); 1849 if (!isSupported) { 1850 console.info('Quick Thumbnail is not supported to be turned on.'); 1851 return; 1852 } 1853 try { 1854 photoOutput.enableQuickThumbnail(true); 1855 } catch (error) { 1856 let err = error as BusinessError; 1857 console.error(`The enableQuickThumbnail call failed. error code: ${err.code}`); 1858 } 1859} 1860``` 1861 1862### on('quickThumbnail') 1863 1864on(type: 'quickThumbnail', callback: AsyncCallback\<image.PixelMap>): void 1865 1866Subscribes to quick thumbnail output events. This API uses an asynchronous callback to return the result. 1867 1868The listening takes effect after **enableQuickThumbnail(true)** is called. 1869 1870**System API**: This is a system API. 1871 1872**System capability**: SystemCapability.Multimedia.Camera.Core 1873 1874**Parameters** 1875 1876| Name | Type | Mandatory| Description | 1877| -------- | ------------- | ---- | ----------------------------------- | 1878| type | string | Yes | Event type. The value is fixed at **'quickThumbnail'**.| 1879| callback | AsyncCallback\<[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)> | Yes| Callback that returns a **PixelMap** instance.| 1880 1881**Example** 1882 1883```ts 1884import { common } from '@kit.AbilityKit'; 1885import { BusinessError } from '@kit.BasicServicesKit'; 1886import { image } from '@kit.ImageKit'; 1887 1888function callback(err: BusinessError, pixelMap: image.PixelMap): void { 1889 if (err || pixelMap === undefined) { 1890 console.error('photoOutput on thumbnail failed'); 1891 return; 1892 } 1893 // Display or save the PixelMap instance. 1894 // do something 1895} 1896 1897async function registerQuickThumbnail(context: common.BaseContext, mode: camera.SceneMode, photoProfile: camera.Profile): Promise<void> { 1898 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 1899 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 1900 // Create a CaptureSession instance. 1901 let session: camera.Session = cameraManager.createSession(mode); 1902 // Start configuration for the session. 1903 session.beginConfig(); 1904 // Add a CameraInput instance to the session. 1905 let cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameras[0]); 1906 await cameraInput.open(); 1907 session.addInput(cameraInput); 1908 // Add a PhotoOutput instance to the session. 1909 let photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 1910 session.addOutput(photoOutput); 1911 let isSupported: boolean = photoOutput.isQuickThumbnailSupported(); 1912 if (!isSupported) { 1913 console.info('Quick Thumbnail is not supported to be turned on.'); 1914 return; 1915 } 1916 try { 1917 photoOutput.enableQuickThumbnail(true); 1918 } catch (error) { 1919 let err = error as BusinessError; 1920 console.error(`The enableQuickThumbnail call failed. error code: ${err.code}`); 1921 } 1922 1923 photoOutput.on('quickThumbnail', callback); 1924} 1925``` 1926 1927### off('quickThumbnail') 1928 1929off(type: 'quickThumbnail', callback?: AsyncCallback\<image.PixelMap>): void 1930 1931Unsubscribes from quick thumbnail output events. 1932 1933**System API**: This is a system API. 1934 1935**System capability**: SystemCapability.Multimedia.Camera.Core 1936 1937**Parameters** 1938 1939| Name | Type | Mandatory| Description | 1940| -------- | ------------- | ---- | ----------------------------------- | 1941| type | string | Yes | Event type. The value is fixed at **'quickThumbnail'**.| 1942| callback | AsyncCallback\<[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)> | No| Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('quickThumbnail')** with the specified callback is canceled. (The callback object cannot be an anonymous function.)| 1943 1944**Example** 1945 1946```ts 1947function unregisterQuickThumbnail(photoOutput: camera.PhotoOutput): void { 1948 photoOutput.off('quickThumbnail'); 1949} 1950``` 1951 1952## VideoOutput 1953 1954Implements output information used in a video session. It inherits from [CameraOutput](js-apis-camera.md#cameraoutput). 1955 1956### isMirrorSupported<sup>12+</sup> 1957 1958isMirrorSupported(): boolean 1959 1960Checks whether video mirroring is supported. 1961 1962**System API**: This is a system API. 1963 1964**System capability**: SystemCapability.Multimedia.Camera.Core 1965 1966**Return value** 1967 1968| Type | Description | 1969| -------------- | ----------------------- | 1970| boolean | Whether video mirroring is supported.| 1971 1972**Error codes** 1973 1974For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1975 1976| ID | Error Message | 1977| --------------- | --------------- | 1978| 202 | Not System Application. | 1979 1980**Example** 1981 1982```ts 1983import { BusinessError } from '@kit.BasicServicesKit'; 1984 1985function isMirrorSupported(videoOutput: camera.VideoOutput): boolean { 1986 return videoOutput.isMirrorSupported(); 1987} 1988``` 1989 1990### enableMirror<sup>12+</sup> 1991 1992enableMirror(enabled: boolean): void 1993 1994Enables video mirroring. 1995 1996Before using this API, call [isMirrorSupported](#ismirrorsupported12) to check whether video mirroring is supported. 1997 1998**System API**: This is a system API. 1999 2000**System capability**: SystemCapability.Multimedia.Camera.Core 2001 2002**Parameters** 2003 2004| Name | Type | Mandatory| Description | 2005| -------- | -------------------- | ---- | ------------------- | 2006| enabled | boolean | Yes | Whether to enable video mirroring. | 2007 2008**Error codes** 2009 2010For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2011 2012| ID | Error Message | 2013| --------------- | --------------- | 2014| 202 | Not System Application. | 2015| 7400101 | Parameter missing or parameter type incorrect. | 2016| 7400103 | Session not config. | 2017 2018**Example** 2019 2020```ts 2021import { BusinessError } from '@kit.BasicServicesKit'; 2022 2023function enableMirror(videoOutput: camera.VideoOutput): void { 2024 return videoOutput.enableMirror(true); 2025} 2026``` 2027 2028## MetadataOutput 2029 2030Implements metadata streams. It inherits from [CameraOutput](js-apis-camera.md#cameraoutput). 2031 2032### addMetadataObjectTypes<sup>13+</sup> 2033 2034addMetadataObjectTypes(types: Array\<MetadataObjectType\>): void 2035 2036Adds the types of metadata objects to be detected. 2037 2038**System capability**: SystemCapability.Multimedia.Camera.Core 2039 2040**Parameters** 2041 2042| Name | Type | Mandatory| Description | 2043| -------------------- | -------------------------------------------------- | --- | ---------------------------- | 2044| metadataObjectTypes | Array\<[MetadataObjectType](#metadataobjecttype)\> | Yes | Metadata object types, which are obtained through **getSupportedOutputCapability**.| 2045 2046**Error codes** 2047 2048For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2049 2050| ID | Error Message | 2051| --------------- | --------------- | 2052| 202 | Not system application. | 2053| 7400101 | Parameter missing or parameter type incorrect. | 2054| 7400103 | Session not config. | 2055| 7400201 | Camera service fatal error. | 2056 2057**Example** 2058 2059```ts 2060import { BusinessError } from '@kit.BasicServicesKit'; 2061 2062function addMetadataObjectTypes(metadataOutput: camera.MetadataOutput, types: Array<camera.MetadataObjectType>): void { 2063 try { 2064 metadataOutput.addMetadataObjectTypes(types); 2065 } catch (error) { 2066 // If the operation fails, error.code is returned and processed. 2067 let err = error as BusinessError; 2068 console.error(`addMetadataObjectTypes error. error code: ${err.code}`); 2069 } 2070} 2071``` 2072 2073### removeMetadataObjectTypes<sup>13+</sup> 2074 2075removeMetadataObjectTypes(types: Array\<MetadataObjectType\>): void 2076 2077Removes the types of metadata objects to be detected. 2078 2079**System capability**: SystemCapability.Multimedia.Camera.Core 2080 2081**Parameters** 2082 2083| Name | Type | Mandatory| Description | 2084| -------------------- | -------------------------------------------------- | --- | ---------------------------- | 2085| metadataObjectTypes | Array\<[MetadataObjectType](#metadataobjecttype)\> | Yes | Metadata object types, which are obtained through **getSupportedOutputCapability**.| 2086 2087**Error codes** 2088 2089For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2090 2091| ID | Error Message | 2092| --------------- | --------------- | 2093| 202 | Not system application. | 2094| 7400101 | Parameter missing or parameter type incorrect. | 2095| 7400103 | Session not config. | 2096| 7400201 | Camera service fatal error. | 2097 2098**Example** 2099 2100```ts 2101import { BusinessError } from '@kit.BasicServicesKit'; 2102 2103function removeMetadataObjectTypes(metadataOutput: camera.MetadataOutput, types: Array<camera.MetadataObjectType>): void { 2104 try { 2105 metadataOutput.removeMetadataObjectTypes(types); 2106 } catch (error) { 2107 // If the operation fails, error.code is returned and processed. 2108 let err = error as BusinessError; 2109 console.error(`removeMetadataObjectTypes error. error code: ${err.code}`); 2110 } 2111} 2112``` 2113 2114## MetadataObjectType 2115 2116Enumerates the types of metadata objects used for camera detection. 2117 2118**System capability**: SystemCapability.Multimedia.Camera.Core 2119 2120| Name | Value | Description | 2121| -------------------------- | ---- | ----------------- | 2122| HUMAN_BODY<sup>13+</sup> | 1 | Metadata object used for human body detection.| 2123| CAT_FACE<sup>13+</sup> | 2 | Metadata object used for cat face detection.| 2124| CAT_BODY<sup>13+</sup> | 3 | Metadata object used for cat body detection.| 2125| DOG_FACE<sup>13+</sup> | 4 | Metadata object used for dog face detection.| 2126| DOG_BODY<sup>13+</sup> | 5 | Metadata object used for dog body detection.| 2127| SALIENT_DETECTION<sup>13+</sup> | 6 | Metadata object used for salient detection.| 2128 2129## Emotion<sup>13+</sup> 2130Enumerates the types of emotions in the detected human face information. 2131 2132**System capability**: SystemCapability.Multimedia.Camera.Core 2133 2134| Name | Value | Description | 2135| -------------------------- | ---- | ----------------- | 2136| NEUTRAL | 0 | Quiet and calm.| 2137| SADNESS | 1 | Sad.| 2138| SMILE | 2 | Smile.| 2139| SURPRISE | 3 | Surprise.| 2140 2141## MetadataObject 2142 2143Implements the basic metadata object used for camera detection. This class is the data source of the camera information of [CameraInput](#camerainput). It is obtained by calling **metadataOutput.on('metadataObjectsAvailable')**. 2144 2145**System capability**: SystemCapability.Multimedia.Camera.Core 2146 2147| Name | Type | Read-only| Optional|Description | 2148| ----------- | ------------------------------------------- | ---- | ---- | ----------------- | 2149| objectId<sup>13+</sup> | number | Yes | No | Metadata object ID.| 2150| confidence<sup>13+</sup> | number | Yes | No | Confidence of the detection, with a value range of [0,1].| 2151 2152## MetadataFaceObject<sup>13+</sup> 2153 2154Implements the human face metadata object used for camera detection. This class inherits from [MetadataObject](#metadataobject) and is the data source of the camera information of [CameraInput](#camerainput). It is obtained by calling **metadataOutput.on('metadataObjectsAvailable')**. 2155 2156**System capability**: SystemCapability.Multimedia.Camera.Core 2157 2158| Name | Type | Read-only| Optional|Description | 2159| ---------------------- | --------------------------------- | ---- | ---- | --------------------- | 2160| leftEyeBoundingBox | [Rect](js-apis-camera.md#rect) | Yes | No | Left eye area.| 2161| rightEyeBoundingBox | [Rect](js-apis-camera.md#rect) | Yes | No | Right eye area.| 2162| emotion | [Emotion](#emotion13) | Yes | No | Detected emotion.| 2163| emotionConfidence | number | Yes | No | Confidence of the emotion detection, with a value range of [0,1].| 2164| pitchAngle | number | Yes | No | Pitch angle, with a value range of [-90, 90], where downward is positive.| 2165| yawAngle | number | Yes | No | Yaw angle, with a value range of [-90, 90], where rightward is positive.| 2166| rollAngle | number | Yes | No | Row angle, with a value range of [-180, 180], where clockwise direction is positive.| 2167 2168## MetadataHumanBodyObject<sup>13+</sup> 2169 2170Implements the human body metadata object used for camera detection. This class inherits from [MetadataObject](#metadataobject) and is the data source of the camera information of [CameraInput](#camerainput). It is obtained by calling **metadataOutput.on('metadataObjectsAvailable')**. 2171 2172**System capability**: SystemCapability.Multimedia.Camera.Core 2173 2174## MetadataCatFaceObject<sup>13+</sup> 2175 2176Implements the cat face metadata object used for camera detection. This class inherits from [MetadataObject](#metadataobject) and is the data source of the camera information of [CameraInput](#camerainput). It is obtained by calling **metadataOutput.on('metadataObjectsAvailable')**. 2177 2178**System capability**: SystemCapability.Multimedia.Camera.Core 2179 2180| Name | Type | Read-only| Optional|Description | 2181| ---------------------- | --------------------------------- | ---- | ---- | --------------------- | 2182| leftEyeBoundingBox | [Rect](js-apis-camera.md#rect) | Yes | No | Left eye area.| 2183| rightEyeBoundingBox | [Rect](js-apis-camera.md#rect) | Yes | No | Right eye area.| 2184 2185## MetadataCatBodyObject<sup>13+</sup> 2186 2187Implements the cat body metadata object used for camera detection. This class inherits from [MetadataObject](#metadataobject) and is the data source of the camera information of [CameraInput](#camerainput). It is obtained by calling **metadataOutput.on('metadataObjectsAvailable')**. 2188 2189**System capability**: SystemCapability.Multimedia.Camera.Core 2190 2191## MetadataDogFaceObject<sup>13+</sup> 2192 2193Implements the dog face metadata object used for camera detection. This class inherits from [MetadataObject](#metadataobject) and is the data source of the camera information of [CameraInput](#camerainput). It is obtained by calling **metadataOutput.on('metadataObjectsAvailable')**. 2194 2195**System capability**: SystemCapability.Multimedia.Camera.Core 2196 2197| Name | Type | Read-only| Optional|Description | 2198| ---------------------- | --------------------------------- | ---- | ---- | --------------------- | 2199| leftEyeBoundingBox | [Rect](js-apis-camera.md#rect) | Yes | No | Left eye area.| 2200| rightEyeBoundingBox | [Rect](js-apis-camera.md#rect) | Yes | No | Right eye area.| 2201 2202## MetadataDogBodyObject<sup>13+</sup> 2203 2204Implements the dog body metadata object used for camera detection. This class inherits from [MetadataObject](#metadataobject) and is the data source of the camera information of [CameraInput](#camerainput). It is obtained by calling **metadataOutput.on('metadataObjectsAvailable')**. 2205 2206**System capability**: SystemCapability.Multimedia.Camera.Core 2207 2208## MetadataSalientDetectionObject<sup>13+</sup> 2209 2210Implements the salient detection metadata object used for camera detection. This class inherits from [MetadataObject](#metadataobject) and is the data source of the camera information of [CameraInput](#camerainput). It is obtained by calling **metadataOutput.on('metadataObjectsAvailable')**. 2211 2212**System capability**: SystemCapability.Multimedia.Camera.Core 2213 2214## PortraitEffect 2215 2216Enumerates the portrait effects. 2217 2218**System API**: This is a system API. 2219 2220**System capability**: SystemCapability.Multimedia.Camera.Core 2221 2222| Name | Value | Description | 2223| ----------------| ---- | ---------| 2224| OFF | 0 | Disabled. | 2225| CIRCLES | 1 | Circles. | 2226| HEART<sup>11+</sup> | 2 | Heart-shaped. | 2227| ROTATED<sup>11+</sup> | 3 | Rotated. | 2228| STUDIO<sup>11+</sup> | 4 | Studio light. | 2229| THEATER<sup>11+</sup> | 5 | Theater light. | 2230 2231## BeautyQuery<sup>12+</sup> 2232 2233Provides APIs to obtain and set the beauty effect. 2234 2235### getSupportedBeautyTypes<sup>12+</sup> 2236 2237getSupportedBeautyTypes(): Array\<BeautyType\> 2238 2239Obtains the supported beauty types. 2240 2241**System API**: This is a system API. 2242 2243**System capability**: SystemCapability.Multimedia.Camera.Core 2244 2245**Return value** 2246 2247| Type | Description | 2248| ---------- | ----------------------------- | 2249| Array\<[BeautyType](#beautytype)\>| Array of beauty types supported. | 2250 2251**Error codes** 2252 2253For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2254 2255| ID | Error Message | 2256| --------------- | --------------- | 2257| 202 | Not System Application. | 2258| 7400103 | Session not config. | 2259 2260**Example** 2261 2262```ts 2263function getSupportedBeautyTypes(portraitPhotoSession: camera.PortraitPhotoSession): Array<camera.BeautyType> { 2264 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2265 return beautyTypes; 2266} 2267``` 2268 2269### getSupportedBeautyRange<sup>12+</sup> 2270 2271getSupportedBeautyRange(type: BeautyType): Array\<number\> 2272 2273Obtains the levels that can be set a beauty type. 2274 2275The beauty levels vary according to the device type. The following table is only an example. 2276 2277| Input Parameter | Example Return Value | Return Value Description | 2278| ----------------| ---- | ---------| 2279| AUTO | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |Beauty levels supported when **type** is set to **AUTO**. The value **0** means that beauty mode is disabled, and other positive values mean the corresponding automatic beauty levels. | 2280| SKIN_SMOOTH | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | Beauty levels supported when **type** is set to **SKIN_SMOOTH**. The value **0** means that the skin smoothing feature is disabled, and other positive values mean the corresponding skin smoothing levels. | 2281| FACE_SLENDER | [0, 1, 2, 3, 4, 5] | Beauty levels supported when **type** is set to **FACE_SLENDER**. The value **0** means that the face slimming feature is disabled, and other positive values mean the corresponding face slimming levels. | 2282| SKIN_TONE | [-1, 16242611] | Beauty levels supported when **type** is set to **SKIN_TONE**. The value **-1** means that the skin tone perfection feature is disabled. Other non-negative values mean the skin tone perfection levels represented by RGB,<br> for example, 16242611, which is 0xF7D7B3 in hexadecimal format, where F7, D7, and B3 represent the values of the R channel, G channel, and B channel, respectively. | 2283 2284**System API**: This is a system API. 2285 2286**System capability**: SystemCapability.Multimedia.Camera.Core 2287 2288**Parameters** 2289 2290| Name | Type | Mandatory| Description | 2291| -------- | --------------------------| ---- | ----------| 2292| type | [BeautyType](#beautytype) | Yes | Beauty type. | 2293 2294**Return value** 2295 2296| Type | Description | 2297| ---------- | ----------------------------- | 2298| Array\<number\> | Array of levels supported.| 2299 2300**Error codes** 2301 2302For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2303 2304| ID | Error Message | 2305| --------------- | --------------- | 2306| 202 | Not System Application. | 2307| 7400103 | Session not config. | 2308 2309**Example** 2310 2311```ts 2312function getSupportedBeautyRange(portraitPhotoSession: camera.PortraitPhotoSession): Array<number> { 2313 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2314 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2315 return []; 2316 } 2317 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2318 return beautyLevels; 2319} 2320``` 2321 2322## BeautyType 2323 2324Enumerates the beauty types. 2325 2326**System API**: This is a system API. 2327 2328**System capability**: SystemCapability.Multimedia.Camera.Core 2329 2330| Name | Value | Description | 2331| ----------------| ---- | ---------| 2332| AUTO | 0 | Automatic. | 2333| SKIN_SMOOTH | 1 | Skin smoothing. | 2334| FACE_SLENDER | 2 | Face slimming. | 2335| SKIN_TONE | 3 | Skin tone perfection. | 2336 2337## ManualExposureQuery<sup>12+</sup> 2338 2339Provides APIs to obtain the manual exposure range supported. 2340 2341### getSupportedExposureRange<sup>12+</sup> 2342 2343getSupportedExposureRange(): Array\<number\> 2344 2345Obtains the supported manual exposure durations. 2346 2347**System API**: This is a system API. 2348 2349**System capability**: SystemCapability.Multimedia.Camera.Core 2350 2351**Return value** 2352 2353| Type | Description | 2354| ---------- | ----------------------------- | 2355| Array\<number\>| Array of manual exposure durations supported, in ms. | 2356 2357**Error codes** 2358 2359For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2360 2361| ID | Error Message | 2362| --------------- | --------------- | 2363| 202 | Not System Application. | 2364| 7400101 | Parameter missing or parameter type incorrect. | 2365| 7400103 | Session not config, only throw in session usage. | 2366 2367 **Example** 2368 2369```ts 2370function getSupportedExposureRange(nightPhotoSession: camera.NightPhotoSession): Array<number> { 2371 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2372 return exposureRange; 2373} 2374``` 2375 2376## ManualExposure<sup>11+</sup> 2377 2378ManualExposure extends [ManualExposureQuery](#manualexposurequery12) 2379 2380Provides APIs to obtain and set the exposure duration. 2381 2382### getExposure<sup>11+</sup> 2383 2384getExposure(): number 2385 2386Obtains the manual exposure duration in use. 2387 2388**System API**: This is a system API. 2389 2390**System capability**: SystemCapability.Multimedia.Camera.Core 2391 2392**Return value** 2393| Name | Type | Mandatory| Description | 2394| -------- | ------------------------------------------------- | ---- | --------------------- | 2395| value | number | Yes | Manual exposure duration, in ms. | 2396 2397**Error codes** 2398 2399For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2400 2401| ID | Error Message | 2402| --------------- | --------------- | 2403| 202 | Not System Application. | 2404| 7400101 | Parameter missing or parameter type incorrect. | 2405| 7400103 | Session not config. | 2406 2407**Example** 2408 2409```ts 2410function getExposure(nightPhotoSession: camera.NightPhotoSession): number | undefined { 2411 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2412 if (exposureRange === undefined || exposureRange.length <= 0) { 2413 return undefined; 2414 } 2415 let exposure: number = nightPhotoSession.getExposure(); 2416 return exposure; 2417} 2418``` 2419 2420### setExposure<sup>11+</sup> 2421 2422setExposure(exposure: number): void 2423 2424Sets the manual exposure duration, in ms. 2425 2426**System API**: This is a system API. 2427 2428**System capability**: SystemCapability.Multimedia.Camera.Core 2429 2430**Parameters** 2431 2432| Name | Type | Mandatory| Description | 2433| -------- | --------------------------| ---- |-------------------------------------------------------------------------| 2434| value | number | Yes | Manual exposure duration, which must be one of the supported durations obtained by running [getSupportedExposureRange](#getsupportedexposurerange12).| 2435 2436 **Error codes** 2437 2438| ID | Error Message | 2439| --------------- | --------------- | 2440| 202 | Not System Application. | 2441| 7400102 | Operation not allowed. | 2442| 7400103 | Session not config. | 2443 2444```ts 2445function setExposure(nightPhotoSession: camera.NightPhotoSession): void { 2446 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2447 if (exposureRange === undefined || exposureRange.length <= 0) { 2448 return; 2449 } 2450 nightPhotoSession.setExposure(exposureRange[0]); 2451} 2452``` 2453 2454## MacroQuery<sup>12+</sup> 2455 2456Provides the API to check the support for macro photography. 2457 2458### isMacroSupported<sup>12+</sup> 2459 2460isMacroSupported(): boolean 2461 2462Checks whether macro photography is supported in the current state. This API must be called after [commitConfig](js-apis-camera.md#commitconfig11-1). 2463 2464**System API**: This is a system API. 2465 2466**System capability**: SystemCapability.Multimedia.Camera.Core 2467 2468**Return value** 2469 2470| Type | Description | 2471| ---------- | ----------------------------- | 2472| boolean | **true**: Macro photography is supported.<br>**false**: Macro photography is not supported.| 2473 2474**Error codes** 2475 2476For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2477 2478| ID | Error Message | 2479|---------|--------------------------| 2480| 202 | Not System Application. | 2481 2482**Example** 2483 2484```ts 2485function isMacroSupported(photoSession: camera.PhotoSessionForSys): boolean { 2486 let isSupported: boolean = photoSession.isMacroSupported(); 2487 return isSupported; 2488} 2489``` 2490 2491## Macro<sup>11+</sup> 2492 2493Macro extends [MacroQuery](#macroquery12) 2494 2495Provides the API to enable macro photography. 2496 2497### enableMacro<sup>11+</sup> 2498 2499enableMacro(enabled: boolean): void 2500 2501Enables or disables macro photography. This API can be called only when macro photography is supported. 2502 2503**System API**: This is a system API. 2504 2505**System capability**: SystemCapability.Multimedia.Camera.Core 2506 2507**Parameters** 2508 2509| Name | Type | Mandatory| Description | 2510| -------- | -------------------- | ---- | -------------------- | 2511| enabled | boolean | Yes | Whether to enable macro photography. The value **true** means to enable macro photography, and **false** means to disable it.| 2512 2513**Error codes** 2514 2515For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2516 2517| ID | Error Message | 2518|----------|--------------------------| 2519| 202 | Not System Application. | 2520| 7400102 | Operation not allowed. | 2521| 7400103 | Session not config. | 2522 2523**Example** 2524 2525```ts 2526function enableMacro(photoSession: camera.PhotoSessionForSys): void { 2527 let isSupported: boolean = photoSession.isMacroSupported(); 2528 if (isSupported) { 2529 photoSession.enableMacro(true); 2530 } 2531} 2532``` 2533 2534## SceneFeatureType<sup>12+</sup> 2535 2536Enumerates the scene features. 2537 2538**System capability**: SystemCapability.Multimedia.Camera.Core 2539 2540| Name | Value | Description | 2541| ----------------------- | --------- | ------------ | 2542| MOON_CAPTURE_BOOST | 0 | Moon scene. **System API**: This is a system API. | 2543 2544## SceneFeatureDetectionResult<sup>12+</sup> 2545 2546Describes the scene feature detection result. 2547 2548**System capability**: SystemCapability.Multimedia.Camera.Core 2549 2550| Name | Type | Read-only | Mandatory | Description | 2551| -------- | ---------- | -------- | -------- | ---------- | 2552| featureType | [SceneFeatureType](#scenefeaturetype12) | Yes | Yes | Scene feature type. | 2553| detected | boolean | Yes | Yes | Detection result. The value **true** means that the specified scene feature is detected.| 2554 2555## SceneDetection<sup>12+</sup> 2556 2557Provides the scene detection capability. 2558 2559### isSceneFeatureSupported<sup>12+</sup> 2560 2561isSceneFeatureSupported(type: SceneFeatureType): boolean 2562 2563Checks whether a scene feature is supported. 2564 2565**System API**: This is a system API. 2566 2567**System capability**: SystemCapability.Multimedia.Camera.Core 2568 2569**Parameters** 2570 2571| Name | Type | Mandatory | Description | 2572|-------|-------------------------------------------|-----|-------------| 2573| type | [SceneFeatureType](#scenefeaturetype12) | Yes | Scene feature. | 2574 2575**Return value** 2576 2577| Type | Description | 2578|-----------|--------------| 2579| boolean | **true**: The scene feature is supported.<br>**false**: The scene feature is not supported. | 2580 2581**Error codes** 2582 2583For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2584 2585| ID | Error Message | 2586|---------|------------------------------------------------| 2587| 202 | Not System Application. | 2588| 7400101 | Parameter missing or parameter type incorrect. | 2589 2590**Example** 2591 2592```ts 2593function isSceneFeatureSupported(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): boolean { 2594 let isSupported: boolean = photoSession.isSceneFeatureSupported(featureType); 2595 return isSupported; 2596} 2597``` 2598 2599### enableSceneFeature<sup>12+</sup> 2600 2601enableSceneFeature(type: SceneFeatureType, enabled: boolean): void 2602 2603Enables or disables a scene feature. This API must be called after [SceneFeatureDetectionResult](#scenefeaturedetectionresult12) of the corresponding scene feature is received. 2604 2605**System API**: This is a system API. 2606 2607**System capability**: SystemCapability.Multimedia.Camera.Core 2608 2609**Parameters** 2610 2611| Name | Type | Mandatory | Description | 2612|---------|-------------------------------------------|-----|-----------------------------| 2613| type | [SceneFeatureType](#scenefeaturetype12) | Yes | Scene feature. | 2614| enabled | boolean | Yes | Whether to enable the scene feature. The value **true** means to enable the scene feature, and **false** means the opposite.| 2615 2616**Error codes** 2617 2618For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2619 2620| ID | Error Message | 2621|---------|------------------------------------------------| 2622| 202 | Not System Application. | 2623| 7400101 | Parameter missing or parameter type incorrect. | 2624 2625**Example** 2626 2627```ts 2628import { BusinessError } from '@kit.BasicServicesKit'; 2629 2630function enableSceneFeature(photoSession: camera.PhotoSessionForSys, cameraInput: camera.CameraInput, previewOutput: camera.PreviewOutput): void { 2631 photoSession.beginConfig(); 2632 photoSession.addInput(cameraInput); 2633 photoSession.addOutput(previewOutput); 2634 photoSession.commitConfig(); 2635 2636 photoSession.on('featureDetection', camera.SceneFeatureType.MOON_CAPTURE_BOOST, 2637 (err: BusinessError, statusObject: camera.SceneFeatureDetectionResult) => { 2638 if (err !== undefined && err.code !== 0) { 2639 console.error(`Callback Error, errorCode: ${err.code}`); 2640 return; 2641 } 2642 console.info( 2643 `on featureDetectionStatus featureType:${statusObject.featureType} detected:${statusObject.detected}`); 2644 if (statusObject.featureType === camera.SceneFeatureType.MOON_CAPTURE_BOOST) { 2645 try { 2646 photoSession.enableSceneFeature(statusObject.featureType, statusObject.detected); 2647 } catch (error) { 2648 let err = error as BusinessError; 2649 console.error(`The enableSceneFeature call failed. error code: ${err.code}`); 2650 } 2651 } 2652 }); 2653} 2654``` 2655 2656## ZoomPointInfo<sup>12+</sup> 2657 2658Describes the equivalent focal length information. 2659 2660**System API**: This is a system API. 2661 2662**System capability**: SystemCapability.Multimedia.Camera.Core 2663 2664| Name | Type | Read-only | Optional | Description | 2665| -------- | ---------- | -------- |-----| ---------- | 2666| zoomRatio | number | Yes | No | Zoom ratio.| 2667| equivalentFocalLength | number | Yes | No | Equivalent focal length corresponding to the current focal length ratio.| 2668 2669## ZoomQuery<sup>12+</sup> 2670 2671Provides the API to obtain the equivalent focal length information list in the current mode. 2672 2673### getZoomPointInfos<sup>12+</sup> 2674 2675getZoomPointInfos(): Array\<ZoomPointInfo\> 2676 2677Obtains the equivalent focal length information list in the current mode. 2678 2679**System API**: This is a system API. 2680 2681**System capability**: SystemCapability.Multimedia.Camera.Core 2682 2683**Return value** 2684 2685| Type | Description | 2686| ---------- | ----------------------------- | 2687| Array\<[ZoomPointInfo](#zoompointinfo12)\>| Equivalent focal length information list in the current mode. | 2688 2689**Error codes** 2690 2691For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2692 2693| ID | Error Message | 2694| --------------- | --------------- | 2695| 202 | Not System Application. | 2696| 7400103 | Session not config. | 2697 2698**Example** 2699 2700```ts 2701import { BusinessError } from '@kit.BasicServicesKit'; 2702 2703function getZoomPointInfos(): Array<ZoomPointInfo> { 2704 try { 2705 let zoomPointInfos: Array<ZoomPointInfo> = sessionExtendsZoom.getZoomPointInfos(); 2706 return zoomPointInfos; 2707 } catch (error) { 2708 // If the operation fails, error.code is returned and processed. 2709 let err = error as BusinessError; 2710 console.error(`The getZoomPointInfos call failed. error code: ${err.code}`); 2711 } 2712} 2713``` 2714 2715## Zoom<sup>11+</sup> 2716 2717Zoom extend [ZoomQuery](#zoomquery12) 2718 2719Provides APIs to process the zoom effect of a camera device, including obtaining the current zoom ratio, setting a zoom ratio, setting a zoom ratio in a smooth manner, and preparing or unpreparing for zooming. 2720 2721### prepareZoom<sup>11+</sup> 2722 2723prepareZoom(): void 2724 2725Instructs the bottom layer to prepare for zooming, for example, powering on the sensor. 2726 2727**System API**: This is a system API. 2728 2729**System capability**: SystemCapability.Multimedia.Camera.Core 2730 2731**Error codes** 2732 2733For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2734 2735| ID | Error Message | 2736| --------------- | --------------- | 2737| 202 | Not System Application. | 2738| 7400103 | Session not config. | 2739 2740**Example** 2741 2742```ts 2743import { BusinessError } from '@kit.BasicServicesKit'; 2744 2745function prepareZoom(sessionExtendsZoom: camera.Zoom): void { 2746 try { 2747 sessionExtendsZoom.prepareZoom(); 2748 } catch (error) { 2749 // If the operation fails, error.code is returned and processed. 2750 let err = error as BusinessError; 2751 console.error(`The prepareZoom call failed. error code: ${err.code}`); 2752 } 2753} 2754``` 2755 2756### unprepareZoom<sup>11+</sup> 2757 2758unprepareZoom(): void 2759 2760Instructs the bottom layer to unprepare for zooming. 2761 2762**System API**: This is a system API. 2763 2764**System capability**: SystemCapability.Multimedia.Camera.Core 2765 2766**Error codes** 2767 2768For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2769 2770| ID | Error Message | 2771| --------------- | --------------- | 2772| 202 | Not System Application. | 2773| 7400103 | Session not config. | 2774 2775**Example** 2776 2777```ts 2778import { BusinessError } from '@kit.BasicServicesKit'; 2779 2780function unprepareZoom(sessionExtendsZoom: camera.Zoom): void { 2781 try { 2782 sessionExtendsZoom.unprepareZoom(); 2783 } catch (error) { 2784 // If the operation fails, error.code is returned and processed. 2785 let err = error as BusinessError; 2786 console.error(`The unprepareZoom call failed. error code: ${err.code}`); 2787 } 2788} 2789``` 2790 2791## ZoomRange<sup>11+</sup> 2792 2793Obtains the supported zoom ratio range. The range is [min, max), which includes the minimum value but excludes the maximum value. 2794 2795**System API**: This is a system API. 2796 2797**System capability**: SystemCapability.Multimedia.Camera.Core 2798 2799| Name | Type | Read-only| Mandatory| Description | 2800| -------- | ------------- |---- | ---- | -------------| 2801| min | number | Yes | N/A | Minimum value of the zoom ratio range. | 2802| max | number | Yes | N/A | Maximum value of the zoom ratio range.| 2803 2804## Beauty<sup>11+</sup> 2805 2806Beauty extends [BeautyQuery](#beautyquery12) 2807 2808Provides APIs to obtain and set the beauty effect. 2809 2810### setBeauty<sup>11+</sup> 2811 2812setBeauty(type: BeautyType, value: number): void 2813 2814Sets a beauty type and its level. Beauty mode is turned off only when all the [beauty types](#beautytype) obtained through [getSupportedBeautyTypes](#getsupportedbeautytypes12) are disabled. 2815 2816**System API**: This is a system API. 2817 2818**System capability**: SystemCapability.Multimedia.Camera.Core 2819 2820**Parameters** 2821 2822| Name | Type | Mandatory| Description | 2823| -------- | --------------------------| ---- |-------------------------------------------------------------------| 2824| type | [BeautyType](#beautytype) | Yes | Beauty type. | 2825| value | number | Yes | Beauty level, which is obtained through [getSupportedBeautyRange](#getsupportedbeautyrange12).| 2826 2827**Error codes** 2828 2829For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2830 2831| ID | Error Message | 2832| --------------- | --------------- | 2833| 202 | Not System Application. | 2834| 7400103 | Session not config. | 2835 2836**Example** 2837 2838```ts 2839function setBeauty(portraitPhotoSession: camera.PortraitPhotoSession): void { 2840 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2841 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2842 return; 2843 } 2844 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2845 if (beautyLevels === undefined || beautyLevels.length <= 0) { 2846 return; 2847 } 2848 portraitPhotoSession.setBeauty(beautyTypes[0], beautyLevels[0]); 2849} 2850``` 2851 2852### getBeauty<sup>11+</sup> 2853 2854getBeauty(type: BeautyType): number 2855 2856Obtains the level of the beauty type in use. 2857 2858**System API**: This is a system API. 2859 2860**System capability**: SystemCapability.Multimedia.Camera.Core 2861 2862**Parameters** 2863 2864| Name | Type | Mandatory| Description | 2865| -------- | ------------------------------------------------- | ---- | --------------------- | 2866| type | [BeautyType](#beautytype) | Yes | Beauty type. | 2867 2868**Return value** 2869| Name | Type | Mandatory| Description | 2870| -------- | ------------------------------------------------- | ---- | --------------------- | 2871| value | number | Yes | Beauty level. | 2872 2873**Error codes** 2874 2875For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2876 2877| ID | Error Message | 2878| --------------- | --------------- | 2879| 202 | Not System Application. | 2880| 7400103 | Session not config. | 2881 2882**Example** 2883 2884```ts 2885function getBeauty(portraitPhotoSession: camera.PortraitPhotoSession): number { 2886 const invalidValue: number = -1; 2887 let beautyTypes = portraitPhotoSession.getSupportedBeautyTypes(); 2888 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2889 return invalidValue; 2890 } 2891 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2892 if (beautyLevels === undefined || beautyLevels.length <= 0) { 2893 return invalidValue; 2894 } 2895 portraitPhotoSession.setBeauty(beautyTypes[0], beautyLevels[0]); 2896 let beautyLevel: number = portraitPhotoSession.getBeauty(beautyTypes[0]); 2897 return beautyLevel; 2898} 2899``` 2900 2901## ColorEffectQuery<sup>12+</sup> 2902 2903Provides the API to obtain the color effects supported. 2904 2905### getSupportedColorEffects<sup>12+</sup> 2906 2907getSupportedColorEffects(): Array\<ColorEffectType\> 2908 2909Obtains the supported color effects. 2910 2911**System API**: This is a system API. 2912 2913**System capability**: SystemCapability.Multimedia.Camera.Core 2914 2915**Return value** 2916 2917| Type | Description | 2918| ----------------------------------------------- | ---------------------------- | 2919| Array<[ColorEffectType](#coloreffecttype11)> | Array of color effects supported. | 2920 2921**Error codes** 2922 2923For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2924 2925| ID | Error Message | 2926| --------------- | --------------- | 2927| 7400103 | Session not config. | 2928| 202 | Not System Application. | 2929 2930**Example** 2931 2932```ts 2933function getSupportedColorEffects(session: camera.PhotoSessionForSys): Array<camera.ColorEffectType> { 2934 let colorEffects: Array<camera.ColorEffectType> = session.getSupportedColorEffects(); 2935 return colorEffects; 2936} 2937``` 2938 2939## ColorEffect<sup>11+</sup> 2940 2941ColorEffect extends [ColorEffectQuery](#coloreffectquery12) 2942 2943Provides the APIs to obtain and set the lens color effect. 2944 2945### setColorEffect<sup>11+</sup> 2946 2947setColorEffect(type: ColorEffectType): void 2948 2949Sets a color effect. Before the setting, call [getSupportedColorEffects](#getsupportedcoloreffects12) to obtain the supported color effects. 2950 2951**System API**: This is a system API. 2952 2953**System capability**: SystemCapability.Multimedia.Camera.Core 2954 2955**Parameters** 2956 2957| Name | Type | Mandatory| Description | 2958| ------------ |--------------------------------------------------------------- | -- | -------------------------- | 2959| type | [ColorEffectType](#coloreffecttype11) | Yes| Color effect, which can be obtained through [getSupportedColorEffects](#getsupportedcoloreffects12). | 2960 2961**Error codes** 2962 2963For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2964 2965| ID | Error Message | 2966| --------------- | --------------- | 2967| 7400103 | Session not config. | 2968| 202 | Not System Application. | 2969 2970**Example** 2971 2972```ts 2973function setColorEffect(session: camera.PhotoSessionForSys, colorEffect: camera.ColorEffectType): void { 2974 session.setColorEffect(colorEffect); 2975} 2976``` 2977 2978### getColorEffect<sup>11+</sup> 2979 2980getColorEffect(): ColorEffectType 2981 2982Obtains the color effect in use. 2983 2984**System API**: This is a system API. 2985 2986**System capability**: SystemCapability.Multimedia.Camera.Core 2987 2988**Return value** 2989 2990| Type | Description | 2991| ----------------------------------------------- | ---------------------------- | 2992| [ColorEffectType](#coloreffecttype11) | Color effect. | 2993 2994**Error codes** 2995 2996For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2997 2998| ID | Error Message | 2999| --------------- | --------------- | 3000| 7400103 | Session not config. | 3001| 202 | Not System Application. | 3002 3003**Example** 3004 3005```ts 3006function getColorEffect(session: camera.PhotoSessionForSys): camera.ColorEffectType { 3007 let colorEffect: camera.ColorEffectType = session.getColorEffect(); 3008 return colorEffect; 3009} 3010``` 3011 3012## ColorEffectType<sup>11+</sup> 3013 3014Enumerates the color effect types. 3015 3016**System API**: This is a system API. 3017 3018**System capability**: SystemCapability.Multimedia.Camera.Core 3019 3020| Name | Value | Description | 3021| --------------------- | ---- | --------- | 3022| NORMAL | 0 | Regular color effect. | 3023| BRIGHT | 1 | Bright color effect. | 3024| SOFT | 2 | Soft color effect. | 3025| BLACK_WHITE<sup>12+</sup> | 3 | Black and white color effect. | 3026 3027## Portrait<sup>11+</sup> 3028 3029Provides the APIs for portrait photo settings. 3030 3031### getSupportedPortraitEffects<sup>10+</sup> 3032 3033getSupportedPortraitEffects(): Array\<PortraitEffect\> 3034 3035Obtains the supported portrait effects. 3036 3037**System API**: This is a system API. 3038 3039**System capability**: SystemCapability.Multimedia.Camera.Core 3040 3041**Return value** 3042 3043| Type | Description | 3044| ----------------------------------------------- | ---------------------------- | 3045| Array<[PortraitEffect](#portraiteffect)> | Array of portrait effects supported. | 3046 3047**Error codes** 3048 3049For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3050 3051| ID | Error Message | 3052| --------------- | --------------- | 3053| 7400103 | Session not config. | 3054| 202 | Not System Application. | 3055 3056**Example** 3057 3058```ts 3059function getSupportedPortraitEffects(portraitPhotoSession: camera.PortraitPhotoSession): Array<camera.PortraitEffect> { 3060 let portraitEffects: Array<camera.PortraitEffect> = portraitPhotoSession.getSupportedPortraitEffects(); 3061 return portraitEffects; 3062} 3063``` 3064 3065### setPortraitEffect<sup>10+</sup> 3066 3067setPortraitEffect(effect: PortraitEffect): void 3068 3069Sets a portrait effect. Before the setting, call [getSupportedPortraitEffects](#getsupportedportraiteffects10) to obtain the supported portrait effects and check whether the target portrait effect is supported. 3070 3071**System API**: This is a system API. 3072 3073**System capability**: SystemCapability.Multimedia.Camera.Core 3074 3075**Parameters** 3076 3077| Name | Type | Mandatory| Description | 3078| ------------ |----------------------------- | -- | -------------------------- | 3079| effect | [PortraitEffect](#portraiteffect) | Yes| Portrait effect, which can be obtained through [getSupportedPortraitEffects](#getsupportedportraiteffects10). | 3080 3081**Error codes** 3082 3083For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3084 3085| ID | Error Message | 3086| --------------- | --------------- | 3087| 7400103 | Session not config. | 3088| 202 | Not System Application. | 3089 3090**Example** 3091 3092```ts 3093import { BusinessError } from '@kit.BasicServicesKit'; 3094 3095function setPortraitEffect(portraitPhotoSession: camera.PortraitPhotoSession, portraitEffects: Array<camera.PortraitEffect>): void { 3096 if (portraitEffects === undefined || portraitEffects.length <= 0) { 3097 return; 3098 } 3099 try { 3100 portraitPhotoSession.setPortraitEffect(portraitEffects[0]); 3101 } catch (error) { 3102 let err = error as BusinessError; 3103 console.error(`The setPortraitEffect call failed. error code: ${err.code}`); 3104 } 3105} 3106``` 3107 3108### getPortraitEffect<sup>10+</sup> 3109 3110getPortraitEffect(): PortraitEffect 3111 3112Obtains the portrait effect in use. 3113 3114**System API**: This is a system API. 3115 3116**System capability**: SystemCapability.Multimedia.Camera.Core 3117 3118**Return value** 3119 3120| Type | Description | 3121| ----------------------------------------------- | ---------------------------- | 3122| [PortraitEffect](#portraiteffect) | Portrait effect. | 3123 3124**Error codes** 3125 3126For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3127 3128| ID | Error Message | 3129| --------------- | --------------- | 3130| 7400103 | Session not config. | 3131| 202 | Not System Application. | 3132 3133**Example** 3134 3135```ts 3136function getPortraitEffect(portraitPhotoSession: camera.PortraitPhotoSession): camera.PortraitEffect { 3137 let portraitEffect: camera.PortraitEffect = portraitPhotoSession.getPortraitEffect(); 3138 return portraitEffect; 3139} 3140``` 3141 3142## PhysicalAperture<sup>11+</sup> 3143 3144Defines the physical aperture information. 3145 3146**System API**: This is a system API. 3147 3148**System capability**: SystemCapability.Multimedia.Camera.Core 3149 3150| Name | Type | Read-only| Optional | Description | 3151| ---------- | ------------------------- | ----- |-----| ----------------- | 3152| zoomRange | [ZoomRange](#zoomrange11) | No | No | Zoom range of a given physical aperture. | 3153| apertures | Array\<number\> | No | No | Array of physical apertures supported. | 3154 3155## Aperture<sup>11+</sup> 3156 3157Provides the APIs for aperture settings. 3158 3159### getSupportedVirtualApertures<sup>11+</sup> 3160 3161getSupportedVirtualApertures(): Array\<number\> 3162 3163Obtains the supported virtual apertures. 3164 3165**System API**: This is a system API. 3166 3167**System capability**: SystemCapability.Multimedia.Camera.Core 3168 3169**Return value** 3170 3171| Type | Description | 3172| ----------------------------------------------- | ---------------------------- | 3173| Array\<number\> | Array of virtual apertures supported. | 3174 3175**Error codes** 3176 3177For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3178 3179| ID | Error Message | 3180| --------------- | --------------- | 3181| 7400103 | Session not config. | 3182| 202 | Not System Application. | 3183 3184**Example** 3185 3186```ts 3187function getSupportedVirtualApertures(session: camera.PortraitPhotoSession): Array<number> { 3188 let virtualApertures: Array<number> = session.getSupportedVirtualApertures(); 3189 return virtualApertures; 3190} 3191``` 3192 3193### getVirtualAperture<sup>11+</sup> 3194 3195getVirtualAperture(): number 3196 3197Obtains the virtual aperture in use. 3198 3199**System API**: This is a system API. 3200 3201**System capability**: SystemCapability.Multimedia.Camera.Core 3202 3203**Return value** 3204 3205| Type | Description | 3206| ----------------------------------------------- | ---------------------------- | 3207| number | Virtual aperture. | 3208 3209**Error codes** 3210 3211For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3212 3213| ID | Error Message | 3214| --------------- | --------------- | 3215| 7400103 | Session not config. | 3216| 202 | Not System Application. | 3217 3218**Example** 3219 3220```ts 3221function getVirtualAperture(session: camera.PortraitPhotoSession): number { 3222 let virtualAperture: number = session.getVirtualAperture(); 3223 return virtualAperture; 3224} 3225``` 3226 3227### setVirtualAperture<sup>11+</sup> 3228 3229setVirtualAperture(aperture: number): void 3230 3231Sets a virtual aperture. Before the setting, call [getSupportedVirtualApertures](#getsupportedvirtualapertures11) to obtain the supported virtual apertures. 3232 3233**System API**: This is a system API. 3234 3235**System capability**: SystemCapability.Multimedia.Camera.Core 3236 3237**Parameters** 3238 3239| Name | Type | Mandatory| Description | 3240| ------------ |------------------------- | -- | -------------------------- | 3241| aperture | number | Yes| Virtual aperture, which can be obtained by calling [getSupportedVirtualApertures](#getsupportedvirtualapertures11). | 3242 3243**Error codes** 3244 3245For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3246 3247| ID | Error Message | 3248| --------------- | --------------- | 3249| 7400103 | Session not config. | 3250| 202 | Not System Application. | 3251 3252**Example** 3253 3254```ts 3255function setVirtualAperture(session: camera.PortraitPhotoSession, virtualAperture: number): void { 3256 session.setVirtualAperture(virtualAperture); 3257} 3258``` 3259 3260### getSupportedPhysicalApertures<sup>11+</sup> 3261 3262getSupportedPhysicalApertures(): Array\<PhysicalAperture\> 3263 3264Obtains the supported physical apertures. 3265 3266**System API**: This is a system API. 3267 3268**System capability**: SystemCapability.Multimedia.Camera.Core 3269 3270**Return value** 3271 3272| Type | Description | 3273| ----------------------------------------------- | ---------------------------- | 3274| Array<[PhysicalAperture](#physicalaperture11)> | Array of physical apertures supported. | 3275 3276**Error codes** 3277 3278For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3279 3280| ID | Error Message | 3281| --------------- | --------------- | 3282| 7400103 | Session not config. | 3283| 202 | Not System Application. | 3284 3285**Example** 3286 3287```ts 3288function getSupportedPhysicalApertures(session: camera.PortraitPhotoSession): Array<camera.PhysicalAperture> { 3289 let physicalApertures: Array<camera.PhysicalAperture> = session.getSupportedPhysicalApertures(); 3290 return physicalApertures; 3291} 3292``` 3293 3294### getPhysicalAperture<sup>11+</sup> 3295 3296getPhysicalAperture(): number 3297 3298Obtains the physical aperture in use. 3299 3300**System API**: This is a system API. 3301 3302**System capability**: SystemCapability.Multimedia.Camera.Core 3303 3304**Return value** 3305 3306| Type | Description | 3307| -------------------- | ---------------------------- | 3308| number | Physical aperture. | 3309 3310**Error codes** 3311 3312For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3313 3314| ID | Error Message | 3315| --------------- | --------------- | 3316| 7400103 | Session not config. | 3317| 202 | Not System Application. | 3318 3319**Example** 3320 3321```ts 3322function getPhysicalAperture(session: camera.PortraitPhotoSession): number { 3323 let physicalAperture: number = session.getPhysicalAperture(); 3324 return physicalAperture; 3325} 3326``` 3327 3328### setPhysicalAperture<sup>11+</sup> 3329 3330setPhysicalAperture(aperture: number): void 3331 3332Sets a physical aperture. Before the setting, call [getSupportedPhysicalApertures](#getsupportedphysicalapertures11) to obtain the supported physical apertures. 3333 3334**System API**: This is a system API. 3335 3336**System capability**: SystemCapability.Multimedia.Camera.Core 3337 3338**Parameters** 3339 3340| Name | Type | Mandatory| Description | 3341| ------------ |------------------------- | -- | -------------------------- | 3342| aperture | number | Yes| Physical aperture, which can be obtained by calling [getSupportedPhysicalApertures](#getsupportedphysicalapertures11). | 3343 3344**Error codes** 3345 3346For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3347 3348| ID | Error Message | 3349| --------------- | --------------- | 3350| 7400103 | Session not config. | 3351| 202 | Not System Application. | 3352 3353**Example** 3354 3355```ts 3356function setPhysicalAperture(session: camera.PortraitPhotoSession, physicalAperture: number): void { 3357 session.setPhysicalAperture(physicalAperture); 3358} 3359``` 3360 3361## CaptureSession<sup>(deprecated)</sup> 3362 3363Implements a capture session, which saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera and requests the camera to complete shooting or video recording. 3364 3365> **NOTE** 3366> 3367> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [PhotoSession](#photosession11) and [VideoSession](#videosession11) instead. 3368 3369### getSupportedBeautyTypes<sup>(deprecated)</sup> 3370 3371getSupportedBeautyTypes(): Array\<BeautyType> 3372 3373Obtains the supported beauty types. 3374 3375> **NOTE** 3376> 3377> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Beauty.getSupportedBeautyTypes](#getsupportedbeautytypes12) instead. 3378 3379**System API**: This is a system API. 3380 3381**System capability**: SystemCapability.Multimedia.Camera.Core 3382 3383**Return value** 3384 3385| Type | Description | 3386| ---------- | ----------------------------- | 3387| Array\<[BeautyType](#beautytype)\>| Array of beauty types supported. | 3388 3389**Error codes** 3390 3391For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3392 3393| ID | Error Message | 3394| --------------- | --------------- | 3395| 7400103 | Session not config. | 3396 3397**Example** 3398 3399```ts 3400function getSupportedBeautyTypes(captureSession: camera.CaptureSession): Array<camera.BeautyType> { 3401 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3402 return beautyTypes; 3403} 3404``` 3405 3406### getSupportedBeautyRange<sup>(deprecated)</sup> 3407 3408getSupportedBeautyRange(type: BeautyType): Array\<number\> 3409 3410Obtains the levels that can be set a beauty type. The beauty levels vary according to the device type. The following table is only an example. 3411 3412| Input Parameter | Example Return Value | Return Value Description | 3413| ----------------| ---- | ---------| 3414| AUTO | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |Beauty levels supported when **type** is set to **AUTO**. The value **0** means that beauty mode is disabled, and other positive values mean the corresponding automatic beauty levels. | 3415| SKIN_SMOOTH | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | Beauty levels supported when **type** is set to **SKIN_SMOOTH**. The value **0** means that the skin smoothing feature is disabled, and other positive values mean the corresponding skin smoothing levels. | 3416| FACE_SLENDER | [0, 1, 2, 3, 4, 5] | Beauty levels supported when **type** is set to **FACE_SLENDER**. The value **0** means that the face slimming feature is disabled, and other positive values mean the corresponding face slimming levels. | 3417| SKIN_TONE | [-1, 16242611] | Beauty levels supported when **type** is set to **SKIN_TONE**. The value **-1** means that the skin tone perfection feature is disabled. Other non-negative values mean the skin tone perfection levels represented by RGB,<br> for example, 16242611, which is 0xF7D7B3 in hexadecimal format, where F7, D7, and B3 represent the values of the R channel, G channel, and B channel, respectively. | 3418 3419> **NOTE** 3420> 3421> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Beauty.getSupportedBeautyRange](#getsupportedbeautyrange12) instead. 3422 3423**System API**: This is a system API. 3424 3425**System capability**: SystemCapability.Multimedia.Camera.Core 3426 3427**Parameters** 3428 3429| Name | Type | Mandatory| Description | 3430| -------- | --------------------------| ---- | ----------| 3431| type | [BeautyType](#beautytype) | Yes | Beauty type. | 3432 3433**Return value** 3434 3435| Type | Description | 3436| ---------- | ----------------------------- | 3437| Array\<number\> | Array of levels supported.| 3438 3439**Error codes** 3440 3441For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3442 3443| ID | Error Message | 3444| --------------- | --------------- | 3445| 7400103 | Session not config. | 3446 3447**Example** 3448 3449```ts 3450function getSupportedBeautyRange(captureSession: camera.CaptureSession): Array<number> { 3451 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3452 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3453 return []; 3454 } 3455 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3456 return beautyLevels; 3457} 3458``` 3459 3460### setBeauty<sup>(deprecated)</sup> 3461 3462setBeauty(type: BeautyType, value: number): void 3463 3464Sets a beauty type and its level. Beauty mode is turned off only when all the [beauty types](#beautytype) obtained through [getSupportedBeautyTypes](#getsupportedbeautytypesdeprecated) are disabled. 3465 3466> **NOTE** 3467> 3468> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Beauty.setBeauty](#setbeauty11) instead. 3469 3470**System API**: This is a system API. 3471 3472**System capability**: SystemCapability.Multimedia.Camera.Core 3473 3474**Parameters** 3475 3476| Name | Type | Mandatory| Description | 3477| -------- | --------------------------| ---- | --------------------- | 3478| type | [BeautyType](#beautytype) | Yes | Beauty type. | 3479| value | number | Yes | Beauty level, which is obtained through [getSupportedBeautyRange](#getsupportedbeautyrangedeprecated).| 3480 3481**Error codes** 3482 3483For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3484 3485| ID | Error Message | 3486| --------------- | --------------- | 3487| 7400103 | Session not config. | 3488 3489**Example** 3490 3491```ts 3492function setBeauty(captureSession: camera.CaptureSession): void { 3493 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3494 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3495 return; 3496 } 3497 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3498 if (beautyLevels === undefined || beautyLevels.length <= 0) { 3499 return; 3500 } 3501 captureSession.setBeauty(beautyTypes[0], beautyLevels[0]); 3502} 3503``` 3504 3505### getBeauty<sup>(deprecated)</sup> 3506 3507getBeauty(type: BeautyType): number 3508 3509Obtains the level of the beauty type in use. 3510 3511> **NOTE** 3512> 3513> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Beauty.getBeauty](#getbeauty11) instead. 3514 3515**System API**: This is a system API. 3516 3517**System capability**: SystemCapability.Multimedia.Camera.Core 3518 3519**Parameters** 3520 3521| Name | Type | Mandatory| Description | 3522| -------- | ------------------------------------------------- | ---- | --------------------- | 3523| type | [BeautyType](#beautytype) | Yes | Beauty type. | 3524 3525**Return value** 3526| Name | Type | Mandatory| Description | 3527| -------- | ------------------------------------------------- | ---- | --------------------- | 3528| value | number | Yes | Beauty level. | 3529 3530**Error codes** 3531 3532For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3533 3534| ID | Error Message | 3535| --------------- | --------------- | 3536| 7400103 | Session not config. | 3537 3538**Example** 3539 3540```ts 3541function getBeauty(captureSession: camera.CaptureSession): number { 3542 const invalidValue: number = -1; 3543 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3544 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3545 return invalidValue; 3546 } 3547 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3548 if (beautyLevels === undefined || beautyLevels.length <= 0) { 3549 return invalidValue; 3550 } 3551 captureSession.setBeauty(beautyTypes[0], beautyLevels[0]); 3552 let beautyLevel: number = captureSession.getBeauty(beautyTypes[0]); 3553 return beautyLevel; 3554} 3555``` 3556 3557## PhotoSessionForSys<sup>11+</sup> 3558 3559PhotoSessionForSys extends PhotoSession, Beauty, ColorEffect, ColorManagement, Macro, SceneDetection 3560 3561Implements a photo session for system applications, which sets the parameters of the normal photo mode and saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera. It inherits from [Session](js-apis-camera.md#session11). 3562 3563**System API**: This is a system API. 3564 3565**System capability**: SystemCapability.Multimedia.Camera.Core 3566 3567## PhotoSession<sup>11+</sup> 3568 3569PhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorManagement 3570 3571Implements a photo session, which sets the parameters of the normal photo mode and saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera. It inherits from [Session](js-apis-camera.md#session11). 3572 3573### on('macroStatusChanged')<sup>11+</sup> 3574 3575on(type: 'macroStatusChanged', callback: AsyncCallback\<boolean\>): void 3576 3577Subscribes to macro state change events. This API uses an asynchronous callback to return the result. 3578 3579**System API**: This is a system API. 3580 3581**System capability**: SystemCapability.Multimedia.Camera.Core 3582 3583**Parameters** 3584 3585| Name | Type | Mandatory| Description | 3586| -------- | ----------------------------------------- | ---- | ------------------------ | 3587| type | string | Yes | Event type. The value is fixed at **'macroStatusChanged'**. The event can be listened for when a session is created.| 3588| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the macro state change. | 3589 3590**Error codes** 3591 3592For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3593 3594| ID| Error Message | 3595|-------|---------------------------| 3596| 202 | Not System Application. | 3597 3598**Example** 3599 3600```ts 3601import { BusinessError } from '@kit.BasicServicesKit'; 3602 3603function callback(err: BusinessError, macroStatus: boolean): void { 3604 if (err !== undefined && err.code !== 0) { 3605 console.error(`Callback Error, errorCode: ${err.code}`); 3606 return; 3607 } 3608 console.info(`Macro state: ${macroStatus}`); 3609} 3610 3611function registerMacroStatusChanged(photoSession: camera.PhotoSession): void { 3612 photoSession.on('macroStatusChanged', callback); 3613} 3614``` 3615 3616### off('macroStatusChanged')<sup>11+</sup> 3617 3618off(type: 'macroStatusChanged', callback?: AsyncCallback\<boolean\>): void 3619 3620Unsubscribes from macro state change events. 3621 3622**System API**: This is a system API. 3623 3624**System capability**: SystemCapability.Multimedia.Camera.Core 3625 3626**Parameters** 3627 3628| Name | Type | Mandatory| Description | 3629| -------- | ------------------------ | ---- | ------------------------ | 3630| type | string | Yes | Event type. The value is fixed at **'macroStatusChanged'**. The event can be listened for when a session is created.| 3631| callback | AsyncCallback\<boolean\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('macroStatusChanged')** with the specified callback is canceled. (The callback object cannot be an anonymous function.)| 3632 3633**Error codes** 3634 3635For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3636 3637| ID| Error Message | 3638|-------|---------------------------| 3639| 202 | Not System Application. | 3640 3641**Example** 3642 3643```ts 3644function unregisterMacroStatusChanged(photoSession: camera.PhotoSession): void { 3645 photoSession.off('macroStatusChanged'); 3646} 3647``` 3648 3649### on('featureDetection')<sup>12+</sup> 3650 3651on(type: 'featureDetection', featureType: SceneFeatureType, callback: AsyncCallback\<SceneFeatureDetectionResult\>): void 3652 3653Subscribe to scene feature detection status change events. This API uses an asynchronous callback to return the result. 3654 3655**System API**: This is a system API. 3656 3657**System capability**: SystemCapability.Multimedia.Camera.Core 3658 3659**Parameters** 3660 3661| Name | Type | Mandatory| Description | 3662| -------- | ----------------------------------------- | ---- | ------------------------ | 3663| type | string | Yes | Event type. The value is fixed at **'featureDetection'**. The event can be listened for when a photo session is created.| 3664| featureType | [SceneFeatureType](#scenefeaturetype12) | Yes | Scene feature type.| 3665| callback | AsyncCallback\<[SceneFeatureDetectionResult](#scenefeaturedetectionresult12)\> | Yes | Callback used to return the status of the scene feature detection. | 3666 3667**Error codes** 3668 3669For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3670 3671| ID| Error Message | 3672|-------|---------------------------| 3673| 202 | Not System Application. | 3674 3675**Example** 3676 3677```ts 3678import { BusinessError } from '@kit.BasicServicesKit'; 3679 3680function callback(err: BusinessError, result: camera.SceneFeatureDetectionResult): void { 3681 if (err !== undefined && err.code !== 0) { 3682 console.error(`Callback Error, errorCode: ${err.code}`); 3683 return; 3684 } 3685 console.info(`feature type: ${result.featureType}`); 3686 console.info(`feature status: ${result.detected}`); 3687} 3688 3689function registerFeatureDetectionStatus(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): void { 3690 photoSession.on('featureDetection', featureType, callback); 3691} 3692``` 3693 3694### off('featureDetection')<sup>12+</sup> 3695 3696off(type: 'featureDetection', featureType: SceneFeatureType, callback?: AsyncCallback\<SceneFeatureDetectionResult\>): void 3697 3698Unsubscribe from camera feature detection status change events. 3699 3700**System API**: This is a system API. 3701 3702**System capability**: SystemCapability.Multimedia.Camera.Core 3703 3704**Parameters** 3705 3706| Name | Type | Mandatory| Description | 3707| -------- | ------------------------ | ---- | ------------------------ | 3708| type | string | Yes | Event type. The value is fixed at **'featureDetection'**. The event can be listened for when a session is created.| 3709| featureType | [SceneFeatureType](#scenefeaturetype12) | Yes | Scene feature type.| 3710| callback | AsyncCallback\<[SceneFeatureDetectionResult](#scenefeaturedetectionresult12)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('featureDetection')** with the specified callback is canceled. (The callback object cannot be an anonymous function.)| 3711 3712**Error codes** 3713 3714For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3715 3716| ID| Error Message | 3717|-------|---------------------------| 3718| 202 | Not System Application. | 3719 3720**Example** 3721 3722```ts 3723function unregisterFeatureDetectionStatus(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): void { 3724 photoSession.off('featureDetection', featureType); 3725} 3726``` 3727 3728## VideoSessionForSys<sup>11+</sup> 3729 3730VideoSessionForSys extends VideoSession, Beauty, ColorEffect, ColorManagement, Macro 3731 3732Implements a video session for system applications, which sets the parameters of the normal video mode and saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera. It inherits from [Session](js-apis-camera.md#session11). 3733 3734**System API**: This is a system API. 3735 3736**System capability**: SystemCapability.Multimedia.Camera.Core 3737 3738## VideoSession<sup>11+</sup> 3739 3740VideoSession extends Session, Flash, AutoExposure, Focus, Zoom, Stabilization, ColorManagement 3741 3742Implements a video session, which sets the parameters of the normal video mode and saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera. It inherits from [Session](js-apis-camera.md#session11). 3743 3744### on('macroStatusChanged')<sup>11+</sup> 3745 3746on(type: 'macroStatusChanged', callback: AsyncCallback\<boolean\>): void 3747 3748Subscribes to macro state change events. This API uses an asynchronous callback to return the result. 3749 3750**System API**: This is a system API. 3751 3752**System capability**: SystemCapability.Multimedia.Camera.Core 3753 3754**Parameters** 3755 3756| Name | Type | Mandatory| Description | 3757| -------- | ----------------------------------------- | ---- | ------------------------ | 3758| type | string | Yes | Event type. The value is fixed at **'macroStatusChanged'**. The event can be listened for when a session is created.| 3759| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the macro state change. | 3760 3761**Error codes** 3762 3763For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3764 3765| ID| Error Message | 3766|-------|---------------------------| 3767| 202 | Not System Application. | 3768 3769**Example** 3770 3771```ts 3772import { BusinessError } from '@kit.BasicServicesKit'; 3773 3774function callback(err: BusinessError, macroStatus: boolean): void { 3775 if (err !== undefined && err.code !== 0) { 3776 console.error(`Callback Error, errorCode: ${err.code}`); 3777 return; 3778 } 3779 console.info(`Macro state: ${macroStatus}`); 3780} 3781 3782function registerMacroStatusChanged(videoSession: camera.VideoSession): void { 3783 videoSession.on('macroStatusChanged', callback); 3784} 3785``` 3786 3787### off('macroStatusChanged')<sup>11+</sup> 3788 3789off(type: 'macroStatusChanged', callback?: AsyncCallback\<boolean\>): void 3790 3791Unsubscribes from macro state change events. 3792 3793**System API**: This is a system API. 3794 3795**System capability**: SystemCapability.Multimedia.Camera.Core 3796 3797**Parameters** 3798 3799| Name | Type | Mandatory| Description | 3800| -------- | ------------------------ | ---- | ------------------------ | 3801| type | string | Yes | Event type. The value is fixed at **'macroStatusChanged'**. The event can be listened for when a session is created.| 3802| callback | AsyncCallback\<boolean\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('macroStatusChanged')** with the specified callback is canceled. (The callback object cannot be an anonymous function.)| 3803 3804**Error codes** 3805 3806For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3807 3808| ID| Error Message | 3809|-------|---------------------------| 3810| 202 | Not System Application. | 3811 3812**Example** 3813 3814```ts 3815function unregisterMacroStatusChanged(videoSession: camera.VideoSession): void { 3816 videoSession.off('macroStatusChanged'); 3817} 3818``` 3819 3820## PortraitPhotoSession<sup>11+</sup> 3821 3822PortraitPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, Beauty, ColorEffect, ColorManagement, Portrait, Aperture 3823 3824Implements a portrait photo session, which sets the parameters of the portrait photo mode and saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera. It inherits from [Session](js-apis-camera.md#session11). 3825 3826### on('error')<sup>11+</sup> 3827 3828on(type: 'error', callback: ErrorCallback): void 3829 3830Subscribes to **PortraitSession** error events. This API uses an asynchronous callback to return the result. 3831 3832**System API**: This is a system API. 3833 3834**System capability**: SystemCapability.Multimedia.Camera.Core 3835 3836**Parameters** 3837 3838| Name | Type | Mandatory| Description | 3839| -------- | --------------------------------- | ---- | ------------------------------ | 3840| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as [beginConfig](js-apis-camera.md#beginconfig11), [commitConfig](js-apis-camera.md#commitconfig11-1), and [addInput](js-apis-camera.md#addinput11).| 3841| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode). | 3842 3843**Example** 3844 3845```ts 3846import { BusinessError } from '@kit.BasicServicesKit'; 3847 3848function callback(err: BusinessError): void { 3849 console.error(`Portrait photo session error code: ${err.code}`); 3850} 3851 3852function registerSessionError(portraitPhotoSession: camera.PortraitPhotoSession): void { 3853 portraitPhotoSession.on('error', callback); 3854} 3855``` 3856 3857### off('error')<sup>11+</sup> 3858 3859off(type: 'error', callback?: ErrorCallback): void 3860 3861Unsubscribes from **PortraitSession** error events. 3862 3863**System API**: This is a system API. 3864 3865**System capability**: SystemCapability.Multimedia.Camera.Core 3866 3867**Parameters** 3868 3869| Name | Type | Mandatory| Description | 3870| -------- | -------------------------- | ---- | ------------------------------ | 3871| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 3872| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('error')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 3873 3874**Example** 3875 3876```ts 3877function unregisterSessionError(portraitPhotoSession: camera.PortraitPhotoSession): void { 3878 portraitPhotoSession.off('error'); 3879} 3880``` 3881 3882### on('focusStateChange')<sup>11+</sup> 3883 3884on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 3885 3886Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 3887 3888**System API**: This is a system API. 3889 3890**System capability**: SystemCapability.Multimedia.Camera.Core 3891 3892**Parameters** 3893 3894| Name | Type | Mandatory| Description | 3895| -------- | ---------------- | ---- | ------------------------ | 3896| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.| 3897| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 3898 3899**Example** 3900 3901```ts 3902import { BusinessError } from '@kit.BasicServicesKit'; 3903 3904function callback(err: BusinessError, focusState: camera.FocusState): void { 3905 if (err !== undefined && err.code !== 0) { 3906 console.error(`Callback Error, errorCode: ${err.code}`); 3907 return; 3908 } 3909 console.info(`Focus state: ${focusState}`); 3910} 3911 3912function registerFocusStateChange(portraitPhotoSession: camera.PortraitPhotoSession): void { 3913 portraitPhotoSession.on('focusStateChange', callback); 3914} 3915``` 3916 3917### off('focusStateChange')<sup>11+</sup> 3918 3919off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 3920 3921Unsubscribes from focus state change events. 3922 3923**System API**: This is a system API. 3924 3925**System capability**: SystemCapability.Multimedia.Camera.Core 3926 3927**Parameters** 3928 3929| Name | Type | Mandatory| Description | 3930| -------- | ----------------------------------------- | ---- | ------------------------ | 3931| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 3932| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('focusStateChange')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 3933 3934**Example** 3935 3936```ts 3937function unregisterFocusStateChange(portraitPhotoSession: camera.PortraitPhotoSession): void { 3938 portraitPhotoSession.off('focusStateChange'); 3939} 3940``` 3941 3942### on('smoothZoomInfoAvailable')<sup>11+</sup> 3943 3944on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 3945 3946Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 3947 3948**System API**: This is a system API. 3949 3950**System capability**: SystemCapability.Multimedia.Camera.Core 3951 3952**Parameters** 3953 3954| Name | Type | Mandatory| Description | 3955| -------- | ----------------------- | ---- | ------------------------ | 3956| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 3957| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 3958 3959**Example** 3960 3961```ts 3962import { BusinessError } from '@kit.BasicServicesKit'; 3963 3964function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 3965 if (err !== undefined && err.code !== 0) { 3966 console.error(`Callback Error, errorCode: ${err.code}`); 3967 return; 3968 } 3969 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 3970} 3971 3972function registerSmoothZoomInfo(portraitPhotoSession: camera.PortraitPhotoSession): void { 3973 portraitPhotoSession.on('smoothZoomInfoAvailable', callback); 3974} 3975``` 3976 3977### off('smoothZoomInfoAvailable')<sup>11+</sup> 3978 3979off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 3980 3981Unsubscribes from smooth zoom state change events. 3982 3983**System API**: This is a system API. 3984 3985**System capability**: SystemCapability.Multimedia.Camera.Core 3986 3987**Parameters** 3988 3989| Name | Type | Mandatory| Description | 3990| -------- | ----------------------------------------- | ---- | ------------------------ | 3991| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 3992| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('smoothZoomInfoAvailable')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 3993 3994**Example** 3995 3996```ts 3997function unregisterSmoothZoomInfo(portraitPhotoSession: camera.PortraitPhotoSession): void { 3998 portraitPhotoSession.off('smoothZoomInfoAvailable'); 3999} 4000``` 4001 4002## NightPhotoSession<sup>11+</sup> 4003 4004NightPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ColorManagement, ManualExposure 4005 4006Implements a night photo session, which sets the parameters of the night photo mode and saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera. It inherits from [Session](js-apis-camera.md#session11). 4007 4008### on('error')<sup>11+</sup> 4009 4010on(type: 'error', callback: ErrorCallback): void 4011 4012Subscribes to **NightSession** error events. This API uses an asynchronous callback to return the result. 4013 4014**System API**: This is a system API. 4015 4016**System capability**: SystemCapability.Multimedia.Camera.Core 4017 4018**Parameters** 4019 4020| Name | Type | Mandatory| Description | 4021| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 4022| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as [beginConfig](js-apis-camera.md#beginconfig11), [commitConfig](js-apis-camera.md#commitconfig11-1), and [addInput](js-apis-camera.md#addinput11).| 4023| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode).| 4024 4025**Example** 4026 4027```ts 4028import { BusinessError } from '@kit.BasicServicesKit'; 4029 4030function callback(err: BusinessError): void { 4031 console.error(`Night photo session error code: ${err.code}`); 4032} 4033 4034function registerSessionError(nightPhotoSession: camera.NightPhotoSession): void { 4035 nightPhotoSession.on('error', callback); 4036} 4037``` 4038 4039### off('error')<sup>11+</sup> 4040 4041off(type: 'error', callback?: ErrorCallback): void 4042 4043Unsubscribes from **NightSession** error events. 4044 4045**System API**: This is a system API. 4046 4047**System capability**: SystemCapability.Multimedia.Camera.Core 4048 4049**Parameters** 4050 4051| Name | Type | Mandatory| Description | 4052| -------- | ------------------------ | ---- | ------------------------------ | 4053| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 4054| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('error')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 4055 4056**Example** 4057 4058```ts 4059function unregisterSessionError(nightPhotoSession: camera.NightPhotoSession): void { 4060 nightPhotoSession.off('error'); 4061} 4062``` 4063 4064### on('focusStateChange')<sup>11+</sup> 4065 4066on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4067 4068Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 4069 4070**System API**: This is a system API. 4071 4072**System capability**: SystemCapability.Multimedia.Camera.Core 4073 4074**Parameters** 4075 4076| Name | Type | Mandatory| Description | 4077| -------- | ---------------- | ---- | ------------------------ | 4078| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.| 4079| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 4080 4081**Example** 4082 4083```ts 4084import { BusinessError } from '@kit.BasicServicesKit'; 4085 4086function callback(err: BusinessError, focusState: camera.FocusState): void { 4087 if (err !== undefined && err.code !== 0) { 4088 console.error(`Callback Error, errorCode: ${err.code}`); 4089 return; 4090 } 4091 console.info(`Focus state: ${focusState}`); 4092} 4093 4094function registerFocusStateChange(nightPhotoSession: camera.NightPhotoSession): void { 4095 nightPhotoSession.on('focusStateChange', callback); 4096} 4097``` 4098 4099### off('focusStateChange')<sup>11+</sup> 4100 4101off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4102 4103Unsubscribes from focus state change events. 4104 4105**System API**: This is a system API. 4106 4107**System capability**: SystemCapability.Multimedia.Camera.Core 4108 4109**Parameters** 4110 4111| Name | Type | Mandatory| Description | 4112| -------- | ----------------------------------------- | ---- | ------------------------ | 4113| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 4114| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('focusStateChange')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 4115 4116**Example** 4117 4118```ts 4119function unregisterFocusStateChange(nightPhotoSession: camera.NightPhotoSession): void { 4120 nightPhotoSession.off('focusStateChange'); 4121} 4122``` 4123 4124### on('smoothZoomInfoAvailable')<sup>11+</sup> 4125 4126on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 4127 4128Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 4129 4130**System API**: This is a system API. 4131 4132**System capability**: SystemCapability.Multimedia.Camera.Core 4133 4134**Parameters** 4135 4136| Name | Type | Mandatory| Description | 4137| -------- | ----------------------- | ---- | ------------------------ | 4138| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 4139| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 4140 4141**Example** 4142 4143```ts 4144import { BusinessError } from '@kit.BasicServicesKit'; 4145 4146function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 4147 if (err !== undefined && err.code !== 0) { 4148 console.error(`Callback Error, errorCode: ${err.code}`); 4149 return; 4150 } 4151 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 4152} 4153 4154function registerSmoothZoomInfo(nightPhotoSession: camera.NightPhotoSession): void { 4155 nightPhotoSession.on('smoothZoomInfoAvailable', callback); 4156} 4157``` 4158 4159### off('smoothZoomInfoAvailable')<sup>11+</sup> 4160 4161off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 4162 4163Unsubscribes from smooth zoom state change events. 4164 4165**System API**: This is a system API. 4166 4167**System capability**: SystemCapability.Multimedia.Camera.Core 4168 4169**Parameters** 4170 4171| Name | Type | Mandatory| Description | 4172| -------- | ----------------------------------------- | ---- | ------------------------ | 4173| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 4174| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('smoothZoomInfoAvailable')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 4175 4176**Example** 4177 4178```ts 4179function unregisterSmoothZoomInfo(nightPhotoSession: camera.NightPhotoSession): void { 4180 nightPhotoSession.off('smoothZoomInfoAvailable'); 4181} 4182``` 4183 4184### on('lcdFlashStatus')<sup>12+</sup> 4185 4186on(type: 'lcdFlashStatus', callback: AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\>): void 4187 4188Subscribes to LCD flash status change events. This API uses an asynchronous callback to return the result. 4189 4190**System API**: This is a system API. 4191 4192**System capability**: SystemCapability.Multimedia.Camera.Core 4193 4194**Parameters** 4195 4196| Name | Type | Mandatory| Description | 4197| -------- | ----------------------- | ---- | ------------------------ | 4198| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created.| 4199| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | Yes | Callback used to return the LCD flash status change. | 4200 4201**Error codes** 4202 4203For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4204 4205| ID| Error Message | 4206|-------|---------------------------| 4207| 202 | Not System Application. | 4208 4209**Example** 4210 4211```ts 4212import { BusinessError } from '@kit.BasicServicesKit'; 4213 4214function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 4215 if (err !== undefined && err.code !== 0) { 4216 console.error(`Callback Error, errorCode: ${err.code}`); 4217 return; 4218 } 4219 console.info(`lcdFlashStatus: ${lcdFlashStatus}`); 4220} 4221 4222function registerLcdFlashStatus(nightPhotoSession: camera.NightPhotoSession): void { 4223 nightPhotoSession.on('lcdFlashStatus', callback); 4224} 4225``` 4226 4227### off('lcdFlashStatus')<sup>12+</sup> 4228 4229off(type: 'lcdFlashStatus', callback?: AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\>): void 4230 4231Unsubscribes from LCD flash status change events. 4232 4233**System API**: This is a system API. 4234 4235**System capability**: SystemCapability.Multimedia.Camera.Core 4236 4237**Parameters** 4238 4239| Name | Type | Mandatory| Description | 4240| -------- | ----------------------------------------- | ---- | ------------------------ | 4241| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created.| 4242| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('lcdFlashStatus')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 4243 4244**Error codes** 4245 4246For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4247 4248| ID| Error Message | 4249|-------|---------------------------| 4250| 202 | Not System Application. | 4251 4252**Example** 4253 4254```ts 4255function unregisterLcdFlashStatus(nightPhotoSession: camera.NightPhotoSession): void { 4256 nightPhotoSession.off('lcdFlashStatus'); 4257} 4258``` 4259 4260## HighResolutionPhotoSession<sup>12+</sup> 4261 4262HighResolutionPhotoSession extends Session, AutoExposure, Focus 4263 4264Implements a high-resolution photo session, which sets the parameters of the high-resolution photo mode and saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera. It inherits from [Session](js-apis-camera.md#session11). 4265 4266### on('error')<sup>12+</sup> 4267 4268on(type: 'error', callback: ErrorCallback): void 4269 4270Subscribes to **HighResolutionPhotoSession** error events. This API uses an asynchronous callback to return the result. 4271 4272**System API**: This is a system API. 4273 4274**System capability**: SystemCapability.Multimedia.Camera.Core 4275 4276**Parameters** 4277 4278| Name | Type | Mandatory| Description | 4279| -------- | --------------------------------- | ---- | ------------------------------ | 4280| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as [beginConfig](js-apis-camera.md#beginconfig11), [commitConfig](js-apis-camera.md#commitconfig11-1), and [addInput](js-apis-camera.md#addinput11).| 4281| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode). | 4282 4283**Error codes** 4284 4285For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4286 4287| ID | Error Message | 4288| --------------- | --------------- | 4289| 202 | Not System Application. | 4290 4291**Example** 4292 4293```ts 4294import { BusinessError } from '@kit.BasicServicesKit'; 4295 4296function callback(err: BusinessError): void { 4297 console.error(`High resolution photo session error code: ${err.code}`); 4298} 4299 4300function registerSessionError(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4301 highResolutionPhotoSession.on('error', callback); 4302} 4303``` 4304### off('error')<sup>12+</sup> 4305 4306off(type: 'error', callback?: ErrorCallback): void 4307 4308Unsubscribes from **HighResolutionPhotoSession** error events. 4309 4310**System API**: This is a system API. 4311 4312**System capability**: SystemCapability.Multimedia.Camera.Core 4313 4314**Parameters** 4315 4316| Name | Type | Mandatory| Description | 4317| -------- | ------------------------ | ---- | ------------------------------ | 4318| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 4319| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('error')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 4320 4321**Error codes** 4322 4323For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4324 4325| ID | Error Message | 4326| --------------- | --------------- | 4327| 202 | Not System Application. | 4328 4329**Example** 4330 4331```ts 4332function unregisterSessionError(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4333 highResolutionPhotoSession.off('error'); 4334} 4335``` 4336 4337### on('focusStateChange')<sup>12+</sup> 4338 4339on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4340 4341Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 4342 4343**System API**: This is a system API. 4344 4345**System capability**: SystemCapability.Multimedia.Camera.Core 4346 4347**Parameters** 4348 4349| Name | Type | Mandatory| Description | 4350| -------- | ---------------- | ---- | ------------------------ | 4351| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.| 4352| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 4353 4354**Error codes** 4355 4356For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4357 4358| ID | Error Message | 4359| --------------- | --------------- | 4360| 202 | Not System Application. | 4361 4362**Example** 4363 4364```ts 4365import { BusinessError } from '@kit.BasicServicesKit'; 4366 4367function callback(err: BusinessError, focusState: camera.FocusState): void { 4368 if (err !== undefined && err.code !== 0) { 4369 console.error(`Callback Error, errorCode: ${err.code}`); 4370 return; 4371 } 4372 console.info(`Focus state: ${focusState}`); 4373} 4374 4375function registerFocusStateChange(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4376 highResolutionPhotoSession.on('focusStateChange', callback); 4377} 4378``` 4379 4380### off('focusStateChange')<sup>12+</sup> 4381 4382off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4383 4384Unsubscribes from focus state change events. 4385 4386**System API**: This is a system API. 4387 4388**System capability**: SystemCapability.Multimedia.Camera.Core 4389 4390**Error codes** 4391 4392For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4393 4394| ID | Error Message | 4395| --------------- | --------------- | 4396| 202 | Not System Application. | 4397 4398**Parameters** 4399 4400| Name | Type | Mandatory| Description | 4401| -------- | ----------------------------------------- | ---- | ------------------------ | 4402| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 4403| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('focusStateChange')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 4404 4405**Example** 4406 4407```ts 4408function unregisterFocusStateChange(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4409 highResolutionPhotoSession.off('focusStateChange'); 4410} 4411``` 4412 4413## SketchStatusData<sup>11+</sup> 4414 4415Defines the PiP status data. 4416 4417**System API**: This is a system API. 4418 4419**System capability**: SystemCapability.Multimedia.Camera.Core 4420 4421| Name | Type | Read-only| Mandatory| Description | 4422| ------------- | -------- | ---- | ---- | ---------- | 4423| status | number | No | Yes | Status of PiP. The options are 0 (stopped), 1 (started), 2 (stopping), and 3 (starting).| 4424| sketchRatio | number | No | Yes | Zoom ratio of PiP.| 4425 4426## SlowMotionVideoSession<sup>12+</sup> 4427 4428SlowMotionVideoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect 4429 4430Implements a slow-motion video session, which sets the parameters of the slow-motion video mode and saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera. It inherits from [Session](js-apis-camera.md#session11). 4431 4432> **NOTE** 4433> 4434> In slow-motion video mode, only preview streams and video streams can be added. 4435### on('error')<sup>12+</sup> 4436 4437on(type: 'error', callback: ErrorCallback): void 4438 4439Subscribes to **SlowMotionVideoSession** error events. This API uses an asynchronous callback to return the result. 4440 4441**System API**: This is a system API. 4442 4443**System capability**: SystemCapability.Multimedia.Camera.Core 4444 4445**Parameters** 4446 4447| Name | Type | Mandatory| Description | 4448| -------- | --------------------------------- | ---- | ------------------------------ | 4449| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as [beginConfig](js-apis-camera.md#beginconfig11), [commitConfig](js-apis-camera.md#commitconfig11-1), and [addInput](js-apis-camera.md#addinput11).| 4450| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode). | 4451 4452**Error codes** 4453 4454For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4455 4456| ID | Error Message | 4457|---------| --------------- | 4458| 202 | Not System Application. | 4459 4460**Example** 4461 4462```ts 4463import { BusinessError } from '@kit.BasicServicesKit'; 4464 4465function callback(err: BusinessError): void { 4466 console.error(`Portrait photo session error code: ${err.code}`); 4467} 4468 4469function registerSessionError(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4470 slowMotionVideoSession.on('error', callback); 4471} 4472``` 4473 4474### off('error')<sup>12+</sup> 4475 4476off(type: 'error', callback?: ErrorCallback): void 4477 4478Unsubscribes from **SlowMotionVideoSession** error events. 4479 4480**System API**: This is a system API. 4481 4482**System capability**: SystemCapability.Multimedia.Camera.Core 4483 4484**Parameters** 4485 4486| Name | Type | Mandatory| Description | 4487| -------- | -------------------------- | ---- | ------------------------------ | 4488| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 4489| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('error')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 4490 4491**Error codes** 4492 4493For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4494 4495| ID | Error Message | 4496|---------| --------------- | 4497| 202 | Not System Application. | 4498 4499**Example** 4500 4501```ts 4502function unregisterSessionError(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4503 slowMotionVideoSession.off('error'); 4504} 4505``` 4506 4507### on('focusStateChange')<sup>12+</sup> 4508 4509on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4510 4511Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 4512 4513**System API**: This is a system API. 4514 4515**System capability**: SystemCapability.Multimedia.Camera.Core 4516 4517**Parameters** 4518 4519| Name | Type | Mandatory| Description | 4520| -------- | ---------------- | ---- | ------------------------ | 4521| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.| 4522| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 4523 4524**Error codes** 4525 4526For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4527 4528| ID | Error Message | 4529|---------| --------------- | 4530| 202 | Not System Application. | 4531 4532**Example** 4533 4534```ts 4535import { BusinessError } from '@kit.BasicServicesKit'; 4536 4537function callback(err: BusinessError, focusState: camera.FocusState): void { 4538 if (err !== undefined && err.code !== 0) { 4539 console.error(`Callback Error, errorCode: ${err.code}`); 4540 return; 4541 } 4542 console.info(`Focus state: ${focusState}`); 4543} 4544 4545function registerFocusStateChange(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4546 slowMotionVideoSession.on('focusStateChange', callback); 4547} 4548``` 4549 4550### off('focusStateChange')<sup>12+</sup> 4551 4552off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4553 4554Unsubscribes from focus state change events. 4555 4556**System API**: This is a system API. 4557 4558**System capability**: SystemCapability.Multimedia.Camera.Core 4559 4560**Parameters** 4561 4562| Name | Type | Mandatory| Description | 4563| -------- | ----------------------------------------- | ---- | ------------------------ | 4564| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 4565| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('focusStateChange')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 4566 4567**Error codes** 4568 4569For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4570 4571| ID | Error Message | 4572|---------| --------------- | 4573| 202 | Not System Application. | 4574 4575**Example** 4576 4577```ts 4578function unregisterFocusStateChange(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4579 slowMotionVideoSession.off('focusStateChange'); 4580} 4581``` 4582 4583### on('smoothZoomInfoAvailable')<sup>12+</sup> 4584 4585on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 4586 4587Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 4588 4589**System API**: This is a system API. 4590 4591**System capability**: SystemCapability.Multimedia.Camera.Core 4592 4593**Parameters** 4594 4595| Name | Type | Mandatory| Description | 4596| -------- | ----------------------- | ---- | ------------------------ | 4597| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 4598| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 4599 4600**Error codes** 4601 4602For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4603 4604| ID | Error Message | 4605|---------| --------------- | 4606| 202 | Not System Application. | 4607 4608**Example** 4609 4610```ts 4611import { BusinessError } from '@kit.BasicServicesKit'; 4612 4613function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 4614 if (err !== undefined && err.code !== 0) { 4615 console.error(`Callback Error, errorCode: ${err.code}`); 4616 return; 4617 } 4618 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 4619} 4620 4621function registerSmoothZoomInfo(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4622 slowMotionVideoSession.on('smoothZoomInfoAvailable', callback); 4623} 4624``` 4625 4626### off('smoothZoomInfoAvailable')<sup>12+</sup> 4627 4628off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 4629 4630Unsubscribes from smooth zoom state change events. 4631 4632**System API**: This is a system API. 4633 4634**System capability**: SystemCapability.Multimedia.Camera.Core 4635 4636**Parameters** 4637 4638| Name | Type | Mandatory| Description | 4639| -------- | ----------------------------------------- | ---- | ------------------------ | 4640| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 4641| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('smoothZoomInfoAvailable')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 4642 4643**Error codes** 4644 4645For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4646 4647| ID | Error Message | 4648|---------| --------------- | 4649| 202 | Not System Application. | 4650 4651**Example** 4652 4653```ts 4654function unregisterSmoothZoomInfo(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4655 slowMotionVideoSession.off('smoothZoomInfoAvailable'); 4656} 4657``` 4658 4659### on('slowMotionStatus')<sup>12+</sup> 4660 4661on(type: 'slowMotionStatus', callback: AsyncCallback\<SlowMotionStatus\>): void 4662 4663Subscribes to slow-motion status change events. This API uses an asynchronous callback to return the result. 4664 4665**System API**: This is a system API. 4666 4667**System capability**: SystemCapability.Multimedia.Camera.Core 4668 4669**Parameters** 4670 4671| Name | Type | Mandatory| Description | 4672| -------- |---------------------------------------------------------------------------| ---- |--------------------------------------------| 4673| type | string | Yes | Event type. The value is fixed at **'slowMotionStatus'**. The event can be listened for when a session is created.| 4674| callback | AsyncCallback\<[SlowMotionStatus](#slowmotionstatus12)\> | Yes | Callback used to return the slow-motion status change. | 4675 4676**Error codes** 4677 4678For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4679 4680| ID | Error Message | 4681|---------| --------------- | 4682| 202 | Not System Application. | 4683 4684**Example** 4685 4686```ts 4687import { BusinessError } from '@kit.BasicServicesKit'; 4688 4689function callback(err: BusinessError, slowMotionStatus: camera.SlowMotionStatus): void { 4690 if (err !== undefined && err.code !== 0) { 4691 console.error(`Callback Error, errorCode: ${err.code}`); 4692 return; 4693 } 4694 console.info(`The slow motion status: ${slowMotionStatus}`); 4695} 4696 4697function registerSlowMotionStatus(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4698 slowMotionVideoSession.on('slowMotionStatus', callback); 4699} 4700``` 4701 4702### off('slowMotionStatus')<sup>12+</sup> 4703 4704off(type: 'slowMotionStatus', callback?: AsyncCallback\<SlowMotionStatus\>): void 4705 4706Unsubscribes from slow-motion status change events. 4707 4708**System API**: This is a system API. 4709 4710**System capability**: SystemCapability.Multimedia.Camera.Core 4711 4712**Parameters** 4713 4714| Name | Type | Mandatory| Description | 4715| -------- | ----------------------------------------- | ---- | ------------------------ | 4716| type | string | Yes | Event type. The value is fixed at **'slowMotionStatus'**. The event can be listened for when a session is created.| 4717| callback | AsyncCallback\<[SlowMotionStatus](#slowmotionstatus12)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('slowMotionStatus')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned. | 4718 4719**Error codes** 4720 4721For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4722 4723| ID | Error Message | 4724|---------| --------------- | 4725| 202 | Not System Application. | 4726 4727**Example** 4728 4729```ts 4730function unregisterSlowMotionStatus(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4731 slowMotionVideoSession.off('slowMotionStatus'); 4732} 4733``` 4734### isSlowMotionDetectionSupported<sup>12+</sup> 4735 4736isSlowMotionDetectionSupported(): boolean 4737 4738Checks whether the device supports slow-motion detection. 4739 4740> **NOTE** 4741> 4742> This API must be called after [commitConfig](js-apis-camera.md#commitconfig11-1) is called. 4743 4744**System API**: This is a system API. 4745 4746**System capability**: SystemCapability.Multimedia.Camera.Core 4747 4748**Return value** 4749 4750| Type | Description | 4751| ---------- |----------------------------------------------------------------------------------------| 4752| boolean | **true**: The device supports slow-motion detection.<br>**false**: The device does not support slow-motion detection.<br>If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 4753 4754**Error codes** 4755 4756For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4757 4758| ID | Error Message | 4759|---------| --------------- | 4760| 202 | Not System Application. | 4761| 7400103 | Session not config. | 4762 4763**Example** 4764 4765```ts 4766import { BusinessError } from '@kit.BasicServicesKit'; 4767 4768function isSlowMotionDetectionSupported(slowMotionVideoSession: camera.SlowMotionVideoSession): boolean { 4769 let isSupported: boolean = false; 4770 try { 4771 isSupported = slowMotionVideoSession.isSlowMotionDetectionSupported(); 4772 } catch (error) { 4773 // If the operation fails, error.code is returned and processed. 4774 let err = error as BusinessError; 4775 console.error(`The isFocusModeSupported call failed. error code: ${err.code}`); 4776 } 4777 return isSupported; 4778} 4779``` 4780 4781### setSlowMotionDetectionArea<sup>12+</sup> 4782 4783setSlowMotionDetectionArea(area: Rect): void 4784 4785Sets an area for slow-motion detection. 4786 4787> **NOTE** 4788> 4789> Before the setting, call [isSlowMotionDetectionSupported](#isslowmotiondetectionsupported12) to check whether the device supports slow-motion detection. 4790This API must be called after [commitConfig](js-apis-camera.md#commitconfig11-1) is called. 4791 4792**System API**: This is a system API. 4793 4794**System capability**: SystemCapability.Multimedia.Camera.Core 4795 4796**Parameters** 4797 4798| Name | Type | Mandatory| Description | 4799| -------- | ---------------------------------------------- | ---- | --------------------------- | 4800| area | [Rect](js-apis-camera.md#rect) | Yes | Area. | 4801 4802**Error codes** 4803 4804For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4805 4806| ID | Error Message | 4807|---------| --------------- | 4808| 202 | Not System Application. | 4809| 7400101 | Parameter missing or parameter type incorrect. | 4810| 7400103 | Session not config. | 4811 4812**Example** 4813 4814```ts 4815import { BusinessError } from '@kit.BasicServicesKit'; 4816 4817function setSlowMotionDetectionArea(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4818 try { 4819 slowMotionVideoSession.setSlowMotionDetectionArea({topLeftX: 0.1, topLeftY: 0.1, width: 0.8, height: 0.8}); 4820 } catch (error) { 4821 // If the operation fails, error.code is returned and processed. 4822 let err = error as BusinessError; 4823 console.error(`The setSlowMotionDetectionArea call failed. error code: ${err.code}`); 4824 } 4825} 4826``` 4827 4828## PanoramaPhotoSession<sup>12+</sup> 4829 4830PanoramaPhotoSession extends Session, Focus, AutoExposure, WhiteBalance, ColorEffect 4831 4832Implements a panoramic photo session, which sets the parameters of the panoramic photo mode and saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera. It inherits from [Session](js-apis-camera.md#session11). 4833 4834### on('error')<sup>12+</sup> 4835 4836on(type: 'error', callback: ErrorCallback): void 4837 4838Subscribes to **PanoramaPhotoSession** error events. This API uses an asynchronous callback to return the result. 4839 4840**System API**: This is a system API. 4841 4842**System capability**: SystemCapability.Multimedia.Camera.Core 4843 4844**Parameters** 4845 4846| Name | Type | Mandatory| Description | 4847| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 4848| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as [beginConfig](js-apis-camera.md#beginconfig11), [commitConfig](js-apis-camera.md#commitconfig11-1), and [addInput](js-apis-camera.md#addinput11).| 4849| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode).| 4850 4851**Example** 4852 4853```ts 4854import { BusinessError } from '@kit.BasicServicesKit'; 4855 4856function callback(err: BusinessError): void { 4857 console.error(`Panorama photo session error code: ${err.code}`); 4858} 4859 4860function registerSessionError(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 4861 panoramaPhotoSession.on('error', callback); 4862} 4863``` 4864 4865### off('error')<sup>11+</sup> 4866 4867off(type: 'error', callback?: ErrorCallback): void 4868 4869Unsubscribes from **PanoramaPhotoSession** error events. 4870 4871**System API**: This is a system API. 4872 4873**System capability**: SystemCapability.Multimedia.Camera.Core 4874 4875**Parameters** 4876 4877| Name | Type | Mandatory| Description | 4878| -------- | ------------------------ | ---- | ------------------------------ | 4879| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 4880| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('error')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 4881 4882**Example** 4883 4884```ts 4885function unregisterSessionError(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 4886 panoramaPhotoSession.off('error'); 4887} 4888``` 4889 4890### on('focusStateChange')<sup>11+</sup> 4891 4892on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4893 4894Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 4895 4896**System API**: This is a system API. 4897 4898**System capability**: SystemCapability.Multimedia.Camera.Core 4899 4900**Parameters** 4901 4902| Name | Type | Mandatory| Description | 4903| -------- | ---------------- | ---- | ------------------------ | 4904| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.| 4905| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 4906 4907**Example** 4908 4909```ts 4910import { BusinessError } from '@kit.BasicServicesKit'; 4911 4912function callback(err: BusinessError, focusState: camera.FocusState): void { 4913 if (err !== undefined && err.code !== 0) { 4914 console.error(`Callback Error, errorCode: ${err.code}`); 4915 return; 4916 } 4917 console.info(`Focus state: ${focusState}`); 4918} 4919 4920function registerFocusStateChange(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 4921 panoramaPhotoSession.on('focusStateChange', callback); 4922} 4923``` 4924 4925### off('focusStateChange')<sup>11+</sup> 4926 4927off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4928 4929Unsubscribes from focus state change events. 4930 4931**System API**: This is a system API. 4932 4933**System capability**: SystemCapability.Multimedia.Camera.Core 4934 4935**Parameters** 4936 4937| Name | Type | Mandatory| Description | 4938| -------- | ----------------------------------------- | ---- | ------------------------ | 4939| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 4940| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('focusStateChange')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 4941 4942**Example** 4943 4944```ts 4945function unregisterFocusStateChange(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 4946 panoramaPhotoSession.off('focusStateChange'); 4947} 4948``` 4949 4950## IsoInfo<sup>12+</sup> 4951 4952Describes the ISO information. 4953 4954**System API**: This is a system API. 4955 4956**System capability**: SystemCapability.Multimedia.Camera.Core 4957 4958| Name| Type | Read-only| Optional| Description | 4959| ---- | ------- | ---- |--| -------------- | 4960| iso | number | Yes | Yes| ISO. | 4961 4962--- 4963 4964## ExposureInfo<sup>12+</sup> 4965 4966Describes the exposure information. 4967 4968**System API**: This is a system API. 4969 4970**System capability**: SystemCapability.Multimedia.Camera.Core 4971 4972| Name | Type | Read-only| Optional | Description | 4973| ----------------- | ------- | ---- |-----| ------------------ | 4974| exposureTime | number | Yes | Yes | Exposure time, in ms.| 4975 4976--- 4977 4978## ApertureInfo<sup>12+</sup> 4979 4980Describes the aperture information. 4981 4982**System API**: This is a system API. 4983 4984**System capability**: SystemCapability.Multimedia.Camera.Core 4985 4986| Name | Type | Read-only| Optional | Description | 4987| --------- | ------- | ---- |-----| ---------- | 4988| aperture | number | Yes | Yes | Aperture. | 4989 4990--- 4991 4992## LuminationInfo<sup>12+</sup> 4993 4994Describes the illumination information. 4995 4996**System API**: This is a system API. 4997 4998**System capability**: SystemCapability.Multimedia.Camera.Core 4999 5000| Name | Type | Read-only| Optional | Description | 5001| ----------- | ------- | ---- |-----| ---------- | 5002| lumination | number | Yes | Yes | Illumination. The value range is [0,1].| 5003 5004## CameraFormat 5005 5006Enumerates the camera output formats. 5007 5008**System capability**: SystemCapability.Multimedia.Camera.Core 5009 5010| Name | Value | Description | 5011| ----------------------- | --------- | ------------ | 5012| CAMERA_FORMAT_DNG<sup>12+</sup> | 4 | Raw image in DNG format. **System API**: This is a system API. | 5013 5014## ExposureMeteringMode<sup>12+</sup> 5015 5016Enumerates the exposure metering modes. 5017 5018**System API**: This is a system API. 5019 5020**System capability**: SystemCapability.Multimedia.Camera.Core 5021 5022| Name | Value | Description | 5023| ----------------------------- | ---- | ----------- | 5024| MATRIX | 0 | Performs metering on a wide area of the image.| 5025| CENTER | 1 | Performs metering on the entire image, with the center allocated with the maximum weight.| 5026| SPOT | 2 | Performs metering around 2.5% of the metering points.| 5027 5028## AutoExposureQuery<sup>12+</sup> 5029 5030Provides APIs to check whether a device supports an exposure mode or exposure metering mode and obtain the exposure compensation range. 5031 5032### isExposureMeteringModeSupported<sup>12+</sup> 5033 5034isExposureMeteringModeSupported(aeMeteringMode: ExposureMeteringMode): boolean 5035 5036Checks whether an exposure metering mode is supported. 5037 5038**System API**: This is a system API. 5039 5040**System capability**: SystemCapability.Multimedia.Camera.Core 5041 5042**Parameters** 5043 5044| Name | Type | Mandatory | Description | 5045| -------- | -------------------------------| ---- | ----------------------------- | 5046| aeMeteringMode | [ExposureMeteringMode](#exposuremeteringmode12) | Yes | Metering mode. | 5047 5048**Return value** 5049 5050| Type | Description | 5051| ---------- | ----------------------------- | 5052| boolean | **true**: The exposure metering mode is supported.<br>**false**: The exposure metering mode is not supported. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 5053 5054**Error codes** 5055 5056For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5057 5058| ID | Error Message | 5059| --------------- | --------------- | 5060| 202 | Not System Application. | 5061| 7400101 | Parameter missing or parameter type incorrect. | 5062| 7400103 | Session not config. | 5063 5064 5065**Example** 5066 5067```ts 5068import { BusinessError } from '@kit.BasicServicesKit'; 5069 5070function isExposureMeteringModeSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5071 let isSupported: boolean = false; 5072 try { 5073 isSupported = professionalPhotoSession.isExposureModeSupported(camera.ExposureMeteringMode.CENTER); 5074 } catch (error) { 5075 // If the operation fails, error.code is returned and processed. 5076 let err = error as BusinessError; 5077 console.error(`The isExposureMeteringModeSupported call failed. error code: ${err.code}`); 5078 } 5079 return isSupported; 5080} 5081``` 5082 5083## AutoExposure 5084 5085AutoExposure extends [AutoExposureQuery](#autoexposurequery12) 5086 5087Provides APIs related to automatic exposure of a camera device, including obtaining and setting the exposure mode and measurement point, obtaining the compensation range, setting the exposure compensation, and obtaining the exposure metering mode. 5088 5089### getExposureMeteringMode<sup>12+</sup> 5090 5091getExposureMeteringMode(): ExposureMeteringMode 5092 5093Obtains the exposure metering mode in use. 5094 5095**System API**: This is a system API. 5096 5097**System capability**: SystemCapability.Multimedia.Camera.Core 5098 5099**Return value** 5100 5101| Type | Description | 5102| ---------- | ----------------------------- | 5103| [ExposureMeteringMode](#exposuremeteringmode12) | Exposure metering mode obtained. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 5104 5105**Error codes** 5106 5107For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5108 5109| ID | Error Message | 5110| --------------- | --------------- | 5111| 7400103 | Session not config. | 5112| 202 | Not System Application. | 5113 5114**Example** 5115 5116```ts 5117import { BusinessError } from '@kit.BasicServicesKit'; 5118 5119function getExposureMeteringMode(professionalPhotoSession: camera.ProfessionalPhotoSession): camera.ExposureMeteringMode | undefined { 5120 let exposureMeteringMode: camera.ExposureMeteringMode | undefined = undefined; 5121 try { 5122 exposureMeteringMode = professionalPhotoSession.getExposureMeteringMode(); 5123 } catch (error) { 5124 // If the operation fails, error.code is returned and processed. 5125 let err = error as BusinessError; 5126 console.error(`The getExposureMeteringMode call failed. error code: ${err.code}`); 5127 } 5128 return exposureMeteringMode; 5129} 5130``` 5131 5132### setExposureMeteringMode<sup>12+</sup> 5133 5134setExposureMeteringMode(aeMeteringMode: ExposureMeteringMode): void 5135 5136Sets an exposure metering mode. 5137 5138Before the setting, call [isExposureMeteringModeSupported](#isexposuremeteringmodesupported12) to check whether the target exposure metering mode is supported. 5139 5140**System API**: This is a system API. 5141 5142**System capability**: SystemCapability.Multimedia.Camera.Core 5143 5144**Parameters** 5145 5146| Name | Type | Mandatory| Description | 5147| -------- | -------------------------------| ---- | ----------------------- | 5148| aeMeteringMode | [ExposureMeteringMode](#exposuremeteringmode12) | Yes | Metering mode. | 5149 5150**Error codes** 5151 5152For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5153 5154| ID | Error Message | 5155| --------------- | --------------- | 5156| 202 | Not System Application. | 5157| 7400101 | Parameter missing or parameter type incorrect. | 5158| 7400103 | Session not config. | 5159 5160**Example** 5161 5162```ts 5163import { BusinessError } from '@kit.BasicServicesKit'; 5164 5165function setExposureMeteringMode(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5166 try { 5167 professionalPhotoSession.setExposureMeteringMode(camera.ExposureMeteringMode.CENTER); 5168 } catch (error) { 5169 // If the operation fails, error.code is returned and processed. 5170 let err = error as BusinessError; 5171 console.error(`The setExposureMeteringMode call failed. error code: ${err.code}`); 5172 } 5173} 5174``` 5175 5176## FocusQuery<sup>12+</sup> 5177 5178Provides the API to check whether the focus assist is supported. 5179 5180### isFocusAssistSupported<sup>12+</sup> 5181 5182isFocusAssistSupported(): boolean 5183 5184Checks whether the focus assist is supported. 5185 5186**System API**: This is a system API. 5187 5188**System capability**: SystemCapability.Multimedia.Camera.Core 5189 5190**Return value** 5191 5192| Type | Description | 5193| ---------- | ----------------------------- | 5194| boolean | **true**: The focus assist is supported.<br>**false**: The focus assist is not supported. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 5195 5196**Error codes** 5197 5198For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5199 5200| ID | Error Message | 5201| --------------- | --------------- | 5202| 7400103 | Session not config. | 5203| 202 | Not System Application. | 5204 5205**Example** 5206 5207```ts 5208import { BusinessError } from '@kit.BasicServicesKit'; 5209 5210function isFocusAssistSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5211 let status: boolean = false; 5212 try { 5213 status = professionalPhotoSession.isFocusAssistSupported(); 5214 } catch (error) { 5215 // If the operation fails, error.code is returned and processed. 5216 let err = error as BusinessError; 5217 console.error(`The isFocusAssistSupported call failed. error code: ${err.code}`); 5218 } 5219 return status; 5220} 5221``` 5222 5223## Focus 5224 5225Focus extends [FocusQuery](#focusquery12) 5226 5227Provides APIs to obtain and set the camera focus mode and focus position. 5228 5229### setFocusAssist<sup>12+</sup> 5230 5231setFocusAssist(enabled: boolean): void 5232 5233Sets the focus assist. 5234 5235Before the setting, call [isFocusAssistSupported](#isfocusassistsupported12) to check whether the device supports the focus assist. 5236 5237**System API**: This is a system API. 5238 5239**System capability**: SystemCapability.Multimedia.Camera.Core 5240 5241**Parameters** 5242 5243| Name | Type | Mandatory| Description | 5244| -------- | ----------------------- | ---- | ------------------- | 5245| enabled | boolean | Yes | **true**: Enables the focus assist.<br>**false**: Disables the focus assist.| 5246 5247**Error codes** 5248 5249For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5250 5251| ID | Error Message | 5252| --------------- | --------------- | 5253| 202 | Not System Application. | 5254| 7400101 | Parameter missing or parameter type incorrect. | 5255| 7400103 | Session not config. | 5256 5257 5258**Example** 5259 5260```ts 5261import { BusinessError } from '@kit.BasicServicesKit'; 5262 5263function setFocusAssist(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5264 try { 5265 professionalPhotoSession.setFocusAssist(false); 5266 } catch (error) { 5267 // If the operation fails, error.code is returned and processed. 5268 let err = error as BusinessError; 5269 console.error(`The setFocusAssist call failed. error code: ${err.code}`); 5270 } 5271} 5272``` 5273 5274### getFocusAssist<sup>12+</sup> 5275 5276getFocusAssist(): boolean 5277 5278Checks whether the focus assist is enabled. 5279 5280**System API**: This is a system API. 5281 5282**System capability**: SystemCapability.Multimedia.Camera.Core 5283 5284**Return value** 5285 5286| Type | Description | 5287| ---------- | ----------------------------- | 5288| boolean | **true**: The focus assist is enabled.<br>**false**: The focus assist is disabled.| 5289 5290**Error codes** 5291 5292For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5293 5294| ID | Error Message | 5295| --------------- | --------------- | 5296| 7400103 | Session not config. | 5297| 202 | Not System Application. | 5298 5299**Example** 5300 5301```ts 5302import { BusinessError } from '@kit.BasicServicesKit'; 5303 5304function getFocusAssist(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5305 let isFocusAssistOpened: boolean; 5306 try { 5307 isFocusAssistOpened = professionalPhotoSession.getFocusAssist(); 5308 } catch (error) { 5309 // If the operation fails, error.code is returned and processed. 5310 let err = error as BusinessError; 5311 console.error(`The getFocusAssist call failed. error code: ${err.code}`); 5312 } 5313 return isFocusAssistOpened; 5314} 5315``` 5316 5317## ManualFocus<sup>12+</sup> 5318 5319Provides APIs related to manual focus operations. 5320 5321### setFocusDistance<sup>12+</sup> 5322 5323setFocusDistance(distance: number): void 5324 5325Sets the manual focus distance. 5326 5327**System API**: This is a system API. 5328 5329**System capability**: SystemCapability.Multimedia.Camera.Core 5330 5331**Parameters** 5332 5333| Name | Type | Mandatory| Description | 5334| -------- | ----------------------- | ---- | ------------------- | 5335| distance | number | Yes | Manual focus distance. The value is a floating point number in the range [0, 1]. The value **0** indicates a close-up shot, and **1** indicates a long shot.<br> | 5336 5337**Error codes** 5338 5339For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5340 5341| ID | Error Message | 5342| --------------- | --------------- | 5343| 202 | Not System Application. | 5344| 7400101 | Parameter missing or parameter type incorrect. | 5345| 7400103 | Session not config. | 5346 5347**Example** 5348 5349```ts 5350import { BusinessError } from '@kit.BasicServicesKit'; 5351 5352function setFocusDistance(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5353 try { 5354 let distance: number = 0.5; 5355 professionalPhotoSession.setFocusDistance(distance); 5356 } catch (error) { 5357 // If the operation fails, error.code is returned and processed. 5358 let err = error as BusinessError; 5359 console.error(`The setFocusDistance call failed. error code: ${err.code}`); 5360 } 5361} 5362``` 5363 5364### getFocusDistance<sup>12+</sup> 5365 5366getFocusDistance(): number 5367 5368Obtains the focus distance in use. 5369 5370**System API**: This is a system API. 5371 5372**System capability**: SystemCapability.Multimedia.Camera.Core 5373 5374**Return value** 5375 5376| Type | Description | 5377| ---------- | ----------------------------- | 5378| number | Normalized value of the focus distance.| 5379 5380**Error codes** 5381 5382For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5383 5384| ID | Error Message | 5385| --------------- | --------------- | 5386| 7400103 | Session not config. | 5387| 202 | Not System Application. | 5388 5389**Example** 5390 5391```ts 5392import { BusinessError } from '@kit.BasicServicesKit'; 5393 5394function getFocusDistance(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 5395 let distance: number = 0; 5396 try { 5397 distance = professionalPhotoSession.getFocusDistance(); 5398 } catch (error) { 5399 // If the operation fails, error.code is returned and processed. 5400 let err = error as BusinessError; 5401 console.error(`The getFocusDistance call failed. error code: ${err.code}`); 5402 } 5403 return distance; 5404} 5405``` 5406 5407## ManualIsoQuery<sup>12+</sup> 5408 5409Provides APIs to check whether a camera device supports manual ISO setting and obtain the ISO range supported by the device. 5410 5411### isManualIsoSupported<sup>12+</sup> 5412 5413isManualIsoSupported(): boolean 5414 5415Checks whether manual ISO setting is supported. 5416 5417**System API**: This is a system API. 5418 5419**System capability**: SystemCapability.Multimedia.Camera.Core 5420 5421**Return value** 5422 5423| Type | Description | 5424| ---------- | ----------------------------- | 5425| boolean | **true**: Manual ISO setting is supported.<br>**false**: Manual ISO setting is not supported. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 5426 5427**Error codes** 5428 5429For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5430 5431| ID | Error Message | 5432| --------------- | --------------- | 5433| 7400103 | Session not config. | 5434| 202 | Not System Application. | 5435 5436**Example** 5437 5438```ts 5439import { BusinessError } from '@kit.BasicServicesKit'; 5440 5441function isManualIsoSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5442 let status: boolean = false; 5443 try { 5444 status = professionalPhotoSession.isManualIsoSupported(); 5445 } catch (error) { 5446 // If the operation fails, error.code is returned and processed. 5447 let err = error as BusinessError; 5448 console.error(`The isManualIsoSupported call failed. error code: ${err.code}`); 5449 } 5450 return status; 5451} 5452``` 5453 5454### getIsoRange<sup>12+</sup> 5455 5456getIsoRange(): Array\<number\> 5457 5458Obtains the supported ISO range. 5459 5460**System API**: This is a system API. 5461 5462**System capability**: SystemCapability.Multimedia.Camera.Core 5463 5464**Return value** 5465 5466| Type | Description | 5467| ---------- | ----------------------------- | 5468| Array\<number\> | ISO range. The value range is [50, 100, ..., 6400]. The actual value depends on the bottom-layer capability. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 5469 5470**Error codes** 5471 5472For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5473 5474| ID | Error Message | 5475| --------------- | --------------- | 5476| 202 | Not System Application. | 5477| 7400103 | Session not config. | 5478 5479**Example** 5480 5481```ts 5482import { BusinessError } from '@kit.BasicServicesKit'; 5483 5484function getIsoRange(professionalPhotoSession: camera.ProfessionalPhotoSession): Array<number> { 5485 let isoRange: Array<number> = []; 5486 try { 5487 isoRange = professionalPhotoSession.getIsoRange(); 5488 } catch (error) { 5489 // If the operation fails, error.code is returned and processed. 5490 let err = error as BusinessError; 5491 console.error(`The getIsoRange call failed. error code: ${err.code}`); 5492 } 5493 return isoRange; 5494} 5495``` 5496 5497## ManualIso<sup>12+</sup> 5498 5499ManualIso extends [ManualIsoQuery](#manualisoquery12) 5500 5501Provides APIs for obtaining and setting the manual ISO (sensitivity) of a camera device. 5502 5503### setIso<sup>12+</sup> 5504setIso(iso: number): void 5505 5506Sets the ISO. 5507 5508**NOTE**: When the ISO is set to 0, automatic ISO is used. 5509 5510**System API**: This is a system API. 5511 5512**System capability**: SystemCapability.Multimedia.Camera.Core 5513 5514**Parameters** 5515 5516| Name | Type | Mandatory| Description | 5517| -------- | ----------------------- | ---- | ------------------- | 5518| iso | number | Yes | ISO.| 5519 5520**Error codes** 5521 5522For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5523 5524| ID | Error Message | 5525| --------------- | --------------- | 5526| 202 | Not System Application. | 5527| 7400101 | Parameter missing or parameter type incorrect. | 5528| 7400103 | Session not config. | 5529 5530**Example** 5531 5532```ts 5533import { BusinessError } from '@kit.BasicServicesKit'; 5534 5535function setIso(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5536 try { 5537 let iso: number = 200; 5538 professionalPhotoSession.setIso(iso); 5539 } catch (error) { 5540 // If the operation fails, error.code is returned and processed. 5541 let err = error as BusinessError; 5542 console.error(`The setIso call failed. error code: ${err.code}`); 5543 } 5544} 5545``` 5546 5547### getIso<sup>12+</sup> 5548 5549getIso(): number 5550 5551Obtains the ISO in use. 5552 5553**System API**: This is a system API. 5554 5555**System capability**: SystemCapability.Multimedia.Camera.Core 5556 5557**Return value** 5558 5559| Type | Description | 5560| ---------- | ----------------------------- | 5561| number | ISO.| 5562 5563**Error codes** 5564 5565For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5566 5567| ID | Error Message | 5568| --------------- | --------------- | 5569| 202 | Not System Application. | 5570| 7400103 | Session not config. | 5571 5572**Example** 5573 5574```ts 5575import { BusinessError } from '@kit.BasicServicesKit'; 5576 5577function getIso(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 5578 let iso: number = 0; 5579 try { 5580 iso = professionalPhotoSession.getIso(); 5581 } catch (error) { 5582 // If the operation fails, error.code is returned and processed. 5583 let err = error as BusinessError; 5584 console.error(`The getIso call failed. error code: ${err.code}`); 5585 } 5586 return iso; 5587} 5588``` 5589 5590## WhiteBalanceMode<sup>12+</sup> 5591 5592Enumerates the white balance modes. 5593 5594**System API**: This is a system API. 5595 5596**System capability**: SystemCapability.Multimedia.Camera.Core 5597 5598| Name | Value | Description | 5599| ----------------------------- | ---- | ----------- | 5600| AUTO | 0 | Automatic.| 5601| CLOUDY | 1 | Cloudy.| 5602| INCANDESCENT | 2 | Incandescent light.| 5603| FLUORESCENT | 3 | Fluorescence light.| 5604| DAYLIGHT | 4 | Daylight.| 5605| MANUAL | 5 | Manual.| 5606 5607## WhiteBalanceQuery<sup>12+</sup> 5608 5609Provides APIs to check whether a white balance mode is supported and obtain the white balance mode range supported. 5610 5611### isWhiteBalanceModeSupported<sup>12+</sup> 5612 5613isWhiteBalanceModeSupported(mode: WhiteBalanceMode): boolean 5614 5615Checks whether a white balance mode is supported. 5616 5617**System API**: This is a system API. 5618 5619**System capability**: SystemCapability.Multimedia.Camera.Core 5620**Parameters** 5621 5622| Name | Type | Mandatory | Description | 5623| -------- | -------------------------------| ---- | ----------------------------- | 5624| mode | [WhiteBalanceMode](#whitebalancemode12) | Yes | White balance mode. | 5625 5626**Return value** 5627 5628| Type | Description | 5629| ---------- | ----------------------------- | 5630| boolean | **true**: The white balance mode is supported.<br>**false**: The white balance mode is not supported. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 5631 5632**Error codes** 5633 5634For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5635 5636| ID | Error Message | 5637| --------------- | --------------- | 5638| 202 | Not System Application. | 5639| 7400101 | Parameter missing or parameter type incorrect. | 5640| 7400103 | Session not config. | 5641 5642**Example** 5643 5644```ts 5645import { BusinessError } from '@kit.BasicServicesKit'; 5646 5647function isWhiteBalanceModeSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5648 let status: boolean = false; 5649 try { 5650 let mode: WhiteBalanceMode = camera.WhiteBalanceMode.DAYLIGHT; 5651 status = professionalPhotoSession.isWhiteBalanceModeSupported(mode); 5652 } catch (error) { 5653 // If the operation fails, error.code is returned and processed. 5654 let err = error as BusinessError; 5655 console.error(`The isWhiteBalanceModeSupported call failed. error code: ${err.code}`); 5656 } 5657 return status; 5658} 5659``` 5660 5661### getWhiteBalanceRange<sup>12+</sup> 5662 5663getWhiteBalanceRange(): Array\<number\> 5664 5665Obtains the white balance range, in which users can manually adjust the white balance. 5666 5667**System API**: This is a system API. 5668 5669**System capability**: SystemCapability.Multimedia.Camera.Core 5670 5671**Return value** 5672 5673| Type | Description | 5674| ---------- | ----------------------------- | 5675| Array\<number\> | White balance range, for example, [2800, ...,10000], in units of K (Kelvin). The actual value depends on the bottom-layer capability. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 5676 5677**Error codes** 5678 5679For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5680 5681| ID | Error Message | 5682| --------------- | --------------- | 5683| 202 | Not System Application. | 5684| 7400103 | Session not config. | 5685 5686**Example** 5687 5688```ts 5689import { BusinessError } from '@kit.BasicServicesKit'; 5690 5691function getWhiteBalanceRange(professionalPhotoSession: camera.ProfessionalPhotoSession): Array<number> { 5692 let range: Array<number> = []; 5693 try { 5694 range = professionalPhotoSession.getWhiteBalanceRange(); 5695 } catch (error) { 5696 // If the operation fails, error.code is returned and processed. 5697 let err = error as BusinessError; 5698 console.error(`The getWhiteBalanceRange call failed. error code: ${err.code}`); 5699 } 5700 return range; 5701} 5702``` 5703 5704## WhiteBalance<sup>12+</sup> 5705 5706WhiteBalance extends [WhiteBalanceQuery](#whitebalancequery12) 5707 5708Provides APIs to process white balance, including obtaining and setting the white balance mode and white balance value. 5709 5710### setWhiteBalanceMode<sup>12+</sup> 5711 5712setWhiteBalanceMode(mode: WhiteBalanceMode): void 5713 5714Sets a white balance mode. 5715 5716Before the setting, call [isWhiteBalanceModeSupported](#iswhitebalancemodesupported12) to check whether the target white balance mode is supported. 5717 5718**System API**: This is a system API. 5719 5720**System capability**: SystemCapability.Multimedia.Camera.Core 5721 5722**Parameters** 5723 5724| Name | Type | Mandatory| Description | 5725| -------- | -------------------------------| ---- | ----------------------- | 5726| mode | [WhiteBalanceMode](#whitebalancemode12) | Yes | White balance mode. | 5727 5728**Error codes** 5729 5730For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5731 5732| ID | Error Message | 5733| --------------- | --------------- | 5734| 202 | Not System Application. | 5735| 7400101 | Parameter missing or parameter type incorrect. | 5736| 7400103 | Session not config. | 5737 5738**Example** 5739 5740```ts 5741import { BusinessError } from '@kit.BasicServicesKit'; 5742 5743function setWhiteBalanceMode(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5744 try { 5745 professionalPhotoSession.setWhiteBalanceMode(camera.WhiteBalanceMode.DAYLIGHT); 5746 } catch (error) { 5747 // If the operation fails, error.code is returned and processed. 5748 let err = error as BusinessError; 5749 console.error(`The setWhiteBalanceMode call failed. error code: ${err.code}`); 5750 } 5751} 5752``` 5753 5754### getWhiteBalanceMode<sup>12+</sup> 5755 5756getWhiteBalanceMode(): WhiteBalanceMode 5757 5758Obtains the white balance mode in use. 5759 5760**System API**: This is a system API. 5761 5762**System capability**: SystemCapability.Multimedia.Camera.Core 5763 5764**Return value** 5765 5766| Type | Description | 5767| ---------- | ----------------------------- | 5768| [WhiteBalanceMode](#whitebalancemode12) | White balance mode in use. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 5769 5770**Error codes** 5771 5772For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5773 5774| ID | Error Message | 5775| --------------- | --------------- | 5776| 202 | Not System Application. | 5777| 7400103 | Session not config. | 5778 5779**Example** 5780 5781```ts 5782import { BusinessError } from '@kit.BasicServicesKit'; 5783 5784function getWhiteBalanceMode(professionalPhotoSession: camera.ProfessionalPhotoSession): camera.WhiteBalanceMode | undefined { 5785 let whiteBalanceMode: camera.WhiteBalanceMode | undefined = undefined; 5786 try { 5787 whiteBalanceMode = professionalPhotoSession.getWhiteBalanceMode(); 5788 } catch (error) { 5789 // If the operation fails, error.code is returned and processed. 5790 let err = error as BusinessError; 5791 console.error(`The getWhiteBalanceMode call failed. error code: ${err.code}`); 5792 } 5793 return whiteBalanceMode; 5794} 5795``` 5796 5797### setWhiteBalance<sup>12+</sup> 5798 5799setWhiteBalance(whiteBalance: number): void 5800 5801Sets a white balance value. 5802 5803**System API**: This is a system API. 5804 5805**System capability**: SystemCapability.Multimedia.Camera.Core 5806 5807**Parameters** 5808 5809| Name | Type | Mandatory| Description | 5810| -------- | ----------------------- | ---- | ------------------- | 5811| whiteBalance | number | Yes | White balance value.| 5812 5813**Error codes** 5814 5815For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5816 5817| ID | Error Message | 5818| --------------- | --------------- | 5819| 202 | Not System Application. | 5820| 7400101 | Parameter missing or parameter type incorrect. | 5821| 7400103 | Session not config. | 5822 5823**Example** 5824 5825```ts 5826import { BusinessError } from '@kit.BasicServicesKit'; 5827 5828function setWhiteBalance(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5829 try { 5830 let whiteBalance: number = 1000; 5831 professionalPhotoSession.setWhiteBalance(whiteBalance); 5832 } catch (error) { 5833 // If the operation fails, error.code is returned and processed. 5834 let err = error as BusinessError; 5835 console.error(`The setWhiteBalance call failed. error code: ${err.code}`); 5836 } 5837} 5838``` 5839 5840### getWhiteBalance<sup>12+</sup> 5841 5842getWhiteBalance(): number 5843 5844Obtains the current white balance value. 5845 5846**System API**: This is a system API. 5847 5848**System capability**: SystemCapability.Multimedia.Camera.Core 5849 5850**Return value** 5851 5852| Type | Description | 5853| ---------- | ----------------------------- | 5854| number | White balance value.| 5855 5856**Error codes** 5857 5858For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5859 5860| ID | Error Message | 5861| --------------- | --------------- | 5862| 202 | Not System Application. | 5863| 7400103 | Session not config. | 5864 5865**Example** 5866 5867```ts 5868import { BusinessError } from '@kit.BasicServicesKit'; 5869 5870function getWhiteBalance(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 5871 let whiteBalance: number = 0; 5872 try { 5873 whiteBalance = professionalPhotoSession.getWhiteBalance(); 5874 } catch (error) { 5875 // If the operation fails, error.code is returned and processed. 5876 let err = error as BusinessError; 5877 console.error(`The getWhiteBalance call failed. error code: ${err.code}`); 5878 } 5879 return whiteBalance; 5880} 5881``` 5882 5883## ProfessionalPhotoSession<sup>12+</sup> 5884 5885ProfessionalPhotoSession extends Session, AutoExposure, ManualExposure, Focus, ManualFocus, WhiteBalance, ManualIso, Flash, Zoom, ColorEffect, Aperture 5886 5887Implements a professional photo session, which sets the parameters of the professional photo mode and saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera. It inherits from [Session](js-apis-camera.md#session12). 5888 5889### on('error')<sup>12+</sup> 5890 5891on(type: 'error', callback: ErrorCallback): void 5892 5893Subscribes to **ProfessionalPhotoSession** error events. This API uses an asynchronous callback to return the result. 5894 5895**System API**: This is a system API. 5896 5897**System capability**: SystemCapability.Multimedia.Camera.Core 5898 5899**Parameters** 5900 5901| Name | Type | Mandatory| Description | 5902| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 5903| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as [beginConfig](js-apis-camera.md#beginconfig11), [commitConfig](js-apis-camera.md#commitconfig11-1), and [addInput](js-apis-camera.md#addinput11).| 5904| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode).| 5905 5906**Error codes** 5907 5908For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5909 5910| ID | Error Message | 5911|---------| --------------- | 5912| 202 | Not System Application. | 5913 5914**Example** 5915 5916```ts 5917import { BusinessError } from '@kit.BasicServicesKit'; 5918 5919function callback(err: BusinessError): void { 5920 console.error(`Professional photo session error code: ${err.code}`); 5921} 5922 5923function registerSessionError(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5924 professionalPhotoSession.on('error', callback); 5925} 5926``` 5927 5928### off('error')<sup>12+</sup> 5929 5930off(type: 'error', callback?: ErrorCallback): void 5931 5932Unsubscribes from **ProfessionalPhotoSession** error events. 5933 5934**System API**: This is a system API. 5935 5936**System capability**: SystemCapability.Multimedia.Camera.Core 5937 5938**Parameters** 5939 5940| Name | Type | Mandatory| Description | 5941| -------- | ------------------------ | ---- | ------------------------------ | 5942| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 5943| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| No | Callback, which is optional. If a callback function is passed in, it is an anonymous function. | 5944 5945**Error codes** 5946 5947For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5948 5949| ID | Error Message | 5950|---------| --------------- | 5951| 202 | Not System Application. | 5952 5953**Example** 5954 5955```ts 5956function unregisterSessionError(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5957 professionalPhotoSession.off('error'); 5958} 5959``` 5960 5961### on('focusStateChange')<sup>12+</sup> 5962 5963on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 5964 5965Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 5966 5967**System API**: This is a system API. 5968 5969**System capability**: SystemCapability.Multimedia.Camera.Core 5970 5971**Parameters** 5972 5973| Name | Type | Mandatory| Description | 5974| -------- | ---------------- | ---- | ------------------------ | 5975| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.| 5976| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 5977 5978**Error codes** 5979 5980For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5981 5982| ID | Error Message | 5983|---------| --------------- | 5984| 202 | Not System Application. | 5985 5986**Example** 5987 5988```ts 5989import { BusinessError } from '@kit.BasicServicesKit'; 5990 5991function callback(err: BusinessError, focusState: camera.FocusState): void { 5992 if (err !== undefined && err.code !== 0) { 5993 console.error(`Callback Error, errorCode: ${err.code}`); 5994 return; 5995 } 5996 console.info(`Focus state: ${focusState}`); 5997} 5998 5999function registerFocusStateChange(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6000 professionalPhotoSession.on('focusStateChange', callback); 6001} 6002``` 6003 6004### off('focusStateChange')<sup>12+</sup> 6005 6006off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 6007 6008Unsubscribes from focus state change events. 6009 6010**System API**: This is a system API. 6011 6012**System capability**: SystemCapability.Multimedia.Camera.Core 6013 6014**Parameters** 6015 6016| Name | Type | Mandatory| Description | 6017| -------- | ----------------------------------------- | ---- | ------------------------ | 6018| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 6019| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('focusStateChange')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 6020 6021**Error codes** 6022 6023For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6024 6025| ID | Error Message | 6026|---------| --------------- | 6027| 202 | Not System Application. | 6028 6029**Example** 6030 6031```ts 6032function unregisterFocusStateChange(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6033 professionalPhotoSession.off('focusStateChange'); 6034} 6035``` 6036 6037### on('smoothZoomInfoAvailable')<sup>12+</sup> 6038 6039on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 6040 6041Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 6042 6043**System API**: This is a system API. 6044 6045**System capability**: SystemCapability.Multimedia.Camera.Core 6046 6047**Parameters** 6048 6049| Name | Type | Mandatory| Description | 6050| -------- | ----------------------- | ---- | ------------------------ | 6051| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 6052| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 6053 6054**Error codes** 6055 6056For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6057 6058| ID | Error Message | 6059|---------| --------------- | 6060| 202 | Not System Application. | 6061 6062**Example** 6063 6064```ts 6065import { BusinessError } from '@kit.BasicServicesKit'; 6066 6067function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 6068 if (err !== undefined && err.code !== 0) { 6069 console.error(`Callback Error, errorCode: ${err.code}`); 6070 return; 6071 } 6072 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 6073} 6074 6075function registerSmoothZoomInfo(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6076 professionalPhotoSession.on('smoothZoomInfoAvailable', callback); 6077} 6078``` 6079 6080### off('smoothZoomInfoAvailable')<sup>12+</sup> 6081 6082off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 6083 6084Unsubscribes from smooth zoom state change events. 6085 6086**System API**: This is a system API. 6087 6088**System capability**: SystemCapability.Multimedia.Camera.Core 6089 6090**Parameters** 6091 6092| Name | Type | Mandatory| Description | 6093| -------- | ----------------------------------------- | ---- | ------------------------ | 6094| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 6095| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('smoothZoomInfoAvailable')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 6096 6097**Error codes** 6098 6099For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6100 6101| ID | Error Message | 6102|---------| --------------- | 6103| 202 | Not System Application. | 6104 6105**Example** 6106 6107```ts 6108function unregisterSmoothZoomInfo(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6109 professionalPhotoSession.off('smoothZoomInfoAvailable'); 6110} 6111``` 6112 6113### on('isoInfoChange')<sup>12+</sup> 6114 6115on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 6116 6117Subscribes to automatic ISO change events to obtain real-time ISO information. This API uses an asynchronous callback to return the result. 6118 6119**System API**: This is a system API. 6120 6121**System capability**: SystemCapability.Multimedia.Camera.Core 6122 6123**Parameters** 6124 6125| Name | Type | Mandatory| Description | 6126| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6127| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 6128| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| Yes | Callback used to return the ISO information. | 6129 6130**Error codes** 6131 6132| ID| Error Message | 6133| ------- | ---------------------- | 6134| 202 | Not System Application. | 6135 6136**Example** 6137 6138```ts 6139import { BusinessError } from '@kit.BasicServicesKit'; 6140 6141function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 6142 if (err !== undefined && err.code !== 0) { 6143 console.error(`Callback Error, errorCode: ${err.code}`); 6144 return; 6145 } 6146 console.log(`ISO value: ${info.iso}`); 6147} 6148 6149function registerIsoInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6150 professionalPhotoSession.on('isoInfoChange', isoInfoCallback); 6151} 6152``` 6153 6154### off('isoInfoChange')<sup>12+</sup> 6155 6156off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 6157 6158Unsubscribes from automatic ISO change events. 6159 6160**System API**: This is a system API. 6161 6162**System capability**: SystemCapability.Multimedia.Camera.Core 6163 6164**Parameters** 6165 6166| Name | Type | Mandatory| Description | 6167| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6168| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 6169| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('isoInfoChange')**.| 6170 6171**Error codes** 6172 6173| ID| Error Message | 6174| ------- | ---------------------- | 6175| 202 | Not System Application. | 6176 6177**Example** 6178 6179```ts 6180function unregisterIsoInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6181 professionalPhotoSession.off('isoInfoChange'); 6182} 6183``` 6184 6185### on('exposureInfoChange')<sup>12+</sup> 6186 6187on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 6188 6189Subscribes to exposure information change events to obtain the exposure information. This API uses an asynchronous callback to return the result. 6190 6191**System API**: This is a system API. 6192 6193**System capability**: SystemCapability.Multimedia.Camera.Core 6194 6195**Parameters** 6196 6197| Name | Type | Mandatory| Description | 6198| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6199| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 6200| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| Yes | Callback used to return the exposure information. | 6201 6202**Error codes** 6203 6204| ID| Error Message | 6205| ------- | ---------------------- | 6206| 202 | Not System Application. | 6207 6208**Example** 6209 6210```ts 6211import { BusinessError } from '@kit.BasicServicesKit'; 6212 6213function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 6214 if (err !== undefined && err.code !== 0) { 6215 console.error(`Callback Error, errorCode: ${err.code}`); 6216 return; 6217 } 6218 console.log(`exposureTimeValue: ${info.exposureTime}`); 6219} 6220 6221function registerExposureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6222 professionalPhotoSession.on('exposureInfoChange', exposureInfoCallback); 6223} 6224``` 6225 6226### off('exposureInfoChange')<sup>12+</sup> 6227 6228off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 6229 6230Unsubscribes from exposure information change events. 6231 6232**System API**: This is a system API. 6233 6234**System capability**: SystemCapability.Multimedia.Camera.Core 6235 6236**Parameters** 6237 6238| Name | Type | Mandatory| Description | 6239| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6240| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 6241| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('exposureInfoChange')**.| 6242 6243**Error codes** 6244 6245| ID| Error Message | 6246| ------- | ---------------------- | 6247| 202 | Not System Application. | 6248 6249**Example** 6250 6251```ts 6252function unregisterExposureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6253 professionalPhotoSession.off('exposureInfoChange'); 6254} 6255``` 6256 6257### on('apertureInfoChange')<sup>12+</sup> 6258 6259on(type: 'apertureInfoChange', callback: AsyncCallback\<ApertureInfo\>): void 6260 6261Subscribes to aperture change events to obtain the real-time aperture information. This API uses an asynchronous callback to return the result. 6262 6263**System API**: This is a system API. 6264 6265**System capability**: SystemCapability.Multimedia.Camera.Core 6266 6267**Parameters** 6268 6269| Name | Type | Mandatory| Description | 6270| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6271| type | string | Yes | Event type. The value is fixed at **'apertureInfoChange'**. | 6272| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| Yes | Callback used to return the aperture information. | 6273 6274**Error codes** 6275 6276| ID| Error Message | 6277| ------- | ---------------------- | 6278| 202 | Not System Application. | 6279 6280**Example** 6281 6282```ts 6283import { BusinessError } from '@kit.BasicServicesKit'; 6284 6285function apertureInfoCallback(err: BusinessError, info: camera.ApertureInfo): void { 6286 if (err !== undefined && err.code !== 0) { 6287 console.error(`Callback Error, errorCode: ${err.code}`); 6288 return; 6289 } 6290 console.log(`Aperture value: ${info.aperture}`); 6291} 6292 6293function registerApertureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6294 professionalPhotoSession.on('apertureInfoChange', apertureInfoCallback); 6295} 6296``` 6297 6298### off('apertureInfoChange')<sup>12+</sup> 6299 6300off(type: 'apertureInfoChange', callback?: AsyncCallback\<ApertureInfo\>): void 6301 6302Unsubscribes from aperture change events. 6303 6304**System API**: This is a system API. 6305 6306**System capability**: SystemCapability.Multimedia.Camera.Core 6307 6308**Parameters** 6309 6310| Name | Type | Mandatory| Description | 6311| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6312| type | string | Yes | Event type. The value is fixed at **'apertureInfoChange'**. | 6313| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('apertureInfoChange')**.| 6314 6315**Error codes** 6316 6317| ID| Error Message | 6318| ------- | ---------------------- | 6319| 202 | Not System Application. | 6320 6321**Example** 6322 6323```ts 6324function unregisterApertureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6325 professionalPhotoSession.off('apertureInfoChange'); 6326} 6327``` 6328 6329### on('luminationInfoChange')<sup>12+</sup> 6330 6331on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 6332 6333Subscribes to illumination change events to obtain real-time illumination information. This API uses an asynchronous callback to return the result. 6334 6335**System API**: This is a system API. 6336 6337**System capability**: SystemCapability.Multimedia.Camera.Core 6338 6339**Parameters** 6340 6341| Name | Type | Mandatory| Description | 6342| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6343| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 6344| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| Yes | Callback used to return the illumination information. | 6345 6346**Error codes** 6347 6348| ID| Error Message | 6349| ------- | ---------------------- | 6350| 202 | Not System Application. | 6351 6352**Example** 6353 6354```ts 6355import { BusinessError } from '@kit.BasicServicesKit'; 6356 6357function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 6358 if (err !== undefined && err.code !== 0) { 6359 console.error(`Callback Error, errorCode: ${err.code}`); 6360 return; 6361 } 6362 console.log(`Lumination: ${info.lumination}`); 6363} 6364 6365function registerLuminationInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6366 professionalPhotoSession.on('luminationInfoChange', luminationInfoCallback); 6367} 6368``` 6369 6370### off('luminationInfoChange')<sup>12+</sup> 6371 6372off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 6373 6374Unsubscribes from illumination change events. 6375 6376**System API**: This is a system API. 6377 6378**System capability**: SystemCapability.Multimedia.Camera.Core 6379 6380**Parameters** 6381 6382| Name | Type | Mandatory| Description | 6383| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6384| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 6385| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('luminationInfoChange')**.| 6386 6387**Error codes** 6388 6389| ID| Error Message | 6390| ------- | ---------------------- | 6391| 202 | Not System Application. | 6392 6393**Example** 6394 6395```ts 6396function unregisterLuminationInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6397 professionalPhotoSession.off('luminationInfoChange'); 6398} 6399``` 6400 6401## ProfessionalVideoSession<sup>12+</sup> 6402 6403ProfessionalVideoSession extends Session, AutoExposure, ManualExposure, Focus, ManualFocus, WhiteBalance, ManualIso, Flash, Zoom, ColorEffect, Aperture 6404 6405Implements a professional video session, which sets the parameters of the professional video mode and saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera. It inherits from [Session](js-apis-camera.md#session12). 6406 6407### on('error')<sup>12+</sup> 6408 6409on(type: 'error', callback: ErrorCallback): void 6410 6411Subscribes to **ProfessionalVideo** error events. This API uses an asynchronous callback to return the result. 6412 6413**System API**: This is a system API. 6414 6415**System capability**: SystemCapability.Multimedia.Camera.Core 6416 6417**Parameters** 6418 6419| Name | Type | Mandatory| Description | 6420| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 6421| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as [beginConfig](js-apis-camera.md#beginconfig11), [commitConfig](js-apis-camera.md#commitconfig11-1), and [addInput](js-apis-camera.md#addinput11).| 6422| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode).| 6423 6424**Error codes** 6425 6426For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6427 6428| ID | Error Message | 6429|---------| --------------- | 6430| 202 | Not System Application. | 6431 6432**Example** 6433 6434```ts 6435import { BusinessError } from '@kit.BasicServicesKit'; 6436 6437function callback(err: BusinessError): void { 6438 console.error(`Professional video session error code: ${err.code}`); 6439} 6440 6441function registerSessionError(professionalVideoSession: camera.ProfessionalVideoSession): void { 6442 professionalVideoSession.on('error', callback); 6443} 6444``` 6445 6446### off('error')<sup>12+</sup> 6447 6448off(type: 'error', callback?: ErrorCallback): void 6449 6450Unsubscribes from **ProfessionalVideo** error events. 6451 6452**System API**: This is a system API. 6453 6454**System capability**: SystemCapability.Multimedia.Camera.Core 6455 6456**Parameters** 6457 6458| Name | Type | Mandatory| Description | 6459| -------- | ------------------------ | ---- | ------------------------------ | 6460| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 6461| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| No | Callback, which is optional. If a callback function is passed in, it is an anonymous function. | 6462 6463**Error codes** 6464 6465For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6466 6467| ID | Error Message | 6468|---------| --------------- | 6469| 202 | Not System Application. | 6470 6471**Example** 6472 6473```ts 6474function unregisterSessionError(professionalVideoSession: camera.ProfessionalVideoSession): void { 6475 professionalVideoSession.off('error'); 6476} 6477``` 6478 6479### on('focusStateChange')<sup>12+</sup> 6480 6481on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 6482 6483Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 6484 6485**System API**: This is a system API. 6486 6487**System capability**: SystemCapability.Multimedia.Camera.Core 6488 6489**Parameters** 6490 6491| Name | Type | Mandatory| Description | 6492| -------- | ---------------- | ---- | ------------------------ | 6493| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.| 6494| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 6495 6496**Error codes** 6497 6498For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6499 6500| ID | Error Message | 6501|---------| --------------- | 6502| 202 | Not System Application. | 6503 6504**Example** 6505 6506```ts 6507import { BusinessError } from '@kit.BasicServicesKit'; 6508 6509function callback(err: BusinessError, focusState: camera.FocusState): void { 6510 if (err !== undefined && err.code !== 0) { 6511 console.error(`Callback Error, errorCode: ${err.code}`); 6512 return; 6513 } 6514 console.info(`Focus state: ${focusState}`); 6515} 6516 6517function registerFocusStateChange(professionalVideoSession: camera.ProfessionalVideoSession): void { 6518 professionalVideoSession.on('focusStateChange', callback); 6519} 6520``` 6521 6522### off('focusStateChange')<sup>12+</sup> 6523 6524off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 6525 6526Unsubscribes from focus state change events. 6527 6528**System API**: This is a system API. 6529 6530**System capability**: SystemCapability.Multimedia.Camera.Core 6531 6532**Parameters** 6533 6534| Name | Type | Mandatory| Description | 6535| -------- | ----------------------------------------- | ---- | ------------------------ | 6536| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 6537| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('focusStateChange')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 6538 6539**Error codes** 6540 6541For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6542 6543| ID | Error Message | 6544|---------| --------------- | 6545| 202 | Not System Application. | 6546 6547**Example** 6548 6549```ts 6550function unregisterFocusStateChange(professionalVideoSession: camera.ProfessionalVideoSession): void { 6551 professionalVideoSession.off('focusStateChange'); 6552} 6553``` 6554 6555### on('smoothZoomInfoAvailable')<sup>12+</sup> 6556 6557on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 6558 6559Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 6560 6561**System API**: This is a system API. 6562 6563**System capability**: SystemCapability.Multimedia.Camera.Core 6564 6565**Parameters** 6566 6567| Name | Type | Mandatory| Description | 6568| -------- | ----------------------- | ---- | ------------------------ | 6569| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 6570| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 6571 6572**Error codes** 6573 6574For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6575 6576| ID | Error Message | 6577|---------| --------------- | 6578| 202 | Not System Application. | 6579 6580**Example** 6581 6582```ts 6583import { BusinessError } from '@kit.BasicServicesKit'; 6584 6585function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 6586 if (err !== undefined && err.code !== 0) { 6587 console.error(`Callback Error, errorCode: ${err.code}`); 6588 return; 6589 } 6590 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 6591} 6592 6593function registerSmoothZoomInfo(professionalVideoSession: camera.ProfessionalVideoSession): void { 6594 professionalVideoSession.on('smoothZoomInfoAvailable', callback); 6595} 6596``` 6597 6598### off('smoothZoomInfoAvailable')<sup>12+</sup> 6599 6600off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 6601 6602Unsubscribes from smooth zoom state change events. 6603 6604**System API**: This is a system API. 6605 6606**System capability**: SystemCapability.Multimedia.Camera.Core 6607 6608**Parameters** 6609 6610| Name | Type | Mandatory| Description | 6611| -------- | ----------------------------------------- | ---- | ------------------------ | 6612| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 6613| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('smoothZoomInfoAvailable')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 6614 6615**Error codes** 6616 6617For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6618 6619| ID | Error Message | 6620|---------| --------------- | 6621| 202 | Not System Application. | 6622 6623**Example** 6624 6625```ts 6626function unregisterSmoothZoomInfo(professionalVideoSession: camera.ProfessionalVideoSession): void { 6627 professionalVideoSession.off('smoothZoomInfoAvailable'); 6628} 6629``` 6630 6631### on('isoInfoChange')<sup>12+</sup> 6632 6633on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 6634 6635Subscribes to automatic ISO change events to obtain real-time ISO information. This API uses an asynchronous callback to return the result. 6636 6637**System API**: This is a system API. 6638 6639**System capability**: SystemCapability.Multimedia.Camera.Core 6640 6641**Parameters** 6642 6643| Name | Type | Mandatory| Description | 6644| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6645| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 6646| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| Yes | Callback used to return the ISO information. | 6647 6648**Error codes** 6649 6650| ID| Error Message | 6651| ------- | ---------------------- | 6652| 202 | Not System Application. | 6653 6654**Example** 6655 6656```ts 6657import { BusinessError } from '@kit.BasicServicesKit'; 6658 6659function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 6660 if (err !== undefined && err.code !== 0) { 6661 console.error(`Callback Error, errorCode: ${err.code}`); 6662 return; 6663 } 6664 console.log(`ISO value: ${info.iso}`); 6665} 6666 6667function registerIsoInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6668 professionalVideoSession.on('isoInfoChange', isoInfoCallback); 6669} 6670``` 6671 6672### off('isoInfoChange')<sup>12+</sup> 6673 6674off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 6675 6676Unsubscribes from automatic ISO change events. 6677 6678**System API**: This is a system API. 6679 6680**System capability**: SystemCapability.Multimedia.Camera.Core 6681 6682**Parameters** 6683 6684| Name | Type | Mandatory| Description | 6685| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6686| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 6687| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('isoInfoChange')**.| 6688 6689**Error codes** 6690 6691| ID| Error Message | 6692| ------- | ---------------------- | 6693| 202 | Not System Application. | 6694 6695**Example** 6696 6697```ts 6698function unregisterIsoInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6699 professionalVideoSession.off('isoInfoChange'); 6700} 6701``` 6702 6703### on('exposureInfoChange')<sup>12+</sup> 6704 6705on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 6706 6707Subscribes to exposure information change events to obtain the exposure information. This API uses an asynchronous callback to return the result. 6708 6709**System API**: This is a system API. 6710 6711**System capability**: SystemCapability.Multimedia.Camera.Core 6712 6713**Parameters** 6714 6715| Name | Type | Mandatory| Description | 6716| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6717| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 6718| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| Yes | Callback used to return the exposure information. | 6719 6720**Error codes** 6721 6722| ID| Error Message | 6723| ------- | ---------------------- | 6724| 202 | Not System Application. | 6725 6726**Example** 6727 6728```ts 6729import { BusinessError } from '@kit.BasicServicesKit'; 6730 6731function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 6732 if (err !== undefined && err.code !== 0) { 6733 console.error(`Callback Error, errorCode: ${err.code}`); 6734 return; 6735 } 6736 console.log(`exposureTimeValue: ${info.exposureTime}`); 6737} 6738 6739function registerExposureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6740 professionalVideoSession.on('exposureInfoChange', exposureInfoCallback); 6741} 6742``` 6743 6744### off('exposureInfoChange')<sup>12+</sup> 6745 6746off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 6747 6748Unsubscribes from exposure information change events. 6749 6750**System API**: This is a system API. 6751 6752**System capability**: SystemCapability.Multimedia.Camera.Core 6753 6754**Parameters** 6755 6756| Name | Type | Mandatory| Description | 6757| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6758| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 6759| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('exposureInfoChange')**.| 6760 6761**Error codes** 6762 6763| ID| Error Message | 6764| ------- | ---------------------- | 6765| 202 | Not System Application. | 6766 6767**Example** 6768 6769```ts 6770function unregisterExposureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6771 professionalVideoSession.off('exposureInfoChange'); 6772} 6773``` 6774 6775### on('apertureInfoChange')<sup>12+</sup> 6776 6777on(type: 'apertureInfoChange', callback: AsyncCallback\<ApertureInfo\>): void 6778 6779Subscribes to aperture change events to obtain the aperture information. This API uses an asynchronous callback to return the result. 6780 6781**System API**: This is a system API. 6782 6783**System capability**: SystemCapability.Multimedia.Camera.Core 6784 6785**Parameters** 6786 6787| Name | Type | Mandatory| Description | 6788| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6789| type | string | Yes | Event type. The value is fixed at **'apertureInfoChange'**. | 6790| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| Yes | Callback used to return the aperture information. | 6791 6792**Error codes** 6793 6794| ID| Error Message | 6795| ------- | ---------------------- | 6796| 202 | Not System Application. | 6797 6798**Example** 6799 6800```ts 6801import { BusinessError } from '@kit.BasicServicesKit'; 6802 6803function apertureInfoCallback(err: BusinessError, info: camera.ApertureInfo): void { 6804 if (err !== undefined && err.code !== 0) { 6805 console.error(`Callback Error, errorCode: ${err.code}`); 6806 return; 6807 } 6808 console.log(`Aperture value: ${info.aperture}`); 6809} 6810 6811function registerApertureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6812 professionalVideoSession.on('apertureInfoChange', apertureInfoCallback); 6813} 6814``` 6815 6816### off('apertureInfoChange')<sup>12+</sup> 6817 6818off(type: 'apertureInfoChange', callback?: AsyncCallback\<ApertureInfo\>): void 6819 6820Unsubscribes from aperture change events. 6821 6822**System API**: This is a system API. 6823 6824**System capability**: SystemCapability.Multimedia.Camera.Core 6825 6826**Parameters** 6827 6828| Name | Type | Mandatory| Description | 6829| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6830| type | string | Yes | Event type. The value is fixed at **'apertureInfoChange'**. | 6831| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('apertureInfoChange')**.| 6832 6833**Error codes** 6834 6835| ID| Error Message | 6836| ------- | ---------------------- | 6837| 202 | Not System Application. | 6838 6839**Example** 6840 6841```ts 6842function unregisterApertureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6843 professionalVideoSession.off('apertureInfoChange'); 6844} 6845``` 6846 6847### on('luminationInfoChange')<sup>12+</sup> 6848 6849on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 6850 6851Subscribes to illumination change events to obtain illumination information. This API uses an asynchronous callback to return the result. 6852 6853**System API**: This is a system API. 6854 6855**System capability**: SystemCapability.Multimedia.Camera.Core 6856 6857**Parameters** 6858 6859| Name | Type | Mandatory| Description | 6860| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6861| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 6862| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| Yes | Callback used to return the illumination information. | 6863 6864**Error codes** 6865 6866| ID| Error Message | 6867| ------- | ---------------------- | 6868| 202 | Not System Application. | 6869 6870**Example** 6871 6872```ts 6873import { BusinessError } from '@kit.BasicServicesKit'; 6874 6875function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 6876 if (err !== undefined && err.code !== 0) { 6877 console.error(`Callback Error, errorCode: ${err.code}`); 6878 return; 6879 } 6880 console.log(`Lumination: ${info.lumination}`); 6881} 6882 6883function registerLuminationInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6884 professionalVideoSession.on('luminationInfoChange', luminationInfoCallback); 6885} 6886``` 6887 6888### off('luminationInfoChange')<sup>12+</sup> 6889 6890off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 6891 6892Unsubscribes from illumination change events. 6893 6894**System API**: This is a system API. 6895 6896**System capability**: SystemCapability.Multimedia.Camera.Core 6897 6898**Parameters** 6899 6900| Name | Type | Mandatory| Description | 6901| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6902| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 6903| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('luminationInfoChange')**.| 6904 6905**Error codes** 6906 6907| ID| Error Message | 6908| ------- | ---------------------- | 6909| 202 | Not System Application. | 6910 6911**Example** 6912 6913```ts 6914function unregisterLuminationInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6915 professionalVideoSession.off('luminationInfoChange'); 6916} 6917``` 6918 6919## MacroPhotoSession<sup>12+</sup> 6920 6921MacroPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ManualFocus 6922 6923Implements a macro photo session, which sets the parameters of the macro photo mode and saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera. It inherits from [Session](js-apis-camera.md#session11). 6924 6925### on('error')<sup>12+</sup> 6926 6927on(type: 'error', callback: ErrorCallback): void 6928 6929Subscribes to **MacroPhotoSession** error events. This API uses an asynchronous callback to return the result. 6930 6931**System API**: This is a system API. 6932 6933**System capability**: SystemCapability.Multimedia.Camera.Core 6934 6935**Parameters** 6936 6937| Name | Type | Mandatory | Description | 6938|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 6939| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as [beginConfig](js-apis-camera.md#beginconfig11), [commitConfig](js-apis-camera.md#commitconfig11-1), and [addInput](js-apis-camera.md#addinput11).| 6940| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes | Callback used to return an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode). | 6941 6942**Error codes** 6943 6944For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6945 6946| ID| Error Message | 6947|-------|----------------------------| 6948| 202 | Not System Application. | 6949 6950**Example** 6951 6952```ts 6953import { BusinessError } from '@kit.BasicServicesKit'; 6954 6955function callback(err: BusinessError): void { 6956 console.error(`MacroPhotoSession error code: ${err.code}`); 6957} 6958 6959function registerSessionError(macroPhotoSession: camera.MacroPhotoSession): void { 6960 macroPhotoSession.on('error', callback); 6961} 6962``` 6963 6964### off('error')<sup>12+</sup> 6965 6966off(type: 'error', callback?: ErrorCallback): void 6967 6968Unsubscribes from **MacroPhotoSession** error events. 6969 6970**System API**: This is a system API. 6971 6972**System capability**: SystemCapability.Multimedia.Camera.Core 6973 6974**Parameters** 6975 6976| Name | Type | Mandatory| Description | 6977|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 6978| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. | 6979| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | No | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.| 6980 6981**Error codes** 6982 6983For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6984 6985| ID| Error Message | 6986|-------|----------------------------| 6987| 202 | Not System Application. | 6988 6989**Example** 6990 6991```ts 6992function unregisterSessionError(macroPhotoSession: camera.MacroPhotoSession): void { 6993 macroPhotoSession.off('error'); 6994} 6995``` 6996 6997### on('focusStateChange')<sup>12+</sup> 6998 6999on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7000 7001Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 7002 7003**System API**: This is a system API. 7004 7005**System capability**: SystemCapability.Multimedia.Camera.Core 7006 7007**Parameters** 7008 7009| Name | Type | Mandatory| Description | 7010|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 7011| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.| 7012| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 7013 7014**Error codes** 7015 7016For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7017 7018| ID| Error Message | 7019|-------|----------------------------| 7020| 202 | Not System Application. | 7021 7022**Example** 7023 7024```ts 7025import { BusinessError } from '@kit.BasicServicesKit'; 7026 7027function callback(err: BusinessError, focusState: camera.FocusState): void { 7028 if (err !== undefined && err.code !== 0) { 7029 console.error(`Callback Error, errorCode: ${err.code}`); 7030 return; 7031 } 7032 console.info(`Focus state: ${focusState}`); 7033} 7034 7035function registerFocusStateChange(macroPhotoSession: camera.MacroPhotoSession): void { 7036 macroPhotoSession.on('focusStateChange', callback); 7037} 7038``` 7039 7040### off('focusStateChange')<sup>12+</sup> 7041 7042off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7043 7044Unsubscribes from focus state change events. 7045 7046**System API**: This is a system API. 7047 7048**System capability**: SystemCapability.Multimedia.Camera.Core 7049 7050**Parameters** 7051 7052| Name | Type | Mandatory| Description | 7053|-----------|---------------------------------------------|----|--------------------------------------------------------------| 7054| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. | 7055| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | No | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled. | 7056 7057**Error codes** 7058 7059For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7060 7061| ID| Error Message | 7062|-------|----------------------------| 7063| 202 | Not System Application. | 7064 7065**Example** 7066 7067```ts 7068function unregisterFocusStateChange(macroPhotoSession: camera.MacroPhotoSession): void { 7069 macroPhotoSession.off('focusStateChange'); 7070} 7071``` 7072 7073### on('smoothZoomInfoAvailable')<sup>12+</sup> 7074 7075on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 7076 7077Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 7078 7079**System API**: This is a system API. 7080 7081**System capability**: SystemCapability.Multimedia.Camera.Core 7082 7083**Parameters** 7084 7085| Name | Type | Mandatory| Description | 7086| -------- | ----------------------- | ---- | ------------------------ | 7087| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 7088| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 7089 7090**Error codes** 7091 7092For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7093 7094| ID| Error Message | 7095|-------|----------------------------| 7096| 202 | Not System Application. | 7097 7098**Example** 7099 7100```ts 7101import { BusinessError } from '@kit.BasicServicesKit'; 7102 7103function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 7104 if (err !== undefined && err.code !== 0) { 7105 console.error(`Callback Error, errorCode: ${err.code}`); 7106 return; 7107 } 7108 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 7109} 7110 7111function registerSmoothZoomInfo(macroPhotoSession: camera.MacroPhotoSession): void { 7112 macroPhotoSession.on('smoothZoomInfoAvailable', callback); 7113} 7114``` 7115 7116### off('smoothZoomInfoAvailable')<sup>12+</sup> 7117 7118off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 7119 7120Unsubscribes from smooth zoom state change events. 7121 7122**System API**: This is a system API. 7123 7124**System capability**: SystemCapability.Multimedia.Camera.Core 7125 7126**Parameters** 7127 7128| Name | Type | Mandatory| Description | 7129| -------- | ----------------------------------------- | ---- | ------------------------ | 7130| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 7131| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | No | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.| 7132 7133**Error codes** 7134 7135For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7136 7137| ID| Error Message | 7138|-------|----------------------------| 7139| 202 | Not System Application. | 7140 7141**Example** 7142 7143```ts 7144function unregisterSmoothZoomInfo(macroPhotoSession: camera.MacroPhotoSession): void { 7145 macroPhotoSession.off('smoothZoomInfoAvailable'); 7146} 7147``` 7148 7149## MacroVideoSession<sup>12+</sup> 7150 7151MacroVideoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ManualFocus 7152 7153Implements a macro video session, which sets the parameters of the macro video mode and saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera. It inherits from [Session](js-apis-camera.md#session11). 7154 7155### on('error')<sup>12+</sup> 7156 7157on(type: 'error', callback: ErrorCallback): void 7158 7159Subscribes to **MacroVideoSession** error events. This API uses an asynchronous callback to return the result. 7160 7161**System API**: This is a system API. 7162 7163**System capability**: SystemCapability.Multimedia.Camera.Core 7164 7165**Parameters** 7166 7167| Name | Type | Mandatory | Description | 7168|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 7169| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as [beginConfig](js-apis-camera.md#beginconfig11), [commitConfig](js-apis-camera.md#commitconfig11-1), and [addInput](js-apis-camera.md#addinput11).| 7170| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes | Callback used to return an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode). | 7171 7172**Error codes** 7173 7174For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7175 7176| ID| Error Message | 7177|-------|----------------------------| 7178| 202 | Not System Application. | 7179 7180**Example** 7181 7182```ts 7183import { BusinessError } from '@kit.BasicServicesKit'; 7184 7185function callback(err: BusinessError): void { 7186 console.error(`MacroPhotoSession error code: ${err.code}`); 7187} 7188 7189function registerSessionError(macroVideoSession: camera.MacroVideoSession): void { 7190 macroVideoSession.on('error', callback); 7191} 7192``` 7193 7194### off('error')<sup>12+</sup> 7195 7196off(type: 'error', callback?: ErrorCallback): void 7197 7198Unsubscribes from **MacroVideoSession** error events. 7199 7200**System API**: This is a system API. 7201 7202**System capability**: SystemCapability.Multimedia.Camera.Core 7203 7204**Parameters** 7205 7206| Name | Type | Mandatory| Description | 7207|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 7208| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. | 7209| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | No | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.| 7210 7211**Error codes** 7212 7213For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7214 7215| ID| Error Message | 7216|-------|----------------------------| 7217| 202 | Not System Application. | 7218 7219**Example** 7220 7221```ts 7222function unregisterSessionError(macroVideoSession: camera.MacroVideoSession): void { 7223 macroVideoSession.off('error'); 7224} 7225``` 7226 7227### on('focusStateChange')<sup>12+</sup> 7228 7229on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7230 7231Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 7232 7233**System API**: This is a system API. 7234 7235**System capability**: SystemCapability.Multimedia.Camera.Core 7236 7237**Parameters** 7238 7239| Name | Type | Mandatory| Description | 7240|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 7241| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.| 7242| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 7243 7244**Error codes** 7245 7246For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7247 7248| ID| Error Message | 7249|-------|----------------------------| 7250| 202 | Not System Application. | 7251 7252**Example** 7253 7254```ts 7255import { BusinessError } from '@kit.BasicServicesKit'; 7256 7257function callback(err: BusinessError, focusState: camera.FocusState): void { 7258 if (err !== undefined && err.code !== 0) { 7259 console.error(`Callback Error, errorCode: ${err.code}`); 7260 return; 7261 } 7262 console.info(`Focus state: ${focusState}`); 7263} 7264 7265function registerFocusStateChange(macroVideoSession: camera.MacroVideoSession): void { 7266 macroVideoSession.on('focusStateChange', callback); 7267} 7268``` 7269 7270### off('focusStateChange')<sup>12+</sup> 7271 7272off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7273 7274Unsubscribes from focus state change events. 7275 7276**System API**: This is a system API. 7277 7278**System capability**: SystemCapability.Multimedia.Camera.Core 7279 7280**Parameters** 7281 7282| Name | Type | Mandatory| Description | 7283|-----------|---------------------------------------------|----|--------------------------------------------------------------| 7284| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. | 7285| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | No | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled. | 7286 7287**Error codes** 7288 7289For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7290 7291| ID| Error Message | 7292|-------|----------------------------| 7293| 202 | Not System Application. | 7294 7295**Example** 7296 7297```ts 7298function unregisterFocusStateChange(macroVideoSession: camera.MacroVideoSession): void { 7299 macroVideoSession.off('focusStateChange'); 7300} 7301``` 7302 7303### on('smoothZoomInfoAvailable')<sup>12+</sup> 7304 7305on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 7306 7307Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 7308 7309**System API**: This is a system API. 7310 7311**System capability**: SystemCapability.Multimedia.Camera.Core 7312 7313**Parameters** 7314 7315| Name | Type | Mandatory| Description | 7316| -------- | ----------------------- | ---- | ------------------------ | 7317| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 7318| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 7319 7320**Error codes** 7321 7322For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7323 7324| ID| Error Message | 7325|-------|----------------------------| 7326| 202 | Not System Application. | 7327 7328**Example** 7329 7330```ts 7331import { BusinessError } from '@kit.BasicServicesKit'; 7332 7333function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 7334 if (err !== undefined && err.code !== 0) { 7335 console.error(`Callback Error, errorCode: ${err.code}`); 7336 return; 7337 } 7338 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 7339} 7340 7341function registerSmoothZoomInfo(macroVideoSession: camera.MacroVideoSession): void { 7342 macroVideoSession.on('smoothZoomInfoAvailable', callback); 7343} 7344``` 7345 7346### off('smoothZoomInfoAvailable')<sup>12+</sup> 7347 7348off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 7349 7350Unsubscribes from smooth zoom state change events. 7351 7352**System API**: This is a system API. 7353 7354**System capability**: SystemCapability.Multimedia.Camera.Core 7355 7356**Parameters** 7357 7358| Name | Type | Mandatory| Description | 7359| -------- | ----------------------------------------- | ---- | ------------------------ | 7360| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 7361| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | No | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.| 7362 7363**Error codes** 7364 7365For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7366 7367| ID| Error Message | 7368|-------|----------------------------| 7369| 202 | Not System Application. | 7370 7371**Example** 7372 7373```ts 7374function unregisterSmoothZoomInfo(macroVideoSession: camera.MacroVideoSession): void { 7375 macroVideoSession.off('smoothZoomInfoAvailable'); 7376} 7377``` 7378 7379## FlashQuery<sup>12+</sup> 7380 7381Provides APIs to obtain the flash information of a camera device, including whether the LCD flash is supported. 7382 7383### isLcdFlashSupported<sup>12+</sup> 7384 7385isLcdFlashSupported(): boolean 7386 7387Checks whether the LCD flash is supported. 7388 7389**System API**: This is a system API. 7390 7391**System capability**: SystemCapability.Multimedia.Camera.Core 7392 7393**Return value** 7394 7395| Type | Description | 7396| -------------- | ----------------------- | 7397| boolean | **true**: The LCD flash is supported.<br>**false**: The LCD flash is not supported.| 7398 7399**Error codes** 7400 7401For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7402 7403| ID | Error Message | 7404| --------------- | --------------- | 7405| 202 | Not System Application. | 7406| 7400103 | Session not config, only throw in session usage. | 7407 7408**Example** 7409 7410```ts 7411function isLcdFlashSupported(nightPhotoSession: camera.NightPhotoSession): boolean { 7412 return nightPhotoSession.isLcdFlashSupported(); 7413} 7414``` 7415 7416## TimeLapseRecordState<sup>12+</sup> 7417 7418Enumerates the time-lapse recording states. 7419 7420**System API**: This is a system API. 7421 7422**System capability**: SystemCapability.Multimedia.Camera.Core 7423 7424| Name | Value | Description | 7425| ----------------------------- | ---- | ----------- | 7426| IDLE | 0 | Recording not started.| 7427| RECORDING | 1 | Recording.| 7428 7429## TimeLapsePreviewType<sup>12+</sup> 7430 7431Enumerates the time-lapse preview types, which affect the shooting algorithm. 7432 7433**System API**: This is a system API. 7434 7435**System capability**: SystemCapability.Multimedia.Camera.Core 7436 7437| Name | Value | Description | 7438| ----------------------------- | ---- | ----------- | 7439| DARK | 1 | Dark environment, a scenario with poor illumination, for example, at night or in a dark area.| 7440| LIGHT | 2 | Bright environment, a scenario with good illumination, for example, in the daytime or under light.| 7441 7442## TryAEInfo<sup>12+</sup> 7443 7444Describes the Try AE parameters. Try AE indicates that the hardware reports the status based on the ambient illumination change during time-lapse photographing. 7445 7446**System API**: This is a system API. 7447 7448**System capability**: SystemCapability.Multimedia.Camera.Core 7449 7450| Name| Type | Read-only| Optional| Description | 7451| ---- | ------- | ---- |--| -------------- | 7452| isTryAEDone | boolean | Yes | No| Whether Try AE is complete. | 7453| isTryAEHintNeeded | boolean | Yes | Yes| Whether Try AE is required. | 7454| previewType | [TimeLapsePreviewType](#timelapsepreviewtype12) | Yes | Yes| Preview type. | 7455| captureInterval | number | Yes | Yes| Shooting interval, in ms. | 7456 7457## TimeLapsePhotoSession<sup>12+</sup> 7458 7459TimeLapsePhotoSession extends Session, Focus, ManualFocus, AutoExposure, ManualExposure, ManualIso, WhiteBalance, Zoom, ColorEffect 7460 7461Implements a time-lapse photo session, which sets the parameters of the time-lapse photo mode and saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera. It inherits from [Session](js-apis-camera.md#session12). 7462 7463### on('error')<sup>12+</sup> 7464 7465on(type: 'error', callback: ErrorCallback): void 7466 7467Subscribes to **TimeLapsePhotoSession** error events. This API uses an asynchronous callback to return the result. 7468 7469**System API**: This is a system API. 7470 7471**System capability**: SystemCapability.Multimedia.Camera.Core 7472 7473**Parameters** 7474 7475| Name | Type | Mandatory| Description | 7476| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 7477| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as [beginConfig](js-apis-camera.md#beginconfig11), [commitConfig](js-apis-camera.md#commitconfig11-1), and [addInput](js-apis-camera.md#addinput11).| 7478| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode).| 7479 7480**Error codes** 7481 7482For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7483 7484| ID | Error Message | 7485|---------| --------------- | 7486| 202 | Not System Application. | 7487 7488**Example** 7489 7490```ts 7491import { BusinessError } from '@kit.BasicServicesKit'; 7492 7493function callback(err: BusinessError): void { 7494 console.error(`Time lapse photo session error code: ${err.code}`); 7495} 7496 7497function registerSessionError(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7498 timeLapsePhotoSession.on('error', callback); 7499} 7500``` 7501 7502### off('error')<sup>12+</sup> 7503 7504off(type: 'error', callback?: ErrorCallback): void 7505 7506Unsubscribes from **TimeLapsePhotoSession** error events. 7507 7508**System API**: This is a system API. 7509 7510**System capability**: SystemCapability.Multimedia.Camera.Core 7511 7512**Parameters** 7513 7514| Name | Type | Mandatory| Description | 7515| -------- | ------------------------ | ---- | ------------------------------ | 7516| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 7517| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| No | Callback, which is optional. If a callback function is passed in, it is an anonymous function. | 7518 7519**Error codes** 7520 7521For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7522 7523| ID | Error Message | 7524|---------| --------------- | 7525| 202 | Not System Application. | 7526 7527**Example** 7528 7529```ts 7530function unregisterSessionError(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7531 timeLapsePhotoSession.off('error'); 7532} 7533``` 7534 7535### on('focusStateChange')<sup>12+</sup> 7536 7537on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7538 7539Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 7540 7541**System API**: This is a system API. 7542 7543**System capability**: SystemCapability.Multimedia.Camera.Core 7544 7545**Parameters** 7546 7547| Name | Type | Mandatory| Description | 7548| -------- | ---------------- | ---- | ------------------------ | 7549| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.| 7550| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 7551 7552**Error codes** 7553 7554For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7555 7556| ID | Error Message | 7557|---------| --------------- | 7558| 202 | Not System Application. | 7559 7560**Example** 7561 7562```ts 7563import { BusinessError } from '@kit.BasicServicesKit'; 7564 7565function callback(err: BusinessError, focusState: camera.FocusState): void { 7566 if (err !== undefined && err.code !== 0) { 7567 console.error(`Callback Error, errorCode: ${err.code}`); 7568 return; 7569 } 7570 console.info(`Focus state: ${focusState}`); 7571} 7572 7573function registerFocusStateChange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7574 timeLapsePhotoSession.on('focusStateChange', callback); 7575} 7576``` 7577 7578### off('focusStateChange')<sup>12+</sup> 7579 7580off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7581 7582Unsubscribes from focus state change events. 7583 7584**System API**: This is a system API. 7585 7586**System capability**: SystemCapability.Multimedia.Camera.Core 7587 7588**Parameters** 7589 7590| Name | Type | Mandatory| Description | 7591| -------- | ----------------------------------------- | ---- | ------------------------ | 7592| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 7593| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('focusStateChange')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 7594 7595**Error codes** 7596 7597For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7598 7599| ID | Error Message | 7600|---------| --------------- | 7601| 202 | Not System Application. | 7602 7603**Example** 7604 7605```ts 7606function unregisterFocusStateChange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7607 timeLapsePhotoSession.off('focusStateChange'); 7608} 7609``` 7610 7611### on('isoInfoChange')<sup>12+</sup> 7612 7613on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 7614 7615Subscribes to automatic ISO change events to obtain real-time ISO information. This API uses an asynchronous callback to return the result. 7616 7617**System API**: This is a system API. 7618 7619**System capability**: SystemCapability.Multimedia.Camera.Core 7620 7621**Parameters** 7622 7623| Name | Type | Mandatory| Description | 7624| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7625| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 7626| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| Yes | Callback used to return the ISO information. | 7627 7628**Error codes** 7629 7630| ID| Error Message | 7631| ------- | ---------------------- | 7632| 202 | Not System Application. | 7633 7634**Example** 7635 7636```ts 7637import { BusinessError } from '@kit.BasicServicesKit'; 7638 7639function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 7640 if (err !== undefined && err.code !== 0) { 7641 console.error(`Callback Error, errorCode: ${err.code}`); 7642 return; 7643 } 7644 console.log(`ISO value: ${info.iso}`); 7645} 7646 7647function registerIsoInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7648 timeLapsePhotoSession.on('isoInfoChange', isoInfoCallback); 7649} 7650``` 7651 7652### off('isoInfoChange')<sup>12+</sup> 7653 7654off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 7655 7656Unsubscribes from automatic ISO change events. 7657 7658**System API**: This is a system API. 7659 7660**System capability**: SystemCapability.Multimedia.Camera.Core 7661 7662**Parameters** 7663 7664| Name | Type | Mandatory| Description | 7665| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7666| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 7667| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('isoInfoChange')**.| 7668 7669**Error codes** 7670 7671| ID| Error Message | 7672| ------- | ---------------------- | 7673| 202 | Not System Application. | 7674 7675**Example** 7676 7677```ts 7678function unregisterIsoInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7679 timeLapsePhotoSession.off('isoInfoChange'); 7680} 7681``` 7682 7683### on('exposureInfoChange')<sup>12+</sup> 7684 7685on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 7686 7687Subscribes to exposure information change events to obtain the exposure information. This API uses an asynchronous callback to return the result. 7688 7689**System API**: This is a system API. 7690 7691**System capability**: SystemCapability.Multimedia.Camera.Core 7692 7693**Parameters** 7694 7695| Name | Type | Mandatory| Description | 7696| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7697| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 7698| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| Yes | Callback used to return the exposure information. | 7699 7700**Error codes** 7701 7702| ID| Error Message | 7703| ------- | ---------------------- | 7704| 202 | Not System Application. | 7705 7706**Example** 7707 7708```ts 7709import { BusinessError } from '@kit.BasicServicesKit'; 7710 7711function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 7712 if (err !== undefined && err.code !== 0) { 7713 console.error(`Callback Error, errorCode: ${err.code}`); 7714 return; 7715 } 7716 console.log(`exposureTimeValue: ${info.exposureTime}`); 7717} 7718 7719function registerExposureInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7720 timeLapsePhotoSession.on('exposureInfoChange', exposureInfoCallback); 7721} 7722``` 7723 7724### off('exposureInfoChange')<sup>12+</sup> 7725 7726off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 7727 7728Unsubscribes from exposure information change events. 7729 7730**System API**: This is a system API. 7731 7732**System capability**: SystemCapability.Multimedia.Camera.Core 7733 7734**Parameters** 7735 7736| Name | Type | Mandatory| Description | 7737| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7738| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 7739| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('exposureInfoChange')**.| 7740 7741**Error codes** 7742 7743| ID| Error Message | 7744| ------- | ---------------------- | 7745| 202 | Not System Application. | 7746 7747**Example** 7748 7749```ts 7750function unregisterExposureInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7751 timeLapsePhotoSession.off('exposureInfoChange'); 7752} 7753``` 7754 7755### on('luminationInfoChange')<sup>12+</sup> 7756 7757on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 7758 7759Subscribes to illumination change events to obtain real-time illumination information. This API uses an asynchronous callback to return the result. 7760 7761**System API**: This is a system API. 7762 7763**System capability**: SystemCapability.Multimedia.Camera.Core 7764 7765**Parameters** 7766 7767| Name | Type | Mandatory| Description | 7768| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7769| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 7770| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| Yes | Callback used to return the illumination information. | 7771 7772**Error codes** 7773 7774| ID| Error Message | 7775| ------- | ---------------------- | 7776| 202 | Not System Application. | 7777 7778**Example** 7779 7780```ts 7781import { BusinessError } from '@kit.BasicServicesKit'; 7782 7783function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 7784 if (err !== undefined && err.code !== 0) { 7785 console.error(`Callback Error, errorCode: ${err.code}`); 7786 return; 7787 } 7788 console.log(`Lumination: ${info.lumination}`); 7789} 7790 7791function registerLuminationInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7792 timeLapsePhotoSession.on('luminationInfoChange', luminationInfoCallback); 7793} 7794``` 7795 7796### off('luminationInfoChange')<sup>12+</sup> 7797 7798off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 7799 7800Unsubscribes from illumination change events. 7801 7802**System API**: This is a system API. 7803 7804**System capability**: SystemCapability.Multimedia.Camera.Core 7805 7806**Parameters** 7807 7808| Name | Type | Mandatory| Description | 7809| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7810| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 7811| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('luminationInfoChange')**.| 7812 7813**Error codes** 7814 7815| ID| Error Message | 7816| ------- | ---------------------- | 7817| 202 | Not System Application. | 7818 7819**Example** 7820 7821```ts 7822function unregisterLuminationInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7823 timeLapsePhotoSession.off('luminationInfoChange'); 7824} 7825``` 7826 7827### on('tryAEInfoChange')<sup>12+</sup> 7828 7829on(type: 'tryAEInfoChange', callback: AsyncCallback\<TryAEInfo\>): void 7830 7831Subscribes to Try AE change events to obtain real-time Try AE parameters. This API uses an asynchronous callback to return the result. 7832 7833**System API**: This is a system API. 7834 7835**System capability**: SystemCapability.Multimedia.Camera.Core 7836 7837**Parameters** 7838 7839| Name | Type | Mandatory| Description | 7840| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7841| type | string | Yes | Event type. The value is fixed at **'tryAEInfoChange'**. | 7842| callback | AsyncCallback\<[TryAEInfo](#tryaeinfo12)\>| Yes | Callback used to return the Try AE parameters. | 7843 7844**Error codes** 7845 7846| ID| Error Message | 7847| ------- | ---------------------- | 7848| 202 | Not System Application. | 7849 7850**Example** 7851 7852```ts 7853import { BusinessError } from '@kit.BasicServicesKit'; 7854 7855function tryAEInfoCallback(err: BusinessError, info: camera.TryAEInfo): void { 7856 if (err !== undefined && err.code !== 0) { 7857 console.error(`Callback Error, errorCode: ${err.code}`); 7858 return; 7859 } 7860 console.log(`TryAEInfo: ${info.isTryAEDone}, ${info.isTryAEHintNeeded}, ${info.previewType}, ${info.captureInterval}`); 7861} 7862 7863function registerTryAEInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7864 timeLapsePhotoSession.on('tryAEInfoChange', tryAEInfoCallback); 7865} 7866``` 7867 7868### off('tryAEInfoChange')<sup>12+</sup> 7869 7870off(type: 'tryAEInfoChange', callback?: AsyncCallback\<TryAEInfo\>): void 7871 7872Unsubscribes from Try AE change events. 7873 7874**System API**: This is a system API. 7875 7876**System capability**: SystemCapability.Multimedia.Camera.Core 7877 7878**Parameters** 7879 7880| Name | Type | Mandatory| Description | 7881| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7882| type | string | Yes | Event type. The value is fixed at **'tryAEInfoChange'**. | 7883| callback | AsyncCallback\<[TryAEInfo](#tryaeinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('tryAEInfoChange')**.| 7884 7885**Error codes** 7886 7887| ID| Error Message | 7888| ------- | ---------------------- | 7889| 202 | Not System Application. | 7890 7891**Example** 7892 7893```ts 7894function unregisterTryAEInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7895 timeLapsePhotoSession.off('tryAEInfoChange'); 7896} 7897``` 7898 7899### isTryAENeeded<sup>12+</sup> 7900 7901isTryAENeeded(): boolean 7902 7903Checks whether Try AE is required. 7904 7905**System API**: This is a system API. 7906 7907**System capability**: SystemCapability.Multimedia.Camera.Core 7908 7909**Return value** 7910 7911| Type | Description | 7912| ---------- | ----------------------------- | 7913| boolean | Result indicating whether Try AE is required. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 7914 7915**Error codes** 7916 7917For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7918 7919| ID | Error Message | 7920| --------------- | --------------- | 7921| 202 | Not System Application. | 7922| 7400103 | Session not config. | 7923 7924**Example** 7925 7926```ts 7927import { BusinessError } from '@kit.BasicServicesKit'; 7928 7929function isTryAENeeded(timeLapsePhotoSession: camera.TimeLapsePhotoSession): boolean { 7930 let needed = false; 7931 try { 7932 needed = timeLapsePhotoSession.isTryAENeeded(); 7933 } catch (error) { 7934 // If the operation fails, error.code is returned and processed. 7935 let err = error as BusinessError; 7936 console.error(`The isTryAENeeded call failed. error code: ${err.code}`); 7937 } 7938 return needed; 7939} 7940``` 7941 7942### startTryAE<sup>12+</sup> 7943 7944startTryAE(): void 7945 7946Starts to execute Try AE. 7947 7948**System API**: This is a system API. 7949 7950**System capability**: SystemCapability.Multimedia.Camera.Core 7951 7952**Error codes** 7953 7954For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7955 7956| ID | Error Message | 7957| --------------- | --------------- | 7958| 202 | Not System Application. | 7959| 7400103 | Session not config. | 7960 7961**Example** 7962 7963```ts 7964import { BusinessError } from '@kit.BasicServicesKit'; 7965 7966function startTryAE(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7967 try { 7968 timeLapsePhotoSession.startTryAE(); 7969 } catch (error) { 7970 // If the operation fails, error.code is returned and processed. 7971 let err = error as BusinessError; 7972 console.error(`The startTryAE call failed. error code: ${err.code}`); 7973 } 7974} 7975``` 7976 7977### stopTryAE<sup>12+</sup> 7978 7979stopTryAE(): void 7980 7981Stops the execution of Try AE. 7982 7983**System API**: This is a system API. 7984 7985**System capability**: SystemCapability.Multimedia.Camera.Core 7986 7987**Error codes** 7988 7989For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7990 7991| ID | Error Message | 7992| --------------- | --------------- | 7993| 202 | Not System Application. | 7994| 7400103 | Session not config. | 7995 7996**Example** 7997 7998```ts 7999import { BusinessError } from '@kit.BasicServicesKit'; 8000 8001function stopTryAE(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8002 try { 8003 timeLapsePhotoSession.stopTryAE(); 8004 } catch (error) { 8005 // If the operation fails, error.code is returned and processed. 8006 let err = error as BusinessError; 8007 console.error(`The stopTryAE call failed. error code: ${err.code}`); 8008 } 8009} 8010``` 8011 8012### getSupportedTimeLapseIntervalRange<sup>12+</sup> 8013 8014getSupportedTimeLapseIntervalRange(): Array\<number\> 8015 8016Obtains the supported time-lapse shooting interval range. 8017 8018**System API**: This is a system API. 8019 8020**System capability**: SystemCapability.Multimedia.Camera.Core 8021 8022**Return value** 8023 8024| Type | Description | 8025| ---------- | ----------------------------- | 8026| Array\<number\> | Interval range, in ms. The value depends on the underlying capability. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 8027 8028**Error codes** 8029 8030For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8031 8032| ID | Error Message | 8033| --------------- | --------------- | 8034| 202 | Not System Application. | 8035| 7400103 | Session not config. | 8036 8037**Example** 8038 8039```ts 8040import { BusinessError } from '@kit.BasicServicesKit'; 8041 8042function getSupportedTimeLapseIntervalRange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): Array<number> { 8043 let intervalRange: Array<number> = []; 8044 try { 8045 intervalRange = timeLapsePhotoSession.getSupportedTimeLapseIntervalRange(); 8046 } catch (error) { 8047 // If the operation fails, error.code is returned and processed. 8048 let err = error as BusinessError; 8049 console.error(`The getSupportedTimeLapseIntervalRange call failed. error code: ${err.code}`); 8050 } 8051 return intervalRange; 8052} 8053``` 8054 8055### getTimeLapseInterval<sup>12+</sup> 8056 8057getTimeLapseInterval(): number 8058 8059Obtains the current time-lapse shooting interval. 8060 8061**System API**: This is a system API. 8062 8063**System capability**: SystemCapability.Multimedia.Camera.Core 8064 8065**Return value** 8066 8067| Type | Description | 8068| ---------- | ----------------------------- | 8069| number | Shooting interval, in ms.| 8070 8071**Error codes** 8072 8073For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8074 8075| ID | Error Message | 8076| --------------- | --------------- | 8077| 202 | Not System Application. | 8078| 7400103 | Session not config. | 8079 8080**Example** 8081 8082```ts 8083import { BusinessError } from '@kit.BasicServicesKit'; 8084 8085function getTimeLapseInterval(timeLapsePhotoSession: camera.TimeLapsePhotoSession): number { 8086 let interval: number = 0; 8087 try { 8088 interval = timeLapsePhotoSession.getTimeLapseInterval(); 8089 } catch (error) { 8090 // If the operation fails, error.code is returned and processed. 8091 let err = error as BusinessError; 8092 console.error(`The getTimeLapseInterval call failed. error code: ${err.code}`); 8093 } 8094 return interval; 8095} 8096``` 8097 8098### setTimeLapseInterval<sup>12+</sup> 8099setTimeLapseInterval(interval: number): void 8100 8101Sets a time-lapse shooting interval. 8102 8103**System API**: This is a system API. 8104 8105**System capability**: SystemCapability.Multimedia.Camera.Core 8106 8107**Parameters** 8108 8109| Name | Type | Mandatory| Description | 8110| -------- | ----------------------- | ---- | ------------------- | 8111| interval | number | Yes | Shooting interval, in ms.| 8112 8113**Error codes** 8114 8115For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8116 8117| ID | Error Message | 8118| --------------- | --------------- | 8119| 202 | Not System Application. | 8120| 7400101 | Parameter missing or parameter type incorrect. | 8121| 7400103 | Session not config. | 8122 8123**Example** 8124 8125```ts 8126import { BusinessError } from '@kit.BasicServicesKit'; 8127 8128function setTimeLapseInterval(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8129 try { 8130 let interval: number = 10000; 8131 timeLapsePhotoSession.setTimeLapseInterval(interval); 8132 } catch (error) { 8133 // If the operation fails, error.code is returned and processed. 8134 let err = error as BusinessError; 8135 console.error(`The setTimeLapseInterval call failed. error code: ${err.code}`); 8136 } 8137} 8138``` 8139 8140### getTimeLapseRecordState<sup>12+</sup> 8141 8142getTimeLapseRecordState(): TimeLapseRecordState 8143 8144Obtains the time-lapse shooting state. 8145 8146**System API**: This is a system API. 8147 8148**System capability**: SystemCapability.Multimedia.Camera.Core 8149 8150**Return value** 8151 8152| Type | Description | 8153| ---------- | ----------------------------- | 8154| [TimeLapseRecordState](#timelapserecordstate12) | Shooting state. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 8155 8156**Error codes** 8157 8158For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8159 8160| ID | Error Message | 8161| --------------- | --------------- | 8162| 202 | Not System Application. | 8163| 7400103 | Session not config. | 8164 8165**Example** 8166 8167```ts 8168import { BusinessError } from '@kit.BasicServicesKit'; 8169 8170function getTimeLapseRecordState(timeLapsePhotoSession: camera.TimeLapsePhotoSession): camera.TimeLapseRecordState { 8171 let state = camera.TimeLapseRecordState.IDLE; 8172 try { 8173 state = timeLapsePhotoSession.getTimeLapseRecordState(); 8174 } catch (error) { 8175 // If the operation fails, error.code is returned and processed. 8176 let err = error as BusinessError; 8177 console.error(`The getTimeLapseRecordState call failed. error code: ${err.code}`); 8178 } 8179 return state; 8180} 8181``` 8182 8183### setTimeLapseRecordState<sup>12+</sup> 8184 8185setTimeLapseRecordState(state: TimeLapseRecordState): void 8186 8187Sets the time-lapse shooting state. 8188 8189**System API**: This is a system API. 8190 8191**System capability**: SystemCapability.Multimedia.Camera.Core 8192 8193**Parameters** 8194 8195| Name | Type | Mandatory| Description | 8196| -------- | -------------------------------| ---- | ----------------------- | 8197| state | [TimeLapseRecordState](#timelapserecordstate12) | Yes | Shooting state. | 8198 8199**Error codes** 8200 8201For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8202 8203| ID | Error Message | 8204| --------------- | --------------- | 8205| 202 | Not System Application. | 8206| 7400101 | Parameter missing or parameter type incorrect. | 8207| 7400103 | Session not config. | 8208 8209**Example** 8210 8211```ts 8212import { BusinessError } from '@kit.BasicServicesKit'; 8213 8214function setTimeLapseRecordState(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8215 try { 8216 timeLapsePhotoSession.setTimeLapseRecordState(camera.TimeLapseRecordState.RECORDING); 8217 } catch (error) { 8218 // If the operation fails, error.code is returned and processed. 8219 let err = error as BusinessError; 8220 console.error(`The setTimeLapseRecordState call failed. error code: ${err.code}`); 8221 } 8222} 8223``` 8224 8225### getTimeLapsePreviewType<sup>12+</sup> 8226 8227getTimeLapsePreviewType(): TimeLapsePreviewType 8228 8229Obtains the time-lapse preview type. 8230 8231**System API**: This is a system API. 8232 8233**System capability**: SystemCapability.Multimedia.Camera.Core 8234 8235**Return value** 8236 8237| Type | Description | 8238| ---------- | ----------------------------- | 8239| [TimeLapsePreviewType](#timelapsepreviewtype12) | Preview type. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 8240 8241**Error codes** 8242 8243For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8244 8245| ID | Error Message | 8246| --------------- | --------------- | 8247| 202 | Not System Application. | 8248| 7400103 | Session not config. | 8249 8250**Example** 8251 8252```ts 8253import { BusinessError } from '@kit.BasicServicesKit'; 8254 8255function getTimeLapsePreviewType(timeLapsePhotoSession: camera.TimeLapsePhotoSession): camera.TimeLapsePreviewType { 8256 let type = camera.TimeLapsePreviewType.DARK; 8257 try { 8258 type = timeLapsePhotoSession.getTimeLapsePreviewType(); 8259 } catch (error) { 8260 // If the operation fails, error.code is returned and processed. 8261 let err = error as BusinessError; 8262 console.error(`The getTimeLapsePreviewType call failed. error code: ${err.code}`); 8263 } 8264 return type; 8265} 8266``` 8267 8268### setTimeLapsePreviewType<sup>12+</sup> 8269 8270setTimeLapsePreviewType(type: TimeLapsePreviewType): void 8271 8272Sets the time-lapse preview type. 8273 8274**System API**: This is a system API. 8275 8276**System capability**: SystemCapability.Multimedia.Camera.Core 8277 8278**Parameters** 8279 8280| Name | Type | Mandatory| Description | 8281| -------- | -------------------------------| ---- | ----------------------- | 8282| state | [TimeLapsePreviewType](#timelapsepreviewtype12) | Yes | Preview type. | 8283 8284**Error codes** 8285 8286For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8287 8288| ID | Error Message | 8289| --------------- | --------------- | 8290| 202 | Not System Application. | 8291| 7400101 | Parameter missing or parameter type incorrect. | 8292| 7400103 | Session not config. | 8293 8294**Example** 8295 8296```ts 8297import { BusinessError } from '@kit.BasicServicesKit'; 8298 8299function setTimeLapsePreviewType(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8300 try { 8301 timeLapsePhotoSession.setTimeLapsePreviewType(camera.TimeLapsePreviewType.LIGHT); 8302 } catch (error) { 8303 // If the operation fails, error.code is returned and processed. 8304 let err = error as BusinessError; 8305 console.error(`The setTimeLapsePreviewType call failed. error code: ${err.code}`); 8306 } 8307} 8308``` 8309 8310## LightPaintingPhotoSession<sup>12+</sup> 8311 8312LightPaintingPhotoSession extends Session, Flash, Focus, Zoom, ColorEffect 8313 8314Implements a light painting photo session, which sets the parameters of the light painting photo mode and saves all [CameraInput](js-apis-camera.md#camerainput) and [CameraOutput](js-apis-camera.md#cameraoutput) instances required to run the camera. It inherits from [Session](js-apis-camera.md#session11). 8315 8316### on('error')<sup>12+</sup> 8317 8318on(type: 'error', callback: ErrorCallback): void 8319 8320Subscribes to **LightPaintingPhotoSession** error events. This API uses an asynchronous callback to return the result. 8321 8322**System API**: This is a system API. 8323 8324**System capability**: SystemCapability.Multimedia.Camera.Core 8325 8326**Parameters** 8327 8328| Name | Type | Mandatory | Description | 8329|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 8330| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as [beginConfig](js-apis-camera.md#beginconfig11), [commitConfig](js-apis-camera.md#commitconfig11-1), and [addInput](js-apis-camera.md#addinput11).| 8331| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes | Callback used to return an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode). | 8332 8333**Error codes** 8334 8335For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8336 8337| ID| Error Message | 8338|-------|----------------------------| 8339| 202 | Not System Application. | 8340 8341**Example** 8342 8343```ts 8344import { BusinessError } from '@kit.BasicServicesKit'; 8345 8346function callback(err: BusinessError): void { 8347 console.error(`LightPaintingPhotoSession error code: ${err.code}`); 8348} 8349 8350function registerSessionError(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8351 lightPaintingPhotoSession.on('error', callback); 8352} 8353``` 8354 8355### off('error')<sup>12+</sup> 8356 8357off(type: 'error', callback?: ErrorCallback): void 8358 8359Unsubscribes from **LightPaintingPhotoSession** error events. 8360 8361**System API**: This is a system API. 8362 8363**System capability**: SystemCapability.Multimedia.Camera.Core 8364 8365**Parameters** 8366 8367| Name | Type | Mandatory| Description | 8368|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 8369| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. | 8370| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | No | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.| 8371 8372**Error codes** 8373 8374For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8375 8376| ID| Error Message | 8377|-------|----------------------------| 8378| 202 | Not System Application. | 8379 8380**Example** 8381 8382```ts 8383function unregisterSessionError(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8384 lightPaintingPhotoSession.off('error'); 8385} 8386``` 8387 8388### on('focusStateChange')<sup>12+</sup> 8389 8390on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 8391 8392Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 8393 8394**System API**: This is a system API. 8395 8396**System capability**: SystemCapability.Multimedia.Camera.Core 8397 8398**Parameters** 8399 8400| Name | Type | Mandatory| Description | 8401|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 8402| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.| 8403| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 8404 8405**Error codes** 8406 8407For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8408 8409| ID| Error Message | 8410|-------|----------------------------| 8411| 202 | Not System Application. | 8412 8413**Example** 8414 8415```ts 8416import { BusinessError } from '@kit.BasicServicesKit'; 8417 8418function callback(err: BusinessError, focusState: camera.FocusState): void { 8419 if (err !== undefined && err.code !== 0) { 8420 console.error(`Callback Error, errorCode: ${err.code}`); 8421 return; 8422 } 8423 console.info(`Focus state: ${focusState}`); 8424} 8425 8426function registerFocusStateChange(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8427 lightPaintingPhotoSession.on('focusStateChange', callback); 8428} 8429``` 8430 8431### off('focusStateChange')<sup>12+</sup> 8432 8433off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 8434 8435Unsubscribes from focus state change events. 8436 8437**System API**: This is a system API. 8438 8439**System capability**: SystemCapability.Multimedia.Camera.Core 8440 8441**Parameters** 8442 8443| Name | Type | Mandatory| Description | 8444|-----------|---------------------------------------------|----|--------------------------------------------------------------| 8445| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. | 8446| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | No | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled. | 8447 8448**Error codes** 8449 8450For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8451 8452| ID| Error Message | 8453|-------|----------------------------| 8454| 202 | Not System Application. | 8455 8456**Example** 8457 8458```ts 8459function unregisterFocusStateChange(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8460 lightPaintingPhotoSession.off('focusStateChange'); 8461} 8462``` 8463 8464### on('smoothZoomInfoAvailable')<sup>12+</sup> 8465 8466on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 8467 8468Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 8469 8470**System API**: This is a system API. 8471 8472**System capability**: SystemCapability.Multimedia.Camera.Core 8473 8474**Parameters** 8475 8476| Name | Type | Mandatory| Description | 8477| -------- | ----------------------- | ---- | ------------------------ | 8478| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 8479| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 8480 8481**Error codes** 8482 8483For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8484 8485| ID| Error Message | 8486|-------|----------------------------| 8487| 202 | Not System Application. | 8488 8489**Example** 8490 8491```ts 8492import { BusinessError } from '@kit.BasicServicesKit'; 8493 8494function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 8495 if (err !== undefined && err.code !== 0) { 8496 console.error(`Callback Error, errorCode: ${err.code}`); 8497 return; 8498 } 8499 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 8500} 8501 8502function registerSmoothZoomInfo(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8503 lightPaintingPhotoSession.on('smoothZoomInfoAvailable', callback); 8504} 8505``` 8506 8507### off('smoothZoomInfoAvailable')<sup>12+</sup> 8508 8509off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 8510 8511Unsubscribes from smooth zoom state change events. 8512 8513**System API**: This is a system API. 8514 8515**System capability**: SystemCapability.Multimedia.Camera.Core 8516 8517**Parameters** 8518 8519| Name | Type | Mandatory| Description | 8520| -------- | ----------------------------------------- | ---- | ------------------------ | 8521| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 8522| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | No | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.| 8523 8524**Error codes** 8525 8526For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8527 8528| ID| Error Message | 8529|-------|----------------------------| 8530| 202 | Not System Application. | 8531 8532**Example** 8533 8534```ts 8535function unregisterSmoothZoomInfo(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8536 lightPaintingPhotoSession.off('smoothZoomInfoAvailable'); 8537} 8538``` 8539 8540### getLightPaintingType<sup>12+</sup> 8541 8542getLightPaintingType(): LightPaintingType 8543 8544Obtains the type of light painting shutter mode in use. 8545 8546**System API**: This is a system API. 8547 8548**System capability**: SystemCapability.Multimedia.Camera.Core 8549 8550**Return value** 8551| Type | Description | 8552|------------------------------------------------- | --------------------- | 8553| [LightPaintingType](#lightpaintingtype12) | Type of light painting shutter mode. | 8554 8555**Error codes** 8556 8557For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8558 8559| ID | Error Message | 8560| --------------- | --------------- | 8561| 202 | Not System Application. | 8562| 7400103 | Session not config. | 8563 8564**Example** 8565 8566```ts 8567function getLightPaintingType(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): camera.LightPaintingType { 8568 let type: camera.LightPaintingType = lightPaintingPhotoSession.getLightPaintingType(); 8569 return type; 8570} 8571``` 8572 8573### setLightPaintingType<sup>12+</sup> 8574 8575setLightPaintingType(type: LightPaintingType): void 8576 8577Sets the type of light painting shutter mode. 8578 8579**System API**: This is a system API. 8580 8581**System capability**: SystemCapability.Multimedia.Camera.Core 8582 8583**Return value** 8584| Name | Type | Mandatory| Description | 8585| -------- | ----------------------- | ---- | ------------------- | 8586| type | [LightPaintingType](#lightpaintingtype12) | Yes | Type of light painting mode.| 8587 8588**Error codes** 8589 8590For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8591 8592| ID | Error Message | 8593| --------------- | --------------- | 8594| 202 | Not System Application. | 8595| 7400101 | Parameter missing or parameter type incorrect. | 8596| 7400103 | Session not config. | 8597 8598**Example** 8599 8600```ts 8601import { BusinessError } from '@kit.BasicServicesKit'; 8602 8603function setLightPaintingType(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8604 try { 8605 let type: camera.LightPaintingType = camera.LightPaintingType.TRAFFIC_TRAILS; 8606 lightPaintingPhotoSession.setLightPaintingType(type); 8607 } catch (error) { 8608 // If the operation fails, error.code is returned and processed. 8609 let err = error as BusinessError; 8610 console.error(`The setLightPaintingType call failed. error code: ${err.code}`); 8611 } 8612} 8613``` 8614 8615### getSupportedLightPaintingTypes<sup>12+</sup> 8616 8617getSupportedLightPaintingTypes(): Array\<LightPaintingType\> 8618 8619Obtains the supported types of light painting shutter mode. 8620 8621**System API**: This is a system API. 8622 8623**System capability**: SystemCapability.Multimedia.Camera.Core 8624 8625**Return value** 8626| Type | Description | 8627|------------------------------------------------- | --------------------- | 8628| Array\<[LightPaintingType](#lightpaintingtype12)\> | Supported types of light painting shutter mode. | 8629 8630**Error codes** 8631 8632For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8633 8634| ID | Error Message | 8635| --------------- | --------------- | 8636| 202 | Not System Application. | 8637| 7400103 | Session not config. | 8638 8639**Example** 8640 8641```ts 8642function getSupportedLightPaintingTypes(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): Array<camera.LightPaintingType> { 8643 let types: Array<camera.LightPaintingType> = lightPaintingPhotoSession.getSupportedLightPaintingTypes(); 8644 return types 8645} 8646``` 8647