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')](js-apis-camera.md#onmetadataobjectsavailable). 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')](js-apis-camera.md#onmetadataobjectsavailable). 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')](js-apis-camera.md#onmetadataobjectsavailable). 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')](js-apis-camera.md#onmetadataobjectsavailable). 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')](js-apis-camera.md#onmetadataobjectsavailable). 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')](js-apis-camera.md#onmetadataobjectsavailable). 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')](js-apis-camera.md#onmetadataobjectsavailable). 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')](js-apis-camera.md#onmetadataobjectsavailable). 2211 2212**System capability**: SystemCapability.Multimedia.Camera.Core 2213 2214## MetadataBarcodeObject<sup>14+</sup> 2215 2216Implements the barcode 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')](js-apis-camera.md#onmetadataobjectsavailable). 2217 2218**System capability**: SystemCapability.Multimedia.Camera.Core 2219 2220## PortraitEffect 2221 2222Enumerates the portrait effects. 2223 2224**System API**: This is a system API. 2225 2226**System capability**: SystemCapability.Multimedia.Camera.Core 2227 2228| Name | Value | Description | 2229| ----------------| ---- | ---------| 2230| OFF | 0 | Disabled. | 2231| CIRCLES | 1 | Circles. | 2232| HEART<sup>11+</sup> | 2 | Heart-shaped. | 2233| ROTATED<sup>11+</sup> | 3 | Rotated. | 2234| STUDIO<sup>11+</sup> | 4 | Studio light. | 2235| THEATER<sup>11+</sup> | 5 | Theater light. | 2236 2237## BeautyQuery<sup>12+</sup> 2238 2239Provides APIs to obtain and set the beauty effect. 2240 2241### getSupportedBeautyTypes<sup>12+</sup> 2242 2243getSupportedBeautyTypes(): Array\<BeautyType\> 2244 2245Obtains the supported beauty types. 2246 2247**System API**: This is a system API. 2248 2249**System capability**: SystemCapability.Multimedia.Camera.Core 2250 2251**Return value** 2252 2253| Type | Description | 2254| ---------- | ----------------------------- | 2255| Array\<[BeautyType](#beautytype)\>| Array of beauty types supported. | 2256 2257**Error codes** 2258 2259For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2260 2261| ID | Error Message | 2262| --------------- | --------------- | 2263| 202 | Not System Application. | 2264| 7400103 | Session not config. | 2265 2266**Example** 2267 2268```ts 2269function getSupportedBeautyTypes(portraitPhotoSession: camera.PortraitPhotoSession): Array<camera.BeautyType> { 2270 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2271 return beautyTypes; 2272} 2273``` 2274 2275### getSupportedBeautyRange<sup>12+</sup> 2276 2277getSupportedBeautyRange(type: BeautyType): Array\<number\> 2278 2279Obtains the levels that can be set a beauty type. 2280 2281The beauty levels vary according to the device type. The following table is only an example. 2282 2283| Input Parameter | Example Return Value | Return Value Description | 2284| ----------------| ---- | ---------| 2285| 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. | 2286| 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. | 2287| 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. | 2288| 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. | 2289 2290**System API**: This is a system API. 2291 2292**System capability**: SystemCapability.Multimedia.Camera.Core 2293 2294**Parameters** 2295 2296| Name | Type | Mandatory| Description | 2297| -------- | --------------------------| ---- | ----------| 2298| type | [BeautyType](#beautytype) | Yes | Beauty type. | 2299 2300**Return value** 2301 2302| Type | Description | 2303| ---------- | ----------------------------- | 2304| Array\<number\> | Array of levels supported.| 2305 2306**Error codes** 2307 2308For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2309 2310| ID | Error Message | 2311| --------------- | --------------- | 2312| 202 | Not System Application. | 2313| 7400103 | Session not config. | 2314 2315**Example** 2316 2317```ts 2318function getSupportedBeautyRange(portraitPhotoSession: camera.PortraitPhotoSession): Array<number> { 2319 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2320 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2321 return []; 2322 } 2323 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2324 return beautyLevels; 2325} 2326``` 2327 2328## BeautyType 2329 2330Enumerates the beauty types. 2331 2332**System API**: This is a system API. 2333 2334**System capability**: SystemCapability.Multimedia.Camera.Core 2335 2336| Name | Value | Description | 2337| ----------------| ---- | ---------| 2338| AUTO | 0 | Automatic. | 2339| SKIN_SMOOTH | 1 | Skin smoothing. | 2340| FACE_SLENDER | 2 | Face slimming. | 2341| SKIN_TONE | 3 | Skin tone perfection. | 2342 2343## ManualExposureQuery<sup>12+</sup> 2344 2345Provides APIs to obtain the manual exposure range supported. 2346 2347### getSupportedExposureRange<sup>12+</sup> 2348 2349getSupportedExposureRange(): Array\<number\> 2350 2351Obtains the supported manual exposure durations. 2352 2353**System API**: This is a system API. 2354 2355**System capability**: SystemCapability.Multimedia.Camera.Core 2356 2357**Return value** 2358 2359| Type | Description | 2360| ---------- | ----------------------------- | 2361| Array\<number\>| Array of manual exposure durations supported, in ms. | 2362 2363**Error codes** 2364 2365For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2366 2367| ID | Error Message | 2368| --------------- | --------------- | 2369| 202 | Not System Application. | 2370| 7400101 | Parameter missing or parameter type incorrect. | 2371| 7400103 | Session not config, only throw in session usage. | 2372 2373 **Example** 2374 2375```ts 2376function getSupportedExposureRange(nightPhotoSession: camera.NightPhotoSession): Array<number> { 2377 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2378 return exposureRange; 2379} 2380``` 2381 2382## ManualExposure<sup>11+</sup> 2383 2384ManualExposure extends [ManualExposureQuery](#manualexposurequery12) 2385 2386Provides APIs to obtain and set the exposure duration. 2387 2388### getExposure<sup>11+</sup> 2389 2390getExposure(): number 2391 2392Obtains the manual exposure duration in use. 2393 2394**System API**: This is a system API. 2395 2396**System capability**: SystemCapability.Multimedia.Camera.Core 2397 2398**Return value** 2399| Name | Type | Mandatory| Description | 2400| -------- | ------------------------------------------------- | ---- | --------------------- | 2401| value | number | Yes | Manual exposure duration, in ms. | 2402 2403**Error codes** 2404 2405For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2406 2407| ID | Error Message | 2408| --------------- | --------------- | 2409| 202 | Not System Application. | 2410| 7400101 | Parameter missing or parameter type incorrect. | 2411| 7400103 | Session not config. | 2412 2413**Example** 2414 2415```ts 2416function getExposure(nightPhotoSession: camera.NightPhotoSession): number | undefined { 2417 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2418 if (exposureRange === undefined || exposureRange.length <= 0) { 2419 return undefined; 2420 } 2421 let exposure: number = nightPhotoSession.getExposure(); 2422 return exposure; 2423} 2424``` 2425 2426### setExposure<sup>11+</sup> 2427 2428setExposure(exposure: number): void 2429 2430Sets the manual exposure duration, in ms. 2431 2432**System API**: This is a system API. 2433 2434**System capability**: SystemCapability.Multimedia.Camera.Core 2435 2436**Parameters** 2437 2438| Name | Type | Mandatory| Description | 2439| -------- | --------------------------| ---- |-------------------------------------------------------------------------| 2440| value | number | Yes | Manual exposure duration, which must be one of the supported durations obtained by running [getSupportedExposureRange](#getsupportedexposurerange12).| 2441 2442 **Error codes** 2443 2444| ID | Error Message | 2445| --------------- | --------------- | 2446| 202 | Not System Application. | 2447| 7400102 | Operation not allowed. | 2448| 7400103 | Session not config. | 2449 2450```ts 2451function setExposure(nightPhotoSession: camera.NightPhotoSession): void { 2452 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2453 if (exposureRange === undefined || exposureRange.length <= 0) { 2454 return; 2455 } 2456 nightPhotoSession.setExposure(exposureRange[0]); 2457} 2458``` 2459 2460## MacroQuery<sup>12+</sup> 2461 2462Provides the API to check the support for macro photography. 2463 2464### isMacroSupported<sup>12+</sup> 2465 2466isMacroSupported(): boolean 2467 2468Checks whether macro photography is supported in the current state. This API must be called after [commitConfig](js-apis-camera.md#commitconfig11-1). 2469 2470**System API**: This is a system API. 2471 2472**System capability**: SystemCapability.Multimedia.Camera.Core 2473 2474**Return value** 2475 2476| Type | Description | 2477| ---------- | ----------------------------- | 2478| boolean | **true**: Macro photography is supported.<br>**false**: Macro photography is not supported.| 2479 2480**Error codes** 2481 2482For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2483 2484| ID | Error Message | 2485|---------|--------------------------| 2486| 202 | Not System Application. | 2487 2488**Example** 2489 2490```ts 2491function isMacroSupported(photoSession: camera.PhotoSessionForSys): boolean { 2492 let isSupported: boolean = photoSession.isMacroSupported(); 2493 return isSupported; 2494} 2495``` 2496 2497## Macro<sup>11+</sup> 2498 2499Macro extends [MacroQuery](#macroquery12) 2500 2501Provides the API to enable macro photography. 2502 2503### enableMacro<sup>11+</sup> 2504 2505enableMacro(enabled: boolean): void 2506 2507Enables or disables macro photography. This API can be called only when macro photography is supported. 2508 2509**System API**: This is a system API. 2510 2511**System capability**: SystemCapability.Multimedia.Camera.Core 2512 2513**Parameters** 2514 2515| Name | Type | Mandatory| Description | 2516| -------- | -------------------- | ---- | -------------------- | 2517| enabled | boolean | Yes | Whether to enable macro photography. The value **true** means to enable macro photography, and **false** means to disable it.| 2518 2519**Error codes** 2520 2521For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2522 2523| ID | Error Message | 2524|----------|--------------------------| 2525| 202 | Not System Application. | 2526| 7400102 | Operation not allowed. | 2527| 7400103 | Session not config. | 2528 2529**Example** 2530 2531```ts 2532function enableMacro(photoSession: camera.PhotoSessionForSys): void { 2533 let isSupported: boolean = photoSession.isMacroSupported(); 2534 if (isSupported) { 2535 photoSession.enableMacro(true); 2536 } 2537} 2538``` 2539 2540## TripodStatus<sup>13+</sup> 2541 2542Enumerates the tripod statuses. 2543 2544**System capability**: SystemCapability.Multimedia.Camera.Core 2545 2546| Name | Value | Description | 2547|----------|-----|-------------------------------------| 2548| INVALID | 0 | Error status, or no tripod detected. **System API**: This is a system API.| 2549| ACTIVE | 1 | The tripod is active. **System API**: This is a system API. | 2550| ENTERING | 2 | The system is transitioning into a stable tripod mode. **System API**: This is a system API. | 2551| EXITING | 3 | The system is leaving the stable tripod mode. **System API**: This is a system API. | 2552 2553 2554## SceneFeatureType<sup>12+</sup> 2555 2556Enumerates the scene features. 2557 2558**System capability**: SystemCapability.Multimedia.Camera.Core 2559 2560| Name | Value | Description | 2561|-------------------------------|-----|---------------------------| 2562| MOON_CAPTURE_BOOST | 0 | Moon scene. **System API**: This is a system API. | 2563| TRIPOD_DETECTION<sup>13+</sup> | 1 | Scene where a tripod is used for photo capture. **System API**: This is a system API. | 2564| LOW_LIGHT_BOOST<sup>13+</sup> | 1 | Scene for long exposure photography. **System API**: This is a system API.| 2565 2566## SceneFeatureDetectionResult<sup>12+</sup> 2567 2568Describes the scene feature detection result. 2569 2570**System capability**: SystemCapability.Multimedia.Camera.Core 2571 2572| Name | Type | Read-only | Mandatory | Description | 2573| -------- | ---------- | -------- | -------- | ---------- | 2574| featureType | [SceneFeatureType](#scenefeaturetype12) | Yes | Yes | Scene feature type. | 2575| detected | boolean | Yes | Yes | Detection result. The value **true** means that the specified scene feature is detected.| 2576 2577## TripodDetectionResult<sup>13+</sup> 2578 2579TripodDetectionResult extends [SceneFeatureDetectionResult](#scenefeaturedetectionresult12) 2580 2581Describes the tripod detection result. 2582 2583**System capability**: SystemCapability.Multimedia.Camera.Core 2584 2585| Name | Type | Read-only | Mandatory | Description | 2586| -------- |---------------------------------| -------- | -------- |---------| 2587| tripodStatus | [TripodStatus](#tripodstatus13) | Yes | Yes | Tripod status.| 2588 2589## SceneDetection<sup>12+</sup> 2590 2591Provides the scene detection capability. 2592 2593### isSceneFeatureSupported<sup>12+</sup> 2594 2595isSceneFeatureSupported(type: SceneFeatureType): boolean 2596 2597Checks whether a scene feature is supported. 2598 2599**System API**: This is a system API. 2600 2601**System capability**: SystemCapability.Multimedia.Camera.Core 2602 2603**Parameters** 2604 2605| Name | Type | Mandatory | Description | 2606|-------|-------------------------------------------|-----|-------------| 2607| type | [SceneFeatureType](#scenefeaturetype12) | Yes | Scene feature. | 2608 2609**Return value** 2610 2611| Type | Description | 2612|-----------|--------------| 2613| boolean | **true**: The scene feature is supported.<br>**false**: The scene feature is not supported. | 2614 2615**Error codes** 2616 2617For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2618 2619| ID | Error Message | 2620|---------|------------------------------------------------| 2621| 202 | Not System Application. | 2622| 7400101 | Parameter missing or parameter type incorrect. | 2623 2624**Example** 2625 2626```ts 2627function isSceneFeatureSupported(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): boolean { 2628 let isSupported: boolean = photoSession.isSceneFeatureSupported(featureType); 2629 return isSupported; 2630} 2631``` 2632 2633### enableSceneFeature<sup>12+</sup> 2634 2635enableSceneFeature(type: SceneFeatureType, enabled: boolean): void 2636 2637Enables or disables a scene feature. This API must be called after [SceneFeatureDetectionResult](#scenefeaturedetectionresult12) of the corresponding scene feature is received. 2638 2639**System API**: This is a system API. 2640 2641**System capability**: SystemCapability.Multimedia.Camera.Core 2642 2643**Parameters** 2644 2645| Name | Type | Mandatory | Description | 2646|---------|-------------------------------------------|-----|-----------------------------| 2647| type | [SceneFeatureType](#scenefeaturetype12) | Yes | Scene feature. | 2648| enabled | boolean | Yes | Whether to enable the scene feature. The value **true** means to enable the scene feature, and **false** means the opposite.| 2649 2650**Error codes** 2651 2652For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2653 2654| ID | Error Message | 2655|---------|------------------------------------------------| 2656| 202 | Not System Application. | 2657| 7400101 | Parameter missing or parameter type incorrect. | 2658 2659**Example** 2660 2661```ts 2662import { BusinessError } from '@kit.BasicServicesKit'; 2663 2664function enableSceneFeature(photoSession: camera.PhotoSessionForSys, cameraInput: camera.CameraInput, previewOutput: camera.PreviewOutput): void { 2665 photoSession.beginConfig(); 2666 photoSession.addInput(cameraInput); 2667 photoSession.addOutput(previewOutput); 2668 photoSession.commitConfig(); 2669 2670 photoSession.on('featureDetection', camera.SceneFeatureType.MOON_CAPTURE_BOOST, 2671 (err: BusinessError, statusObject: camera.SceneFeatureDetectionResult) => { 2672 if (err !== undefined && err.code !== 0) { 2673 console.error(`Callback Error, errorCode: ${err.code}`); 2674 return; 2675 } 2676 console.info( 2677 `on featureDetectionStatus featureType:${statusObject.featureType} detected:${statusObject.detected}`); 2678 if (statusObject.featureType === camera.SceneFeatureType.MOON_CAPTURE_BOOST) { 2679 try { 2680 photoSession.enableSceneFeature(statusObject.featureType, statusObject.detected); 2681 } catch (error) { 2682 let err = error as BusinessError; 2683 console.error(`The enableSceneFeature call failed. error code: ${err.code}`); 2684 } 2685 } 2686 }); 2687} 2688``` 2689 2690## ZoomPointInfo<sup>12+</sup> 2691 2692Describes the equivalent focal length information. 2693 2694**System API**: This is a system API. 2695 2696**System capability**: SystemCapability.Multimedia.Camera.Core 2697 2698| Name | Type | Read-only | Optional | Description | 2699| -------- | ---------- | -------- |-----| ---------- | 2700| zoomRatio | number | Yes | No | Zoom ratio.| 2701| equivalentFocalLength | number | Yes | No | Equivalent focal length corresponding to the current focal length ratio.| 2702 2703## ZoomQuery<sup>12+</sup> 2704 2705Provides the API to obtain the equivalent focal length information list in the current mode. 2706 2707### getZoomPointInfos<sup>12+</sup> 2708 2709getZoomPointInfos(): Array\<ZoomPointInfo\> 2710 2711Obtains the equivalent focal length information list in the current mode. 2712 2713**System API**: This is a system API. 2714 2715**System capability**: SystemCapability.Multimedia.Camera.Core 2716 2717**Return value** 2718 2719| Type | Description | 2720| ---------- | ----------------------------- | 2721| Array\<[ZoomPointInfo](#zoompointinfo12)\>| Equivalent focal length information list in the current mode. | 2722 2723**Error codes** 2724 2725For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2726 2727| ID | Error Message | 2728| --------------- | --------------- | 2729| 202 | Not System Application. | 2730| 7400103 | Session not config. | 2731 2732**Example** 2733 2734```ts 2735import { BusinessError } from '@kit.BasicServicesKit'; 2736 2737function getZoomPointInfos(): Array<ZoomPointInfo> { 2738 try { 2739 let zoomPointInfos: Array<ZoomPointInfo> = sessionExtendsZoom.getZoomPointInfos(); 2740 return zoomPointInfos; 2741 } catch (error) { 2742 // If the operation fails, error.code is returned and processed. 2743 let err = error as BusinessError; 2744 console.error(`The getZoomPointInfos call failed. error code: ${err.code}`); 2745 } 2746} 2747``` 2748 2749## Zoom<sup>11+</sup> 2750 2751Zoom extend [ZoomQuery](#zoomquery12) 2752 2753Provides 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. 2754 2755### prepareZoom<sup>11+</sup> 2756 2757prepareZoom(): void 2758 2759Instructs the bottom layer to prepare for zooming, for example, powering on the sensor. 2760 2761**System API**: This is a system API. 2762 2763**System capability**: SystemCapability.Multimedia.Camera.Core 2764 2765**Error codes** 2766 2767For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2768 2769| ID | Error Message | 2770| --------------- | --------------- | 2771| 202 | Not System Application. | 2772| 7400103 | Session not config. | 2773 2774**Example** 2775 2776```ts 2777import { BusinessError } from '@kit.BasicServicesKit'; 2778 2779function prepareZoom(sessionExtendsZoom: camera.Zoom): void { 2780 try { 2781 sessionExtendsZoom.prepareZoom(); 2782 } catch (error) { 2783 // If the operation fails, error.code is returned and processed. 2784 let err = error as BusinessError; 2785 console.error(`The prepareZoom call failed. error code: ${err.code}`); 2786 } 2787} 2788``` 2789 2790### unprepareZoom<sup>11+</sup> 2791 2792unprepareZoom(): void 2793 2794Instructs the bottom layer to unprepare for zooming. 2795 2796**System API**: This is a system API. 2797 2798**System capability**: SystemCapability.Multimedia.Camera.Core 2799 2800**Error codes** 2801 2802For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2803 2804| ID | Error Message | 2805| --------------- | --------------- | 2806| 202 | Not System Application. | 2807| 7400103 | Session not config. | 2808 2809**Example** 2810 2811```ts 2812import { BusinessError } from '@kit.BasicServicesKit'; 2813 2814function unprepareZoom(sessionExtendsZoom: camera.Zoom): void { 2815 try { 2816 sessionExtendsZoom.unprepareZoom(); 2817 } catch (error) { 2818 // If the operation fails, error.code is returned and processed. 2819 let err = error as BusinessError; 2820 console.error(`The unprepareZoom call failed. error code: ${err.code}`); 2821 } 2822} 2823``` 2824 2825## ZoomRange<sup>11+</sup> 2826 2827Obtains the supported zoom ratio range. The range is [min, max), which includes the minimum value but excludes the maximum value. 2828 2829**System API**: This is a system API. 2830 2831**System capability**: SystemCapability.Multimedia.Camera.Core 2832 2833| Name | Type | Read-only| Mandatory| Description | 2834| -------- | ------------- |---- | ---- | -------------| 2835| min | number | Yes | N/A | Minimum value of the zoom ratio range. | 2836| max | number | Yes | N/A | Maximum value of the zoom ratio range.| 2837 2838## Beauty<sup>11+</sup> 2839 2840Beauty extends [BeautyQuery](#beautyquery12) 2841 2842Provides APIs to obtain and set the beauty effect. 2843 2844### setBeauty<sup>11+</sup> 2845 2846setBeauty(type: BeautyType, value: number): void 2847 2848Sets a beauty type and its level. Beauty mode is turned off only when all the [beauty types](#beautytype) obtained through [getSupportedBeautyTypes](#getsupportedbeautytypes12) are disabled. 2849 2850**System API**: This is a system API. 2851 2852**System capability**: SystemCapability.Multimedia.Camera.Core 2853 2854**Parameters** 2855 2856| Name | Type | Mandatory| Description | 2857| -------- | --------------------------| ---- |-------------------------------------------------------------------| 2858| type | [BeautyType](#beautytype) | Yes | Beauty type. | 2859| value | number | Yes | Beauty level, which is obtained through [getSupportedBeautyRange](#getsupportedbeautyrange12).| 2860 2861**Error codes** 2862 2863For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2864 2865| ID | Error Message | 2866| --------------- | --------------- | 2867| 202 | Not System Application. | 2868| 7400103 | Session not config. | 2869 2870**Example** 2871 2872```ts 2873function setBeauty(portraitPhotoSession: camera.PortraitPhotoSession): void { 2874 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2875 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2876 return; 2877 } 2878 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2879 if (beautyLevels === undefined || beautyLevels.length <= 0) { 2880 return; 2881 } 2882 portraitPhotoSession.setBeauty(beautyTypes[0], beautyLevels[0]); 2883} 2884``` 2885 2886### getBeauty<sup>11+</sup> 2887 2888getBeauty(type: BeautyType): number 2889 2890Obtains the level of the beauty type in use. 2891 2892**System API**: This is a system API. 2893 2894**System capability**: SystemCapability.Multimedia.Camera.Core 2895 2896**Parameters** 2897 2898| Name | Type | Mandatory| Description | 2899| -------- | ------------------------------------------------- | ---- | --------------------- | 2900| type | [BeautyType](#beautytype) | Yes | Beauty type. | 2901 2902**Return value** 2903| Name | Type | Mandatory| Description | 2904| -------- | ------------------------------------------------- | ---- | --------------------- | 2905| value | number | Yes | Beauty level. | 2906 2907**Error codes** 2908 2909For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2910 2911| ID | Error Message | 2912| --------------- | --------------- | 2913| 202 | Not System Application. | 2914| 7400103 | Session not config. | 2915 2916**Example** 2917 2918```ts 2919function getBeauty(portraitPhotoSession: camera.PortraitPhotoSession): number { 2920 const invalidValue: number = -1; 2921 let beautyTypes = portraitPhotoSession.getSupportedBeautyTypes(); 2922 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2923 return invalidValue; 2924 } 2925 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2926 if (beautyLevels === undefined || beautyLevels.length <= 0) { 2927 return invalidValue; 2928 } 2929 portraitPhotoSession.setBeauty(beautyTypes[0], beautyLevels[0]); 2930 let beautyLevel: number = portraitPhotoSession.getBeauty(beautyTypes[0]); 2931 return beautyLevel; 2932} 2933``` 2934 2935## ColorEffectQuery<sup>12+</sup> 2936 2937Provides the API to obtain the color effects supported. 2938 2939### getSupportedColorEffects<sup>12+</sup> 2940 2941getSupportedColorEffects(): Array\<ColorEffectType\> 2942 2943Obtains the supported color effects. 2944 2945**System API**: This is a system API. 2946 2947**System capability**: SystemCapability.Multimedia.Camera.Core 2948 2949**Return value** 2950 2951| Type | Description | 2952| ----------------------------------------------- | ---------------------------- | 2953| Array<[ColorEffectType](#coloreffecttype11)> | Array of color effects supported. | 2954 2955**Error codes** 2956 2957For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2958 2959| ID | Error Message | 2960| --------------- | --------------- | 2961| 7400103 | Session not config. | 2962| 202 | Not System Application. | 2963 2964**Example** 2965 2966```ts 2967function getSupportedColorEffects(session: camera.PhotoSessionForSys): Array<camera.ColorEffectType> { 2968 let colorEffects: Array<camera.ColorEffectType> = session.getSupportedColorEffects(); 2969 return colorEffects; 2970} 2971``` 2972 2973## ColorEffect<sup>11+</sup> 2974 2975ColorEffect extends [ColorEffectQuery](#coloreffectquery12) 2976 2977Provides the APIs to obtain and set the lens color effect. 2978 2979### setColorEffect<sup>11+</sup> 2980 2981setColorEffect(type: ColorEffectType): void 2982 2983Sets a color effect. Before the setting, call [getSupportedColorEffects](#getsupportedcoloreffects12) to obtain the supported color effects. 2984 2985**System API**: This is a system API. 2986 2987**System capability**: SystemCapability.Multimedia.Camera.Core 2988 2989**Parameters** 2990 2991| Name | Type | Mandatory| Description | 2992| ------------ |--------------------------------------------------------------- | -- | -------------------------- | 2993| type | [ColorEffectType](#coloreffecttype11) | Yes| Color effect, which can be obtained through [getSupportedColorEffects](#getsupportedcoloreffects12). | 2994 2995**Error codes** 2996 2997For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2998 2999| ID | Error Message | 3000| --------------- | --------------- | 3001| 7400103 | Session not config. | 3002| 202 | Not System Application. | 3003 3004**Example** 3005 3006```ts 3007function setColorEffect(session: camera.PhotoSessionForSys, colorEffect: camera.ColorEffectType): void { 3008 session.setColorEffect(colorEffect); 3009} 3010``` 3011 3012### getColorEffect<sup>11+</sup> 3013 3014getColorEffect(): ColorEffectType 3015 3016Obtains the color effect in use. 3017 3018**System API**: This is a system API. 3019 3020**System capability**: SystemCapability.Multimedia.Camera.Core 3021 3022**Return value** 3023 3024| Type | Description | 3025| ----------------------------------------------- | ---------------------------- | 3026| [ColorEffectType](#coloreffecttype11) | Color effect. | 3027 3028**Error codes** 3029 3030For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3031 3032| ID | Error Message | 3033| --------------- | --------------- | 3034| 7400103 | Session not config. | 3035| 202 | Not System Application. | 3036 3037**Example** 3038 3039```ts 3040function getColorEffect(session: camera.PhotoSessionForSys): camera.ColorEffectType { 3041 let colorEffect: camera.ColorEffectType = session.getColorEffect(); 3042 return colorEffect; 3043} 3044``` 3045 3046## ColorEffectType<sup>11+</sup> 3047 3048Enumerates the color effect types. 3049 3050**System API**: This is a system API. 3051 3052**System capability**: SystemCapability.Multimedia.Camera.Core 3053 3054| Name | Value | Description | 3055| --------------------- | ---- | --------- | 3056| NORMAL | 0 | Regular color effect. | 3057| BRIGHT | 1 | Bright color effect. | 3058| SOFT | 2 | Soft color effect. | 3059| BLACK_WHITE<sup>12+</sup> | 3 | Black and white color effect. | 3060 3061## Portrait<sup>11+</sup> 3062 3063Provides the APIs for portrait photo settings. 3064 3065### getSupportedPortraitEffects<sup>10+</sup> 3066 3067getSupportedPortraitEffects(): Array\<PortraitEffect\> 3068 3069Obtains the supported portrait effects. 3070 3071**System API**: This is a system API. 3072 3073**System capability**: SystemCapability.Multimedia.Camera.Core 3074 3075**Return value** 3076 3077| Type | Description | 3078| ----------------------------------------------- | ---------------------------- | 3079| Array<[PortraitEffect](#portraiteffect)> | Array of portrait effects supported. | 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 3093function getSupportedPortraitEffects(portraitPhotoSession: camera.PortraitPhotoSession): Array<camera.PortraitEffect> { 3094 let portraitEffects: Array<camera.PortraitEffect> = portraitPhotoSession.getSupportedPortraitEffects(); 3095 return portraitEffects; 3096} 3097``` 3098 3099### setPortraitEffect<sup>10+</sup> 3100 3101setPortraitEffect(effect: PortraitEffect): void 3102 3103Sets a portrait effect. Before the setting, call [getSupportedPortraitEffects](#getsupportedportraiteffects10) to obtain the supported portrait effects and check whether the target portrait effect is supported. 3104 3105**System API**: This is a system API. 3106 3107**System capability**: SystemCapability.Multimedia.Camera.Core 3108 3109**Parameters** 3110 3111| Name | Type | Mandatory| Description | 3112| ------------ |----------------------------- | -- | -------------------------- | 3113| effect | [PortraitEffect](#portraiteffect) | Yes| Portrait effect, which can be obtained through [getSupportedPortraitEffects](#getsupportedportraiteffects10). | 3114 3115**Error codes** 3116 3117For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3118 3119| ID | Error Message | 3120| --------------- | --------------- | 3121| 7400103 | Session not config. | 3122| 202 | Not System Application. | 3123 3124**Example** 3125 3126```ts 3127import { BusinessError } from '@kit.BasicServicesKit'; 3128 3129function setPortraitEffect(portraitPhotoSession: camera.PortraitPhotoSession, portraitEffects: Array<camera.PortraitEffect>): void { 3130 if (portraitEffects === undefined || portraitEffects.length <= 0) { 3131 return; 3132 } 3133 try { 3134 portraitPhotoSession.setPortraitEffect(portraitEffects[0]); 3135 } catch (error) { 3136 let err = error as BusinessError; 3137 console.error(`The setPortraitEffect call failed. error code: ${err.code}`); 3138 } 3139} 3140``` 3141 3142### getPortraitEffect<sup>10+</sup> 3143 3144getPortraitEffect(): PortraitEffect 3145 3146Obtains the portrait effect in use. 3147 3148**System API**: This is a system API. 3149 3150**System capability**: SystemCapability.Multimedia.Camera.Core 3151 3152**Return value** 3153 3154| Type | Description | 3155| ----------------------------------------------- | ---------------------------- | 3156| [PortraitEffect](#portraiteffect) | Portrait effect. | 3157 3158**Error codes** 3159 3160For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3161 3162| ID | Error Message | 3163| --------------- | --------------- | 3164| 7400103 | Session not config. | 3165| 202 | Not System Application. | 3166 3167**Example** 3168 3169```ts 3170function getPortraitEffect(portraitPhotoSession: camera.PortraitPhotoSession): camera.PortraitEffect { 3171 let portraitEffect: camera.PortraitEffect = portraitPhotoSession.getPortraitEffect(); 3172 return portraitEffect; 3173} 3174``` 3175 3176## PhysicalAperture<sup>11+</sup> 3177 3178Defines the physical aperture information. 3179 3180**System API**: This is a system API. 3181 3182**System capability**: SystemCapability.Multimedia.Camera.Core 3183 3184| Name | Type | Read-only| Optional | Description | 3185| ---------- | ------------------------- | ----- |-----| ----------------- | 3186| zoomRange | [ZoomRange](#zoomrange11) | No | No | Zoom range of a given physical aperture. | 3187| apertures | Array\<number\> | No | No | Array of physical apertures supported. | 3188 3189## Aperture<sup>11+</sup> 3190 3191Provides the APIs for aperture settings. 3192 3193### getSupportedVirtualApertures<sup>11+</sup> 3194 3195getSupportedVirtualApertures(): Array\<number\> 3196 3197Obtains the supported virtual apertures. 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| Array\<number\> | Array of virtual apertures supported. | 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 getSupportedVirtualApertures(session: camera.PortraitPhotoSession): Array<number> { 3222 let virtualApertures: Array<number> = session.getSupportedVirtualApertures(); 3223 return virtualApertures; 3224} 3225``` 3226 3227### getVirtualAperture<sup>11+</sup> 3228 3229getVirtualAperture(): number 3230 3231Obtains the virtual aperture in use. 3232 3233**System API**: This is a system API. 3234 3235**System capability**: SystemCapability.Multimedia.Camera.Core 3236 3237**Return value** 3238 3239| Type | Description | 3240| ----------------------------------------------- | ---------------------------- | 3241| number | Virtual aperture. | 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 getVirtualAperture(session: camera.PortraitPhotoSession): number { 3256 let virtualAperture: number = session.getVirtualAperture(); 3257 return virtualAperture; 3258} 3259``` 3260 3261### setVirtualAperture<sup>11+</sup> 3262 3263setVirtualAperture(aperture: number): void 3264 3265Sets a virtual aperture. Before the setting, call [getSupportedVirtualApertures](#getsupportedvirtualapertures11) to obtain the supported virtual apertures. 3266 3267**System API**: This is a system API. 3268 3269**System capability**: SystemCapability.Multimedia.Camera.Core 3270 3271**Parameters** 3272 3273| Name | Type | Mandatory| Description | 3274| ------------ |------------------------- | -- | -------------------------- | 3275| aperture | number | Yes| Virtual aperture, which can be obtained by calling [getSupportedVirtualApertures](#getsupportedvirtualapertures11). | 3276 3277**Error codes** 3278 3279For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3280 3281| ID | Error Message | 3282| --------------- | --------------- | 3283| 7400103 | Session not config. | 3284| 202 | Not System Application. | 3285 3286**Example** 3287 3288```ts 3289function setVirtualAperture(session: camera.PortraitPhotoSession, virtualAperture: number): void { 3290 session.setVirtualAperture(virtualAperture); 3291} 3292``` 3293 3294### getSupportedPhysicalApertures<sup>11+</sup> 3295 3296getSupportedPhysicalApertures(): Array\<PhysicalAperture\> 3297 3298Obtains the supported physical apertures. 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| Array<[PhysicalAperture](#physicalaperture11)> | Array of physical apertures supported. | 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 getSupportedPhysicalApertures(session: camera.PortraitPhotoSession): Array<camera.PhysicalAperture> { 3323 let physicalApertures: Array<camera.PhysicalAperture> = session.getSupportedPhysicalApertures(); 3324 return physicalApertures; 3325} 3326``` 3327 3328### getPhysicalAperture<sup>11+</sup> 3329 3330getPhysicalAperture(): number 3331 3332Obtains the physical aperture in use. 3333 3334**System API**: This is a system API. 3335 3336**System capability**: SystemCapability.Multimedia.Camera.Core 3337 3338**Return value** 3339 3340| Type | Description | 3341| -------------------- | ---------------------------- | 3342| number | Physical aperture. | 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 getPhysicalAperture(session: camera.PortraitPhotoSession): number { 3357 let physicalAperture: number = session.getPhysicalAperture(); 3358 return physicalAperture; 3359} 3360``` 3361 3362### setPhysicalAperture<sup>11+</sup> 3363 3364setPhysicalAperture(aperture: number): void 3365 3366Sets a physical aperture. Before the setting, call [getSupportedPhysicalApertures](#getsupportedphysicalapertures11) to obtain the supported physical apertures. 3367 3368**System API**: This is a system API. 3369 3370**System capability**: SystemCapability.Multimedia.Camera.Core 3371 3372**Parameters** 3373 3374| Name | Type | Mandatory| Description | 3375| ------------ |------------------------- | -- | -------------------------- | 3376| aperture | number | Yes| Physical aperture, which can be obtained by calling [getSupportedPhysicalApertures](#getsupportedphysicalapertures11). | 3377 3378**Error codes** 3379 3380For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3381 3382| ID | Error Message | 3383| --------------- | --------------- | 3384| 7400103 | Session not config. | 3385| 202 | Not System Application. | 3386 3387**Example** 3388 3389```ts 3390function setPhysicalAperture(session: camera.PortraitPhotoSession, physicalAperture: number): void { 3391 session.setPhysicalAperture(physicalAperture); 3392} 3393``` 3394 3395## CaptureSession<sup>(deprecated)</sup> 3396 3397Implements 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. 3398 3399> **NOTE** 3400> 3401> 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. 3402 3403### getSupportedBeautyTypes<sup>(deprecated)</sup> 3404 3405getSupportedBeautyTypes(): Array\<BeautyType> 3406 3407Obtains the supported beauty types. 3408 3409> **NOTE** 3410> 3411> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Beauty.getSupportedBeautyTypes](#getsupportedbeautytypes12) instead. 3412 3413**System API**: This is a system API. 3414 3415**System capability**: SystemCapability.Multimedia.Camera.Core 3416 3417**Return value** 3418 3419| Type | Description | 3420| ---------- | ----------------------------- | 3421| Array\<[BeautyType](#beautytype)\>| Array of beauty types supported. | 3422 3423**Error codes** 3424 3425For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3426 3427| ID | Error Message | 3428| --------------- | --------------- | 3429| 7400103 | Session not config. | 3430 3431**Example** 3432 3433```ts 3434function getSupportedBeautyTypes(captureSession: camera.CaptureSession): Array<camera.BeautyType> { 3435 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3436 return beautyTypes; 3437} 3438``` 3439 3440### getSupportedBeautyRange<sup>(deprecated)</sup> 3441 3442getSupportedBeautyRange(type: BeautyType): Array\<number\> 3443 3444Obtains 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. 3445 3446| Input Parameter | Example Return Value | Return Value Description | 3447| ----------------| ---- | ---------| 3448| 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. | 3449| 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. | 3450| 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. | 3451| 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. | 3452 3453> **NOTE** 3454> 3455> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Beauty.getSupportedBeautyRange](#getsupportedbeautyrange12) instead. 3456 3457**System API**: This is a system API. 3458 3459**System capability**: SystemCapability.Multimedia.Camera.Core 3460 3461**Parameters** 3462 3463| Name | Type | Mandatory| Description | 3464| -------- | --------------------------| ---- | ----------| 3465| type | [BeautyType](#beautytype) | Yes | Beauty type. | 3466 3467**Return value** 3468 3469| Type | Description | 3470| ---------- | ----------------------------- | 3471| Array\<number\> | Array of levels supported.| 3472 3473**Error codes** 3474 3475For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3476 3477| ID | Error Message | 3478| --------------- | --------------- | 3479| 7400103 | Session not config. | 3480 3481**Example** 3482 3483```ts 3484function getSupportedBeautyRange(captureSession: camera.CaptureSession): Array<number> { 3485 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3486 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3487 return []; 3488 } 3489 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3490 return beautyLevels; 3491} 3492``` 3493 3494### setBeauty<sup>(deprecated)</sup> 3495 3496setBeauty(type: BeautyType, value: number): void 3497 3498Sets a beauty type and its level. Beauty mode is turned off only when all the [beauty types](#beautytype) obtained through [getSupportedBeautyTypes](#getsupportedbeautytypesdeprecated) are disabled. 3499 3500> **NOTE** 3501> 3502> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Beauty.setBeauty](#setbeauty11) instead. 3503 3504**System API**: This is a system API. 3505 3506**System capability**: SystemCapability.Multimedia.Camera.Core 3507 3508**Parameters** 3509 3510| Name | Type | Mandatory| Description | 3511| -------- | --------------------------| ---- | --------------------- | 3512| type | [BeautyType](#beautytype) | Yes | Beauty type. | 3513| value | number | Yes | Beauty level, which is obtained through [getSupportedBeautyRange](#getsupportedbeautyrangedeprecated).| 3514 3515**Error codes** 3516 3517For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3518 3519| ID | Error Message | 3520| --------------- | --------------- | 3521| 7400103 | Session not config. | 3522 3523**Example** 3524 3525```ts 3526function setBeauty(captureSession: camera.CaptureSession): void { 3527 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3528 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3529 return; 3530 } 3531 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3532 if (beautyLevels === undefined || beautyLevels.length <= 0) { 3533 return; 3534 } 3535 captureSession.setBeauty(beautyTypes[0], beautyLevels[0]); 3536} 3537``` 3538 3539### getBeauty<sup>(deprecated)</sup> 3540 3541getBeauty(type: BeautyType): number 3542 3543Obtains the level of the beauty type in use. 3544 3545> **NOTE** 3546> 3547> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Beauty.getBeauty](#getbeauty11) instead. 3548 3549**System API**: This is a system API. 3550 3551**System capability**: SystemCapability.Multimedia.Camera.Core 3552 3553**Parameters** 3554 3555| Name | Type | Mandatory| Description | 3556| -------- | ------------------------------------------------- | ---- | --------------------- | 3557| type | [BeautyType](#beautytype) | Yes | Beauty type. | 3558 3559**Return value** 3560| Name | Type | Mandatory| Description | 3561| -------- | ------------------------------------------------- | ---- | --------------------- | 3562| value | number | Yes | Beauty level. | 3563 3564**Error codes** 3565 3566For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3567 3568| ID | Error Message | 3569| --------------- | --------------- | 3570| 7400103 | Session not config. | 3571 3572**Example** 3573 3574```ts 3575function getBeauty(captureSession: camera.CaptureSession): number { 3576 const invalidValue: number = -1; 3577 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3578 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3579 return invalidValue; 3580 } 3581 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3582 if (beautyLevels === undefined || beautyLevels.length <= 0) { 3583 return invalidValue; 3584 } 3585 captureSession.setBeauty(beautyTypes[0], beautyLevels[0]); 3586 let beautyLevel: number = captureSession.getBeauty(beautyTypes[0]); 3587 return beautyLevel; 3588} 3589``` 3590 3591## PhotoSessionForSys<sup>11+</sup> 3592 3593PhotoSessionForSys extends PhotoSession, Beauty, ColorEffect, ColorManagement, Macro, SceneDetection 3594 3595Implements 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). 3596 3597**System API**: This is a system API. 3598 3599**System capability**: SystemCapability.Multimedia.Camera.Core 3600 3601## PhotoSession<sup>11+</sup> 3602 3603PhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorManagement 3604 3605Implements 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). 3606 3607### on('macroStatusChanged')<sup>11+</sup> 3608 3609on(type: 'macroStatusChanged', callback: AsyncCallback\<boolean\>): void 3610 3611Subscribes to macro state change events. This API uses an asynchronous callback to return the result. 3612 3613**System API**: This is a system API. 3614 3615**System capability**: SystemCapability.Multimedia.Camera.Core 3616 3617**Parameters** 3618 3619| Name | Type | Mandatory| Description | 3620| -------- | ----------------------------------------- | ---- | ------------------------ | 3621| type | string | Yes | Event type. The value is fixed at **'macroStatusChanged'**. The event can be listened for when a session is created.| 3622| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the macro state change. | 3623 3624**Error codes** 3625 3626For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3627 3628| ID| Error Message | 3629|-------|---------------------------| 3630| 202 | Not System Application. | 3631 3632**Example** 3633 3634```ts 3635import { BusinessError } from '@kit.BasicServicesKit'; 3636 3637function callback(err: BusinessError, macroStatus: boolean): void { 3638 if (err !== undefined && err.code !== 0) { 3639 console.error(`Callback Error, errorCode: ${err.code}`); 3640 return; 3641 } 3642 console.info(`Macro state: ${macroStatus}`); 3643} 3644 3645function registerMacroStatusChanged(photoSession: camera.PhotoSession): void { 3646 photoSession.on('macroStatusChanged', callback); 3647} 3648``` 3649 3650### off('macroStatusChanged')<sup>11+</sup> 3651 3652off(type: 'macroStatusChanged', callback?: AsyncCallback\<boolean\>): void 3653 3654Unsubscribes from macro state change events. 3655 3656**System API**: This is a system API. 3657 3658**System capability**: SystemCapability.Multimedia.Camera.Core 3659 3660**Parameters** 3661 3662| Name | Type | Mandatory| Description | 3663| -------- | ------------------------ | ---- | ------------------------ | 3664| type | string | Yes | Event type. The value is fixed at **'macroStatusChanged'**. The event can be listened for when a session is created.| 3665| 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.)| 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 3678function unregisterMacroStatusChanged(photoSession: camera.PhotoSession): void { 3679 photoSession.off('macroStatusChanged'); 3680} 3681``` 3682 3683### on('featureDetection')<sup>12+</sup> 3684 3685on(type: 'featureDetection', featureType: SceneFeatureType, callback: AsyncCallback\<SceneFeatureDetectionResult\>): void 3686 3687Subscribe to scene feature detection status change events. This API uses an asynchronous callback to return the result. 3688 3689**System API**: This is a system API. 3690 3691**System capability**: SystemCapability.Multimedia.Camera.Core 3692 3693**Parameters** 3694 3695| Name | Type | Mandatory| Description | 3696| -------- | ----------------------------------------- | ---- | ------------------------ | 3697| type | string | Yes | Event type. The value is fixed at **'featureDetection'**. The event can be listened for when a photo session is created.| 3698| featureType | [SceneFeatureType](#scenefeaturetype12) | Yes | Scene feature type.| 3699| callback | AsyncCallback\<[SceneFeatureDetectionResult](#scenefeaturedetectionresult12)\> | Yes | Callback used to return the status of the scene feature detection. | 3700 3701**Error codes** 3702 3703For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3704 3705| ID| Error Message | 3706|-------|---------------------------| 3707| 202 | Not System Application. | 3708 3709**Example** 3710 3711```ts 3712import { BusinessError } from '@kit.BasicServicesKit'; 3713 3714function callback(err: BusinessError, result: camera.SceneFeatureDetectionResult): void { 3715 if (err !== undefined && err.code !== 0) { 3716 console.error(`Callback Error, errorCode: ${err.code}`); 3717 return; 3718 } 3719 console.info(`feature type: ${result.featureType}`); 3720 console.info(`feature status: ${result.detected}`); 3721} 3722 3723function registerFeatureDetectionStatus(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): void { 3724 photoSession.on('featureDetection', featureType, callback); 3725} 3726``` 3727 3728### off('featureDetection')<sup>12+</sup> 3729 3730off(type: 'featureDetection', featureType: SceneFeatureType, callback?: AsyncCallback\<SceneFeatureDetectionResult\>): void 3731 3732Unsubscribe from camera feature detection status change events. 3733 3734**System API**: This is a system API. 3735 3736**System capability**: SystemCapability.Multimedia.Camera.Core 3737 3738**Parameters** 3739 3740| Name | Type | Mandatory| Description | 3741| -------- | ------------------------ | ---- | ------------------------ | 3742| type | string | Yes | Event type. The value is fixed at **'featureDetection'**. The event can be listened for when a session is created.| 3743| featureType | [SceneFeatureType](#scenefeaturetype12) | Yes | Scene feature type.| 3744| 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.)| 3745 3746**Error codes** 3747 3748For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3749 3750| ID| Error Message | 3751|-------|---------------------------| 3752| 202 | Not System Application. | 3753 3754**Example** 3755 3756```ts 3757function unregisterFeatureDetectionStatus(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): void { 3758 photoSession.off('featureDetection', featureType); 3759} 3760``` 3761 3762### on('lcdFlashStatus')<sup>13+</sup> 3763 3764on(type: 'lcdFlashStatus', callback: AsyncCallback\<LcdFlashStatus\>): void 3765 3766Subscribes to LCD flash status change events. This API uses an asynchronous callback to return the result. 3767 3768**System API**: This is a system API. 3769 3770**System capability**: SystemCapability.Multimedia.Camera.Core 3771 3772**Parameters** 3773 3774| Name | Type | Mandatory| Description | 3775| -------- | ----------------------------------------- | ---- |------------------------------------------| 3776| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created.| 3777| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | Yes | Callback used to return the LCD flash status change. | 3778 3779**Error codes** 3780 3781For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3782 3783| ID| Error Message | 3784|-------|---------------------------| 3785| 202 | Not System Application. | 3786 3787**Example** 3788 3789```ts 3790import { BusinessError } from '@kit.BasicServicesKit'; 3791 3792function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 3793 if (err !== undefined && err.code !== 0) { 3794 console.error(`Callback Error, errorCode: ${err.code}`); 3795 return; 3796 } 3797 console.info(`isLcdFlashNeeded: ${lcdFlashStatus.isLcdFlashNeeded}`); 3798 console.info(`lcdCompensation: ${lcdFlashStatus.lcdCompensation}`); 3799} 3800 3801function registerLcdFlashStatus(photoSession: camera.PhotoSession): void { 3802 photoSession.on('lcdFlashStatus', callback); 3803} 3804``` 3805 3806### off('lcdFlashStatus')<sup>12+</sup> 3807 3808off(type: 'lcdFlashStatus', callback?: AsyncCallback\<LcdFlashStatus\>): void 3809 3810Unsubscribes from LCD flash status change events. 3811 3812**System API**: This is a system API. 3813 3814**System capability**: SystemCapability.Multimedia.Camera.Core 3815 3816**Parameters** 3817 3818| Name | Type | Mandatory| Description | 3819| -------- | ------------------------ | ---- |------------------------------------------------------------------| 3820| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created. | 3821| 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.)| 3822 3823**Error codes** 3824 3825For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3826 3827| ID| Error Message | 3828|-------|---------------------------| 3829| 202 | Not System Application. | 3830 3831**Example** 3832 3833```ts 3834function unregisterLcdFlashStatus(photoSession: camera.PhotoSession): void { 3835 photoSession.off('lcdFlashStatus'); 3836} 3837``` 3838 3839## VideoSessionForSys<sup>11+</sup> 3840 3841VideoSessionForSys extends VideoSession, Beauty, ColorEffect, ColorManagement, Macro 3842 3843Implements 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). 3844 3845**System API**: This is a system API. 3846 3847**System capability**: SystemCapability.Multimedia.Camera.Core 3848 3849## VideoSession<sup>11+</sup> 3850 3851VideoSession extends Session, Flash, AutoExposure, Focus, Zoom, Stabilization, ColorManagement 3852 3853Implements 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). 3854 3855### on('macroStatusChanged')<sup>11+</sup> 3856 3857on(type: 'macroStatusChanged', callback: AsyncCallback\<boolean\>): void 3858 3859Subscribes to macro state change events. This API uses an asynchronous callback to return the result. 3860 3861**System API**: This is a system API. 3862 3863**System capability**: SystemCapability.Multimedia.Camera.Core 3864 3865**Parameters** 3866 3867| Name | Type | Mandatory| Description | 3868| -------- | ----------------------------------------- | ---- | ------------------------ | 3869| type | string | Yes | Event type. The value is fixed at **'macroStatusChanged'**. The event can be listened for when a session is created.| 3870| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the macro state change. | 3871 3872**Error codes** 3873 3874For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3875 3876| ID| Error Message | 3877|-------|---------------------------| 3878| 202 | Not System Application. | 3879 3880**Example** 3881 3882```ts 3883import { BusinessError } from '@kit.BasicServicesKit'; 3884 3885function callback(err: BusinessError, macroStatus: boolean): void { 3886 if (err !== undefined && err.code !== 0) { 3887 console.error(`Callback Error, errorCode: ${err.code}`); 3888 return; 3889 } 3890 console.info(`Macro state: ${macroStatus}`); 3891} 3892 3893function registerMacroStatusChanged(videoSession: camera.VideoSession): void { 3894 videoSession.on('macroStatusChanged', callback); 3895} 3896``` 3897 3898### off('macroStatusChanged')<sup>11+</sup> 3899 3900off(type: 'macroStatusChanged', callback?: AsyncCallback\<boolean\>): void 3901 3902Unsubscribes from macro state change events. 3903 3904**System API**: This is a system API. 3905 3906**System capability**: SystemCapability.Multimedia.Camera.Core 3907 3908**Parameters** 3909 3910| Name | Type | Mandatory| Description | 3911| -------- | ------------------------ | ---- | ------------------------ | 3912| type | string | Yes | Event type. The value is fixed at **'macroStatusChanged'**. The event can be listened for when a session is created.| 3913| 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.)| 3914 3915**Error codes** 3916 3917For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3918 3919| ID| Error Message | 3920|-------|---------------------------| 3921| 202 | Not System Application. | 3922 3923**Example** 3924 3925```ts 3926function unregisterMacroStatusChanged(videoSession: camera.VideoSession): void { 3927 videoSession.off('macroStatusChanged'); 3928} 3929``` 3930 3931### on('lcdFlashStatus')<sup>13+</sup> 3932 3933on(type: 'lcdFlashStatus', callback: AsyncCallback\<LcdFlashStatus\>): void 3934 3935Subscribes to LCD flash status change events. This API uses an asynchronous callback to return the result. 3936 3937**System API**: This is a system API. 3938 3939**System capability**: SystemCapability.Multimedia.Camera.Core 3940 3941**Parameters** 3942 3943| Name | Type | Mandatory| Description | 3944| -------- | ----------------------------------------- | ---- |------------------------------------------| 3945| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created.| 3946| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | Yes | Callback used to return the LCD flash status change. | 3947 3948**Error codes** 3949 3950For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3951 3952| ID| Error Message | 3953|-------|---------------------------| 3954| 202 | Not System Application. | 3955 3956**Example** 3957 3958```ts 3959import { BusinessError } from '@kit.BasicServicesKit'; 3960 3961function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 3962 if (err !== undefined && err.code !== 0) { 3963 console.error(`Callback Error, errorCode: ${err.code}`); 3964 return; 3965 } 3966 console.info(`isLcdFlashNeeded: ${lcdFlashStatus.isLcdFlashNeeded}`); 3967 console.info(`lcdCompensation: ${lcdFlashStatus.lcdCompensation}`); 3968} 3969 3970function registerLcdFlashStatus(videoSession: camera.VideoSession): void { 3971 videoSession.on('lcdFlashStatus', callback); 3972} 3973``` 3974 3975### off('lcdFlashStatus')<sup>12+</sup> 3976 3977off(type: 'lcdFlashStatus', callback?: AsyncCallback\<LcdFlashStatus\>): void 3978 3979Unsubscribes from LCD flash status change events. 3980 3981**System API**: This is a system API. 3982 3983**System capability**: SystemCapability.Multimedia.Camera.Core 3984 3985**Parameters** 3986 3987| Name | Type | Mandatory| Description | 3988| -------- | ------------------------ | ---- |------------------------------------------------------------------| 3989| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created. | 3990| 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.)| 3991 3992**Error codes** 3993 3994For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3995 3996| ID| Error Message | 3997|-------|---------------------------| 3998| 202 | Not System Application. | 3999 4000**Example** 4001 4002```ts 4003function unregisterLcdFlashStatus(videoSession: camera.VideoSession): void { 4004 videoSession.off('lcdFlashStatus'); 4005} 4006``` 4007 4008## PortraitPhotoSession<sup>11+</sup> 4009 4010PortraitPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, Beauty, ColorEffect, ColorManagement, Portrait, Aperture 4011 4012Implements 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). 4013 4014### on('error')<sup>11+</sup> 4015 4016on(type: 'error', callback: ErrorCallback): void 4017 4018Subscribes to **PortraitSession** error events. This API uses an asynchronous callback to return the result. 4019 4020**System API**: This is a system API. 4021 4022**System capability**: SystemCapability.Multimedia.Camera.Core 4023 4024**Parameters** 4025 4026| Name | Type | Mandatory| Description | 4027| -------- | --------------------------------- | ---- | ------------------------------ | 4028| 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).| 4029| 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). | 4030 4031**Example** 4032 4033```ts 4034import { BusinessError } from '@kit.BasicServicesKit'; 4035 4036function callback(err: BusinessError): void { 4037 console.error(`Portrait photo session error code: ${err.code}`); 4038} 4039 4040function registerSessionError(portraitPhotoSession: camera.PortraitPhotoSession): void { 4041 portraitPhotoSession.on('error', callback); 4042} 4043``` 4044 4045### off('error')<sup>11+</sup> 4046 4047off(type: 'error', callback?: ErrorCallback): void 4048 4049Unsubscribes from **PortraitSession** error events. 4050 4051**System API**: This is a system API. 4052 4053**System capability**: SystemCapability.Multimedia.Camera.Core 4054 4055**Parameters** 4056 4057| Name | Type | Mandatory| Description | 4058| -------- | -------------------------- | ---- | ------------------------------ | 4059| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 4060| 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.) | 4061 4062**Example** 4063 4064```ts 4065function unregisterSessionError(portraitPhotoSession: camera.PortraitPhotoSession): void { 4066 portraitPhotoSession.off('error'); 4067} 4068``` 4069 4070### on('focusStateChange')<sup>11+</sup> 4071 4072on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4073 4074Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 4075 4076**System API**: This is a system API. 4077 4078**System capability**: SystemCapability.Multimedia.Camera.Core 4079 4080**Parameters** 4081 4082| Name | Type | Mandatory| Description | 4083| -------- | ---------------- | ---- | ------------------------ | 4084| 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.| 4085| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 4086 4087**Example** 4088 4089```ts 4090import { BusinessError } from '@kit.BasicServicesKit'; 4091 4092function callback(err: BusinessError, focusState: camera.FocusState): void { 4093 if (err !== undefined && err.code !== 0) { 4094 console.error(`Callback Error, errorCode: ${err.code}`); 4095 return; 4096 } 4097 console.info(`Focus state: ${focusState}`); 4098} 4099 4100function registerFocusStateChange(portraitPhotoSession: camera.PortraitPhotoSession): void { 4101 portraitPhotoSession.on('focusStateChange', callback); 4102} 4103``` 4104 4105### off('focusStateChange')<sup>11+</sup> 4106 4107off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4108 4109Unsubscribes from focus state change events. 4110 4111**System API**: This is a system API. 4112 4113**System capability**: SystemCapability.Multimedia.Camera.Core 4114 4115**Parameters** 4116 4117| Name | Type | Mandatory| Description | 4118| -------- | ----------------------------------------- | ---- | ------------------------ | 4119| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 4120| 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.) | 4121 4122**Example** 4123 4124```ts 4125function unregisterFocusStateChange(portraitPhotoSession: camera.PortraitPhotoSession): void { 4126 portraitPhotoSession.off('focusStateChange'); 4127} 4128``` 4129 4130### on('smoothZoomInfoAvailable')<sup>11+</sup> 4131 4132on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 4133 4134Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 4135 4136**System API**: This is a system API. 4137 4138**System capability**: SystemCapability.Multimedia.Camera.Core 4139 4140**Parameters** 4141 4142| Name | Type | Mandatory| Description | 4143| -------- | ----------------------- | ---- | ------------------------ | 4144| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 4145| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 4146 4147**Example** 4148 4149```ts 4150import { BusinessError } from '@kit.BasicServicesKit'; 4151 4152function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 4153 if (err !== undefined && err.code !== 0) { 4154 console.error(`Callback Error, errorCode: ${err.code}`); 4155 return; 4156 } 4157 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 4158} 4159 4160function registerSmoothZoomInfo(portraitPhotoSession: camera.PortraitPhotoSession): void { 4161 portraitPhotoSession.on('smoothZoomInfoAvailable', callback); 4162} 4163``` 4164 4165### off('smoothZoomInfoAvailable')<sup>11+</sup> 4166 4167off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 4168 4169Unsubscribes from smooth zoom state change events. 4170 4171**System API**: This is a system API. 4172 4173**System capability**: SystemCapability.Multimedia.Camera.Core 4174 4175**Parameters** 4176 4177| Name | Type | Mandatory| Description | 4178| -------- | ----------------------------------------- | ---- | ------------------------ | 4179| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 4180| 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.) | 4181 4182**Example** 4183 4184```ts 4185function unregisterSmoothZoomInfo(portraitPhotoSession: camera.PortraitPhotoSession): void { 4186 portraitPhotoSession.off('smoothZoomInfoAvailable'); 4187} 4188``` 4189 4190### on('lcdFlashStatus')<sup>13+</sup> 4191 4192on(type: 'lcdFlashStatus', callback: AsyncCallback\<LcdFlashStatus\>): void 4193 4194Subscribes to LCD flash status change events. This API uses an asynchronous callback to return the result. 4195 4196**System API**: This is a system API. 4197 4198**System capability**: SystemCapability.Multimedia.Camera.Core 4199 4200**Parameters** 4201 4202| Name | Type | Mandatory| Description | 4203| -------- | ----------------------------------------- | ---- |------------------------------------------| 4204| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created.| 4205| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | Yes | Callback used to return the LCD flash status change. | 4206 4207**Error codes** 4208 4209For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4210 4211| ID| Error Message | 4212|-------|---------------------------| 4213| 202 | Not System Application. | 4214 4215**Example** 4216 4217```ts 4218import { BusinessError } from '@kit.BasicServicesKit'; 4219 4220function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 4221 if (err !== undefined && err.code !== 0) { 4222 console.error(`Callback Error, errorCode: ${err.code}`); 4223 return; 4224 } 4225 console.info(`isLcdFlashNeeded: ${lcdFlashStatus.isLcdFlashNeeded}`); 4226 console.info(`lcdCompensation: ${lcdFlashStatus.lcdCompensation}`); 4227} 4228 4229function registerLcdFlashStatus(portraitPhotoSession: camera.PortraitPhotoSession): void { 4230 portraitPhotoSession.on('lcdFlashStatus', callback); 4231} 4232``` 4233 4234### off('lcdFlashStatus')<sup>12+</sup> 4235 4236off(type: 'lcdFlashStatus', callback?: AsyncCallback\<LcdFlashStatus\>): void 4237 4238Unsubscribes from LCD flash status change events. 4239 4240**System API**: This is a system API. 4241 4242**System capability**: SystemCapability.Multimedia.Camera.Core 4243 4244**Parameters** 4245 4246| Name | Type | Mandatory| Description | 4247| -------- | ------------------------ | ---- |------------------------------------------------------------------| 4248| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created. | 4249| 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.)| 4250 4251**Error codes** 4252 4253For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4254 4255| ID| Error Message | 4256|-------|---------------------------| 4257| 202 | Not System Application. | 4258 4259**Example** 4260 4261```ts 4262function unregisterLcdFlashStatus(portraitPhotoSession: camera.PortraitPhotoSession): void { 4263 portraitPhotoSession.off('lcdFlashStatus'); 4264} 4265``` 4266 4267## NightPhotoSession<sup>11+</sup> 4268 4269NightPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ColorManagement, ManualExposure 4270 4271Implements 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). 4272 4273### on('error')<sup>11+</sup> 4274 4275on(type: 'error', callback: ErrorCallback): void 4276 4277Subscribes to **NightSession** error events. This API uses an asynchronous callback to return the result. 4278 4279**System API**: This is a system API. 4280 4281**System capability**: SystemCapability.Multimedia.Camera.Core 4282 4283**Parameters** 4284 4285| Name | Type | Mandatory| Description | 4286| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 4287| 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).| 4288| 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).| 4289 4290**Example** 4291 4292```ts 4293import { BusinessError } from '@kit.BasicServicesKit'; 4294 4295function callback(err: BusinessError): void { 4296 console.error(`Night photo session error code: ${err.code}`); 4297} 4298 4299function registerSessionError(nightPhotoSession: camera.NightPhotoSession): void { 4300 nightPhotoSession.on('error', callback); 4301} 4302``` 4303 4304### off('error')<sup>11+</sup> 4305 4306off(type: 'error', callback?: ErrorCallback): void 4307 4308Unsubscribes from **NightSession** 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**Example** 4322 4323```ts 4324function unregisterSessionError(nightPhotoSession: camera.NightPhotoSession): void { 4325 nightPhotoSession.off('error'); 4326} 4327``` 4328 4329### on('focusStateChange')<sup>11+</sup> 4330 4331on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4332 4333Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 4334 4335**System API**: This is a system API. 4336 4337**System capability**: SystemCapability.Multimedia.Camera.Core 4338 4339**Parameters** 4340 4341| Name | Type | Mandatory| Description | 4342| -------- | ---------------- | ---- | ------------------------ | 4343| 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.| 4344| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 4345 4346**Example** 4347 4348```ts 4349import { BusinessError } from '@kit.BasicServicesKit'; 4350 4351function callback(err: BusinessError, focusState: camera.FocusState): void { 4352 if (err !== undefined && err.code !== 0) { 4353 console.error(`Callback Error, errorCode: ${err.code}`); 4354 return; 4355 } 4356 console.info(`Focus state: ${focusState}`); 4357} 4358 4359function registerFocusStateChange(nightPhotoSession: camera.NightPhotoSession): void { 4360 nightPhotoSession.on('focusStateChange', callback); 4361} 4362``` 4363 4364### off('focusStateChange')<sup>11+</sup> 4365 4366off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4367 4368Unsubscribes from focus state change events. 4369 4370**System API**: This is a system API. 4371 4372**System capability**: SystemCapability.Multimedia.Camera.Core 4373 4374**Parameters** 4375 4376| Name | Type | Mandatory| Description | 4377| -------- | ----------------------------------------- | ---- | ------------------------ | 4378| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 4379| 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.) | 4380 4381**Example** 4382 4383```ts 4384function unregisterFocusStateChange(nightPhotoSession: camera.NightPhotoSession): void { 4385 nightPhotoSession.off('focusStateChange'); 4386} 4387``` 4388 4389### on('smoothZoomInfoAvailable')<sup>11+</sup> 4390 4391on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 4392 4393Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 4394 4395**System API**: This is a system API. 4396 4397**System capability**: SystemCapability.Multimedia.Camera.Core 4398 4399**Parameters** 4400 4401| Name | Type | Mandatory| Description | 4402| -------- | ----------------------- | ---- | ------------------------ | 4403| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 4404| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 4405 4406**Example** 4407 4408```ts 4409import { BusinessError } from '@kit.BasicServicesKit'; 4410 4411function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 4412 if (err !== undefined && err.code !== 0) { 4413 console.error(`Callback Error, errorCode: ${err.code}`); 4414 return; 4415 } 4416 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 4417} 4418 4419function registerSmoothZoomInfo(nightPhotoSession: camera.NightPhotoSession): void { 4420 nightPhotoSession.on('smoothZoomInfoAvailable', callback); 4421} 4422``` 4423 4424### off('smoothZoomInfoAvailable')<sup>11+</sup> 4425 4426off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 4427 4428Unsubscribes from smooth zoom state change events. 4429 4430**System API**: This is a system API. 4431 4432**System capability**: SystemCapability.Multimedia.Camera.Core 4433 4434**Parameters** 4435 4436| Name | Type | Mandatory| Description | 4437| -------- | ----------------------------------------- | ---- | ------------------------ | 4438| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 4439| 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.) | 4440 4441**Example** 4442 4443```ts 4444function unregisterSmoothZoomInfo(nightPhotoSession: camera.NightPhotoSession): void { 4445 nightPhotoSession.off('smoothZoomInfoAvailable'); 4446} 4447``` 4448 4449### on('lcdFlashStatus')<sup>12+</sup> 4450 4451on(type: 'lcdFlashStatus', callback: AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\>): void 4452 4453Subscribes to LCD flash status change events. This API uses an asynchronous callback to return the result. 4454 4455**System API**: This is a system API. 4456 4457**System capability**: SystemCapability.Multimedia.Camera.Core 4458 4459**Parameters** 4460 4461| Name | Type | Mandatory| Description | 4462| -------- | ----------------------- | ---- | ------------------------ | 4463| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created.| 4464| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | Yes | Callback used to return the LCD flash status change. | 4465 4466**Error codes** 4467 4468For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4469 4470| ID| Error Message | 4471|-------|---------------------------| 4472| 202 | Not System Application. | 4473 4474**Example** 4475 4476```ts 4477import { BusinessError } from '@kit.BasicServicesKit'; 4478 4479function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 4480 if (err !== undefined && err.code !== 0) { 4481 console.error(`Callback Error, errorCode: ${err.code}`); 4482 return; 4483 } 4484 console.info(`lcdFlashStatus: ${lcdFlashStatus}`); 4485} 4486 4487function registerLcdFlashStatus(nightPhotoSession: camera.NightPhotoSession): void { 4488 nightPhotoSession.on('lcdFlashStatus', callback); 4489} 4490``` 4491 4492### off('lcdFlashStatus')<sup>12+</sup> 4493 4494off(type: 'lcdFlashStatus', callback?: AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\>): void 4495 4496Unsubscribes from LCD flash status change events. 4497 4498**System API**: This is a system API. 4499 4500**System capability**: SystemCapability.Multimedia.Camera.Core 4501 4502**Parameters** 4503 4504| Name | Type | Mandatory| Description | 4505| -------- | ----------------------------------------- | ---- | ------------------------ | 4506| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created.| 4507| 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.) | 4508 4509**Error codes** 4510 4511For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4512 4513| ID| Error Message | 4514|-------|---------------------------| 4515| 202 | Not System Application. | 4516 4517**Example** 4518 4519```ts 4520function unregisterLcdFlashStatus(nightPhotoSession: camera.NightPhotoSession): void { 4521 nightPhotoSession.off('lcdFlashStatus'); 4522} 4523``` 4524 4525## HighResolutionPhotoSession<sup>12+</sup> 4526 4527HighResolutionPhotoSession extends Session, AutoExposure, Focus 4528 4529Implements 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). 4530 4531### on('error')<sup>12+</sup> 4532 4533on(type: 'error', callback: ErrorCallback): void 4534 4535Subscribes to **HighResolutionPhotoSession** error events. This API uses an asynchronous callback to return the result. 4536 4537**System API**: This is a system API. 4538 4539**System capability**: SystemCapability.Multimedia.Camera.Core 4540 4541**Parameters** 4542 4543| Name | Type | Mandatory| Description | 4544| -------- | --------------------------------- | ---- | ------------------------------ | 4545| 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).| 4546| 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). | 4547 4548**Error codes** 4549 4550For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4551 4552| ID | Error Message | 4553| --------------- | --------------- | 4554| 202 | Not System Application. | 4555 4556**Example** 4557 4558```ts 4559import { BusinessError } from '@kit.BasicServicesKit'; 4560 4561function callback(err: BusinessError): void { 4562 console.error(`High resolution photo session error code: ${err.code}`); 4563} 4564 4565function registerSessionError(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4566 highResolutionPhotoSession.on('error', callback); 4567} 4568``` 4569### off('error')<sup>12+</sup> 4570 4571off(type: 'error', callback?: ErrorCallback): void 4572 4573Unsubscribes from **HighResolutionPhotoSession** error events. 4574 4575**System API**: This is a system API. 4576 4577**System capability**: SystemCapability.Multimedia.Camera.Core 4578 4579**Parameters** 4580 4581| Name | Type | Mandatory| Description | 4582| -------- | ------------------------ | ---- | ------------------------------ | 4583| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 4584| 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.) | 4585 4586**Error codes** 4587 4588For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4589 4590| ID | Error Message | 4591| --------------- | --------------- | 4592| 202 | Not System Application. | 4593 4594**Example** 4595 4596```ts 4597function unregisterSessionError(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4598 highResolutionPhotoSession.off('error'); 4599} 4600``` 4601 4602### on('focusStateChange')<sup>12+</sup> 4603 4604on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4605 4606Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 4607 4608**System API**: This is a system API. 4609 4610**System capability**: SystemCapability.Multimedia.Camera.Core 4611 4612**Parameters** 4613 4614| Name | Type | Mandatory| Description | 4615| -------- | ---------------- | ---- | ------------------------ | 4616| 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.| 4617| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 4618 4619**Error codes** 4620 4621For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4622 4623| ID | Error Message | 4624| --------------- | --------------- | 4625| 202 | Not System Application. | 4626 4627**Example** 4628 4629```ts 4630import { BusinessError } from '@kit.BasicServicesKit'; 4631 4632function callback(err: BusinessError, focusState: camera.FocusState): void { 4633 if (err !== undefined && err.code !== 0) { 4634 console.error(`Callback Error, errorCode: ${err.code}`); 4635 return; 4636 } 4637 console.info(`Focus state: ${focusState}`); 4638} 4639 4640function registerFocusStateChange(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4641 highResolutionPhotoSession.on('focusStateChange', callback); 4642} 4643``` 4644 4645### off('focusStateChange')<sup>12+</sup> 4646 4647off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4648 4649Unsubscribes from focus state change events. 4650 4651**System API**: This is a system API. 4652 4653**System capability**: SystemCapability.Multimedia.Camera.Core 4654 4655**Error codes** 4656 4657For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4658 4659| ID | Error Message | 4660| --------------- | --------------- | 4661| 202 | Not System Application. | 4662 4663**Parameters** 4664 4665| Name | Type | Mandatory| Description | 4666| -------- | ----------------------------------------- | ---- | ------------------------ | 4667| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 4668| 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.) | 4669 4670**Example** 4671 4672```ts 4673function unregisterFocusStateChange(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4674 highResolutionPhotoSession.off('focusStateChange'); 4675} 4676``` 4677 4678## SketchStatusData<sup>11+</sup> 4679 4680Defines the PiP status data. 4681 4682**System API**: This is a system API. 4683 4684**System capability**: SystemCapability.Multimedia.Camera.Core 4685 4686| Name | Type | Read-only| Mandatory| Description | 4687| ------------- | -------- | ---- | ---- | ---------- | 4688| status | number | No | Yes | Status of PiP. The options are 0 (stopped), 1 (started), 2 (stopping), and 3 (starting).| 4689| sketchRatio | number | No | Yes | Zoom ratio of PiP.| 4690 4691## SlowMotionVideoSession<sup>12+</sup> 4692 4693SlowMotionVideoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect 4694 4695Implements 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). 4696 4697> **NOTE** 4698> 4699> In slow-motion video mode, only preview streams and video streams can be added. 4700### on('error')<sup>12+</sup> 4701 4702on(type: 'error', callback: ErrorCallback): void 4703 4704Subscribes to **SlowMotionVideoSession** error events. This API uses an asynchronous callback to return the result. 4705 4706**System API**: This is a system API. 4707 4708**System capability**: SystemCapability.Multimedia.Camera.Core 4709 4710**Parameters** 4711 4712| Name | Type | Mandatory| Description | 4713| -------- | --------------------------------- | ---- | ------------------------------ | 4714| 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).| 4715| 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). | 4716 4717**Error codes** 4718 4719For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4720 4721| ID | Error Message | 4722|---------| --------------- | 4723| 202 | Not System Application. | 4724 4725**Example** 4726 4727```ts 4728import { BusinessError } from '@kit.BasicServicesKit'; 4729 4730function callback(err: BusinessError): void { 4731 console.error(`Portrait photo session error code: ${err.code}`); 4732} 4733 4734function registerSessionError(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4735 slowMotionVideoSession.on('error', callback); 4736} 4737``` 4738 4739### off('error')<sup>12+</sup> 4740 4741off(type: 'error', callback?: ErrorCallback): void 4742 4743Unsubscribes from **SlowMotionVideoSession** error events. 4744 4745**System API**: This is a system API. 4746 4747**System capability**: SystemCapability.Multimedia.Camera.Core 4748 4749**Parameters** 4750 4751| Name | Type | Mandatory| Description | 4752| -------- | -------------------------- | ---- | ------------------------------ | 4753| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 4754| 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.) | 4755 4756**Error codes** 4757 4758For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4759 4760| ID | Error Message | 4761|---------| --------------- | 4762| 202 | Not System Application. | 4763 4764**Example** 4765 4766```ts 4767function unregisterSessionError(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4768 slowMotionVideoSession.off('error'); 4769} 4770``` 4771 4772### on('focusStateChange')<sup>12+</sup> 4773 4774on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4775 4776Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 4777 4778**System API**: This is a system API. 4779 4780**System capability**: SystemCapability.Multimedia.Camera.Core 4781 4782**Parameters** 4783 4784| Name | Type | Mandatory| Description | 4785| -------- | ---------------- | ---- | ------------------------ | 4786| 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.| 4787| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 4788 4789**Error codes** 4790 4791For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4792 4793| ID | Error Message | 4794|---------| --------------- | 4795| 202 | Not System Application. | 4796 4797**Example** 4798 4799```ts 4800import { BusinessError } from '@kit.BasicServicesKit'; 4801 4802function callback(err: BusinessError, focusState: camera.FocusState): void { 4803 if (err !== undefined && err.code !== 0) { 4804 console.error(`Callback Error, errorCode: ${err.code}`); 4805 return; 4806 } 4807 console.info(`Focus state: ${focusState}`); 4808} 4809 4810function registerFocusStateChange(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4811 slowMotionVideoSession.on('focusStateChange', callback); 4812} 4813``` 4814 4815### off('focusStateChange')<sup>12+</sup> 4816 4817off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4818 4819Unsubscribes from focus state change events. 4820 4821**System API**: This is a system API. 4822 4823**System capability**: SystemCapability.Multimedia.Camera.Core 4824 4825**Parameters** 4826 4827| Name | Type | Mandatory| Description | 4828| -------- | ----------------------------------------- | ---- | ------------------------ | 4829| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 4830| 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.) | 4831 4832**Error codes** 4833 4834For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4835 4836| ID | Error Message | 4837|---------| --------------- | 4838| 202 | Not System Application. | 4839 4840**Example** 4841 4842```ts 4843function unregisterFocusStateChange(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4844 slowMotionVideoSession.off('focusStateChange'); 4845} 4846``` 4847 4848### on('smoothZoomInfoAvailable')<sup>12+</sup> 4849 4850on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 4851 4852Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 4853 4854**System API**: This is a system API. 4855 4856**System capability**: SystemCapability.Multimedia.Camera.Core 4857 4858**Parameters** 4859 4860| Name | Type | Mandatory| Description | 4861| -------- | ----------------------- | ---- | ------------------------ | 4862| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 4863| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 4864 4865**Error codes** 4866 4867For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4868 4869| ID | Error Message | 4870|---------| --------------- | 4871| 202 | Not System Application. | 4872 4873**Example** 4874 4875```ts 4876import { BusinessError } from '@kit.BasicServicesKit'; 4877 4878function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 4879 if (err !== undefined && err.code !== 0) { 4880 console.error(`Callback Error, errorCode: ${err.code}`); 4881 return; 4882 } 4883 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 4884} 4885 4886function registerSmoothZoomInfo(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4887 slowMotionVideoSession.on('smoothZoomInfoAvailable', callback); 4888} 4889``` 4890 4891### off('smoothZoomInfoAvailable')<sup>12+</sup> 4892 4893off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 4894 4895Unsubscribes from smooth zoom state change events. 4896 4897**System API**: This is a system API. 4898 4899**System capability**: SystemCapability.Multimedia.Camera.Core 4900 4901**Parameters** 4902 4903| Name | Type | Mandatory| Description | 4904| -------- | ----------------------------------------- | ---- | ------------------------ | 4905| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 4906| 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.) | 4907 4908**Error codes** 4909 4910For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4911 4912| ID | Error Message | 4913|---------| --------------- | 4914| 202 | Not System Application. | 4915 4916**Example** 4917 4918```ts 4919function unregisterSmoothZoomInfo(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4920 slowMotionVideoSession.off('smoothZoomInfoAvailable'); 4921} 4922``` 4923 4924### on('slowMotionStatus')<sup>12+</sup> 4925 4926on(type: 'slowMotionStatus', callback: AsyncCallback\<SlowMotionStatus\>): void 4927 4928Subscribes to slow-motion status change events. This API uses an asynchronous callback to return the result. 4929 4930**System API**: This is a system API. 4931 4932**System capability**: SystemCapability.Multimedia.Camera.Core 4933 4934**Parameters** 4935 4936| Name | Type | Mandatory| Description | 4937| -------- |---------------------------------------------------------------------------| ---- |--------------------------------------------| 4938| type | string | Yes | Event type. The value is fixed at **'slowMotionStatus'**. The event can be listened for when a session is created.| 4939| callback | AsyncCallback\<[SlowMotionStatus](#slowmotionstatus12)\> | Yes | Callback used to return the slow-motion status change. | 4940 4941**Error codes** 4942 4943For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4944 4945| ID | Error Message | 4946|---------| --------------- | 4947| 202 | Not System Application. | 4948 4949**Example** 4950 4951```ts 4952import { BusinessError } from '@kit.BasicServicesKit'; 4953 4954function callback(err: BusinessError, slowMotionStatus: camera.SlowMotionStatus): void { 4955 if (err !== undefined && err.code !== 0) { 4956 console.error(`Callback Error, errorCode: ${err.code}`); 4957 return; 4958 } 4959 console.info(`The slow motion status: ${slowMotionStatus}`); 4960} 4961 4962function registerSlowMotionStatus(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4963 slowMotionVideoSession.on('slowMotionStatus', callback); 4964} 4965``` 4966 4967### off('slowMotionStatus')<sup>12+</sup> 4968 4969off(type: 'slowMotionStatus', callback?: AsyncCallback\<SlowMotionStatus\>): void 4970 4971Unsubscribes from slow-motion status change events. 4972 4973**System API**: This is a system API. 4974 4975**System capability**: SystemCapability.Multimedia.Camera.Core 4976 4977**Parameters** 4978 4979| Name | Type | Mandatory| Description | 4980| -------- | ----------------------------------------- | ---- | ------------------------ | 4981| type | string | Yes | Event type. The value is fixed at **'slowMotionStatus'**. The event can be listened for when a session is created.| 4982| 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. | 4983 4984**Error codes** 4985 4986For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4987 4988| ID | Error Message | 4989|---------| --------------- | 4990| 202 | Not System Application. | 4991 4992**Example** 4993 4994```ts 4995function unregisterSlowMotionStatus(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4996 slowMotionVideoSession.off('slowMotionStatus'); 4997} 4998``` 4999### isSlowMotionDetectionSupported<sup>12+</sup> 5000 5001isSlowMotionDetectionSupported(): boolean 5002 5003Checks whether the device supports slow-motion detection. 5004 5005> **NOTE** 5006> 5007> This API must be called after [commitConfig](js-apis-camera.md#commitconfig11-1) is called. 5008 5009**System API**: This is a system API. 5010 5011**System capability**: SystemCapability.Multimedia.Camera.Core 5012 5013**Return value** 5014 5015| Type | Description | 5016| ---------- |----------------------------------------------------------------------------------------| 5017| 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.| 5018 5019**Error codes** 5020 5021For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5022 5023| ID | Error Message | 5024|---------| --------------- | 5025| 202 | Not System Application. | 5026| 7400103 | Session not config. | 5027 5028**Example** 5029 5030```ts 5031import { BusinessError } from '@kit.BasicServicesKit'; 5032 5033function isSlowMotionDetectionSupported(slowMotionVideoSession: camera.SlowMotionVideoSession): boolean { 5034 let isSupported: boolean = false; 5035 try { 5036 isSupported = slowMotionVideoSession.isSlowMotionDetectionSupported(); 5037 } catch (error) { 5038 // If the operation fails, error.code is returned and processed. 5039 let err = error as BusinessError; 5040 console.error(`The isFocusModeSupported call failed. error code: ${err.code}`); 5041 } 5042 return isSupported; 5043} 5044``` 5045 5046### setSlowMotionDetectionArea<sup>12+</sup> 5047 5048setSlowMotionDetectionArea(area: Rect): void 5049 5050Sets an area for slow-motion detection. 5051 5052> **NOTE** 5053> 5054> Before the setting, call [isSlowMotionDetectionSupported](#isslowmotiondetectionsupported12) to check whether the device supports slow-motion detection. 5055This API must be called after [commitConfig](js-apis-camera.md#commitconfig11-1) is called. 5056 5057**System API**: This is a system API. 5058 5059**System capability**: SystemCapability.Multimedia.Camera.Core 5060 5061**Parameters** 5062 5063| Name | Type | Mandatory| Description | 5064| -------- | ---------------------------------------------- | ---- | --------------------------- | 5065| area | [Rect](js-apis-camera.md#rect) | Yes | Area. | 5066 5067**Error codes** 5068 5069For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5070 5071| ID | Error Message | 5072|---------| --------------- | 5073| 202 | Not System Application. | 5074| 7400101 | Parameter missing or parameter type incorrect. | 5075| 7400103 | Session not config. | 5076 5077**Example** 5078 5079```ts 5080import { BusinessError } from '@kit.BasicServicesKit'; 5081 5082function setSlowMotionDetectionArea(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 5083 try { 5084 slowMotionVideoSession.setSlowMotionDetectionArea({topLeftX: 0.1, topLeftY: 0.1, width: 0.8, height: 0.8}); 5085 } catch (error) { 5086 // If the operation fails, error.code is returned and processed. 5087 let err = error as BusinessError; 5088 console.error(`The setSlowMotionDetectionArea call failed. error code: ${err.code}`); 5089 } 5090} 5091``` 5092 5093## PanoramaPhotoSession<sup>12+</sup> 5094 5095PanoramaPhotoSession extends Session, Focus, AutoExposure, WhiteBalance, ColorEffect 5096 5097Implements 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). 5098 5099### on('error')<sup>12+</sup> 5100 5101on(type: 'error', callback: ErrorCallback): void 5102 5103Subscribes to **PanoramaPhotoSession** error events. This API uses an asynchronous callback to return the result. 5104 5105**System API**: This is a system API. 5106 5107**System capability**: SystemCapability.Multimedia.Camera.Core 5108 5109**Parameters** 5110 5111| Name | Type | Mandatory| Description | 5112| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 5113| 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).| 5114| 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).| 5115 5116**Example** 5117 5118```ts 5119import { BusinessError } from '@kit.BasicServicesKit'; 5120 5121function callback(err: BusinessError): void { 5122 console.error(`Panorama photo session error code: ${err.code}`); 5123} 5124 5125function registerSessionError(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5126 panoramaPhotoSession.on('error', callback); 5127} 5128``` 5129 5130### off('error')<sup>11+</sup> 5131 5132off(type: 'error', callback?: ErrorCallback): void 5133 5134Unsubscribes from **PanoramaPhotoSession** error events. 5135 5136**System API**: This is a system API. 5137 5138**System capability**: SystemCapability.Multimedia.Camera.Core 5139 5140**Parameters** 5141 5142| Name | Type | Mandatory| Description | 5143| -------- | ------------------------ | ---- | ------------------------------ | 5144| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 5145| 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.) | 5146 5147**Example** 5148 5149```ts 5150function unregisterSessionError(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5151 panoramaPhotoSession.off('error'); 5152} 5153``` 5154 5155### on('focusStateChange')<sup>11+</sup> 5156 5157on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 5158 5159Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 5160 5161**System API**: This is a system API. 5162 5163**System capability**: SystemCapability.Multimedia.Camera.Core 5164 5165**Parameters** 5166 5167| Name | Type | Mandatory| Description | 5168| -------- | ---------------- | ---- | ------------------------ | 5169| 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.| 5170| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 5171 5172**Example** 5173 5174```ts 5175import { BusinessError } from '@kit.BasicServicesKit'; 5176 5177function callback(err: BusinessError, focusState: camera.FocusState): void { 5178 if (err !== undefined && err.code !== 0) { 5179 console.error(`Callback Error, errorCode: ${err.code}`); 5180 return; 5181 } 5182 console.info(`Focus state: ${focusState}`); 5183} 5184 5185function registerFocusStateChange(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5186 panoramaPhotoSession.on('focusStateChange', callback); 5187} 5188``` 5189 5190### off('focusStateChange')<sup>11+</sup> 5191 5192off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 5193 5194Unsubscribes from focus state change events. 5195 5196**System API**: This is a system API. 5197 5198**System capability**: SystemCapability.Multimedia.Camera.Core 5199 5200**Parameters** 5201 5202| Name | Type | Mandatory| Description | 5203| -------- | ----------------------------------------- | ---- | ------------------------ | 5204| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 5205| 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.) | 5206 5207**Example** 5208 5209```ts 5210function unregisterFocusStateChange(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5211 panoramaPhotoSession.off('focusStateChange'); 5212} 5213``` 5214 5215## IsoInfo<sup>12+</sup> 5216 5217Describes the ISO information. 5218 5219**System API**: This is a system API. 5220 5221**System capability**: SystemCapability.Multimedia.Camera.Core 5222 5223| Name| Type | Read-only| Optional| Description | 5224| ---- | ------- | ---- |--| -------------- | 5225| iso | number | Yes | Yes| ISO. | 5226 5227--- 5228 5229## ExposureInfo<sup>12+</sup> 5230 5231Describes the exposure information. 5232 5233**System API**: This is a system API. 5234 5235**System capability**: SystemCapability.Multimedia.Camera.Core 5236 5237| Name | Type | Read-only| Optional | Description | 5238| ----------------- | ------- | ---- |-----| ------------------ | 5239| exposureTime | number | Yes | Yes | Exposure time, in ms.| 5240 5241--- 5242 5243## ApertureInfo<sup>12+</sup> 5244 5245Describes the aperture information. 5246 5247**System API**: This is a system API. 5248 5249**System capability**: SystemCapability.Multimedia.Camera.Core 5250 5251| Name | Type | Read-only| Optional | Description | 5252| --------- | ------- | ---- |-----| ---------- | 5253| aperture | number | Yes | Yes | Aperture. | 5254 5255--- 5256 5257## LuminationInfo<sup>12+</sup> 5258 5259Describes the illumination information. 5260 5261**System API**: This is a system API. 5262 5263**System capability**: SystemCapability.Multimedia.Camera.Core 5264 5265| Name | Type | Read-only| Optional | Description | 5266| ----------- | ------- | ---- |-----| ---------- | 5267| lumination | number | Yes | Yes | Illumination. The value range is [0,1].| 5268 5269## CameraFormat 5270 5271Enumerates the camera output formats. 5272 5273**System capability**: SystemCapability.Multimedia.Camera.Core 5274 5275| Name | Value | Description | 5276| ----------------------- | --------- | ------------ | 5277| CAMERA_FORMAT_DNG<sup>12+</sup> | 4 | Raw image in DNG format. **System API**: This is a system API. | 5278 5279## ExposureMeteringMode<sup>12+</sup> 5280 5281Enumerates the exposure metering modes. 5282 5283**System API**: This is a system API. 5284 5285**System capability**: SystemCapability.Multimedia.Camera.Core 5286 5287| Name | Value | Description | 5288| ----------------------------- | ---- | ----------- | 5289| MATRIX | 0 | Performs metering on a wide area of the image.| 5290| CENTER | 1 | Performs metering on the entire image, with the center allocated with the maximum weight.| 5291| SPOT | 2 | Performs metering around 2.5% of the metering points.| 5292 5293## AutoExposureQuery<sup>12+</sup> 5294 5295Provides APIs to check whether a device supports an exposure mode or exposure metering mode and obtain the exposure compensation range. 5296 5297### isExposureMeteringModeSupported<sup>12+</sup> 5298 5299isExposureMeteringModeSupported(aeMeteringMode: ExposureMeteringMode): boolean 5300 5301Checks whether an exposure metering mode is supported. 5302 5303**System API**: This is a system API. 5304 5305**System capability**: SystemCapability.Multimedia.Camera.Core 5306 5307**Parameters** 5308 5309| Name | Type | Mandatory | Description | 5310| -------- | -------------------------------| ---- | ----------------------------- | 5311| aeMeteringMode | [ExposureMeteringMode](#exposuremeteringmode12) | Yes | Metering mode. | 5312 5313**Return value** 5314 5315| Type | Description | 5316| ---------- | ----------------------------- | 5317| 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.| 5318 5319**Error codes** 5320 5321For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5322 5323| ID | Error Message | 5324| --------------- | --------------- | 5325| 202 | Not System Application. | 5326| 7400101 | Parameter missing or parameter type incorrect. | 5327| 7400103 | Session not config. | 5328 5329 5330**Example** 5331 5332```ts 5333import { BusinessError } from '@kit.BasicServicesKit'; 5334 5335function isExposureMeteringModeSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5336 let isSupported: boolean = false; 5337 try { 5338 isSupported = professionalPhotoSession.isExposureModeSupported(camera.ExposureMeteringMode.CENTER); 5339 } catch (error) { 5340 // If the operation fails, error.code is returned and processed. 5341 let err = error as BusinessError; 5342 console.error(`The isExposureMeteringModeSupported call failed. error code: ${err.code}`); 5343 } 5344 return isSupported; 5345} 5346``` 5347 5348## AutoExposure 5349 5350AutoExposure extends [AutoExposureQuery](#autoexposurequery12) 5351 5352Provides 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. 5353 5354### getExposureMeteringMode<sup>12+</sup> 5355 5356getExposureMeteringMode(): ExposureMeteringMode 5357 5358Obtains the exposure metering mode in use. 5359 5360**System API**: This is a system API. 5361 5362**System capability**: SystemCapability.Multimedia.Camera.Core 5363 5364**Return value** 5365 5366| Type | Description | 5367| ---------- | ----------------------------- | 5368| [ExposureMeteringMode](#exposuremeteringmode12) | Exposure metering mode obtained. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 5369 5370**Error codes** 5371 5372For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5373 5374| ID | Error Message | 5375| --------------- | --------------- | 5376| 7400103 | Session not config. | 5377| 202 | Not System Application. | 5378 5379**Example** 5380 5381```ts 5382import { BusinessError } from '@kit.BasicServicesKit'; 5383 5384function getExposureMeteringMode(professionalPhotoSession: camera.ProfessionalPhotoSession): camera.ExposureMeteringMode | undefined { 5385 let exposureMeteringMode: camera.ExposureMeteringMode | undefined = undefined; 5386 try { 5387 exposureMeteringMode = professionalPhotoSession.getExposureMeteringMode(); 5388 } catch (error) { 5389 // If the operation fails, error.code is returned and processed. 5390 let err = error as BusinessError; 5391 console.error(`The getExposureMeteringMode call failed. error code: ${err.code}`); 5392 } 5393 return exposureMeteringMode; 5394} 5395``` 5396 5397### setExposureMeteringMode<sup>12+</sup> 5398 5399setExposureMeteringMode(aeMeteringMode: ExposureMeteringMode): void 5400 5401Sets an exposure metering mode. 5402 5403Before the setting, call [isExposureMeteringModeSupported](#isexposuremeteringmodesupported12) to check whether the target exposure metering mode is supported. 5404 5405**System API**: This is a system API. 5406 5407**System capability**: SystemCapability.Multimedia.Camera.Core 5408 5409**Parameters** 5410 5411| Name | Type | Mandatory| Description | 5412| -------- | -------------------------------| ---- | ----------------------- | 5413| aeMeteringMode | [ExposureMeteringMode](#exposuremeteringmode12) | Yes | Metering mode. | 5414 5415**Error codes** 5416 5417For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5418 5419| ID | Error Message | 5420| --------------- | --------------- | 5421| 202 | Not System Application. | 5422| 7400101 | Parameter missing or parameter type incorrect. | 5423| 7400103 | Session not config. | 5424 5425**Example** 5426 5427```ts 5428import { BusinessError } from '@kit.BasicServicesKit'; 5429 5430function setExposureMeteringMode(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5431 try { 5432 professionalPhotoSession.setExposureMeteringMode(camera.ExposureMeteringMode.CENTER); 5433 } catch (error) { 5434 // If the operation fails, error.code is returned and processed. 5435 let err = error as BusinessError; 5436 console.error(`The setExposureMeteringMode call failed. error code: ${err.code}`); 5437 } 5438} 5439``` 5440 5441## FocusQuery<sup>12+</sup> 5442 5443Provides the API to check whether the focus assist is supported. 5444 5445### isFocusAssistSupported<sup>12+</sup> 5446 5447isFocusAssistSupported(): boolean 5448 5449Checks whether the focus assist is supported. 5450 5451**System API**: This is a system API. 5452 5453**System capability**: SystemCapability.Multimedia.Camera.Core 5454 5455**Return value** 5456 5457| Type | Description | 5458| ---------- | ----------------------------- | 5459| 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.| 5460 5461**Error codes** 5462 5463For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5464 5465| ID | Error Message | 5466| --------------- | --------------- | 5467| 7400103 | Session not config. | 5468| 202 | Not System Application. | 5469 5470**Example** 5471 5472```ts 5473import { BusinessError } from '@kit.BasicServicesKit'; 5474 5475function isFocusAssistSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5476 let status: boolean = false; 5477 try { 5478 status = professionalPhotoSession.isFocusAssistSupported(); 5479 } catch (error) { 5480 // If the operation fails, error.code is returned and processed. 5481 let err = error as BusinessError; 5482 console.error(`The isFocusAssistSupported call failed. error code: ${err.code}`); 5483 } 5484 return status; 5485} 5486``` 5487 5488## Focus 5489 5490Focus extends [FocusQuery](#focusquery12) 5491 5492Provides APIs to obtain and set the camera focus mode and focus position. 5493 5494### setFocusAssist<sup>12+</sup> 5495 5496setFocusAssist(enabled: boolean): void 5497 5498Sets the focus assist. 5499 5500Before the setting, call [isFocusAssistSupported](#isfocusassistsupported12) to check whether the device supports the focus assist. 5501 5502**System API**: This is a system API. 5503 5504**System capability**: SystemCapability.Multimedia.Camera.Core 5505 5506**Parameters** 5507 5508| Name | Type | Mandatory| Description | 5509| -------- | ----------------------- | ---- | ------------------- | 5510| enabled | boolean | Yes | **true**: Enables the focus assist.<br>**false**: Disables the focus assist.| 5511 5512**Error codes** 5513 5514For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5515 5516| ID | Error Message | 5517| --------------- | --------------- | 5518| 202 | Not System Application. | 5519| 7400101 | Parameter missing or parameter type incorrect. | 5520| 7400103 | Session not config. | 5521 5522 5523**Example** 5524 5525```ts 5526import { BusinessError } from '@kit.BasicServicesKit'; 5527 5528function setFocusAssist(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5529 try { 5530 professionalPhotoSession.setFocusAssist(false); 5531 } catch (error) { 5532 // If the operation fails, error.code is returned and processed. 5533 let err = error as BusinessError; 5534 console.error(`The setFocusAssist call failed. error code: ${err.code}`); 5535 } 5536} 5537``` 5538 5539### getFocusAssist<sup>12+</sup> 5540 5541getFocusAssist(): boolean 5542 5543Checks whether the focus assist is enabled. 5544 5545**System API**: This is a system API. 5546 5547**System capability**: SystemCapability.Multimedia.Camera.Core 5548 5549**Return value** 5550 5551| Type | Description | 5552| ---------- | ----------------------------- | 5553| boolean | **true**: The focus assist is enabled.<br>**false**: The focus assist is disabled.| 5554 5555**Error codes** 5556 5557For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5558 5559| ID | Error Message | 5560| --------------- | --------------- | 5561| 7400103 | Session not config. | 5562| 202 | Not System Application. | 5563 5564**Example** 5565 5566```ts 5567import { BusinessError } from '@kit.BasicServicesKit'; 5568 5569function getFocusAssist(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5570 let isFocusAssistOpened: boolean; 5571 try { 5572 isFocusAssistOpened = professionalPhotoSession.getFocusAssist(); 5573 } catch (error) { 5574 // If the operation fails, error.code is returned and processed. 5575 let err = error as BusinessError; 5576 console.error(`The getFocusAssist call failed. error code: ${err.code}`); 5577 } 5578 return isFocusAssistOpened; 5579} 5580``` 5581 5582## ManualFocus<sup>12+</sup> 5583 5584Provides APIs related to manual focus operations. 5585 5586### setFocusDistance<sup>12+</sup> 5587 5588setFocusDistance(distance: number): void 5589 5590Sets the manual focus distance. 5591 5592**System API**: This is a system API. 5593 5594**System capability**: SystemCapability.Multimedia.Camera.Core 5595 5596**Parameters** 5597 5598| Name | Type | Mandatory| Description | 5599| -------- | ----------------------- | ---- | ------------------- | 5600| 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> | 5601 5602**Error codes** 5603 5604For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5605 5606| ID | Error Message | 5607| --------------- | --------------- | 5608| 202 | Not System Application. | 5609| 7400101 | Parameter missing or parameter type incorrect. | 5610| 7400103 | Session not config. | 5611 5612**Example** 5613 5614```ts 5615import { BusinessError } from '@kit.BasicServicesKit'; 5616 5617function setFocusDistance(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5618 try { 5619 let distance: number = 0.5; 5620 professionalPhotoSession.setFocusDistance(distance); 5621 } catch (error) { 5622 // If the operation fails, error.code is returned and processed. 5623 let err = error as BusinessError; 5624 console.error(`The setFocusDistance call failed. error code: ${err.code}`); 5625 } 5626} 5627``` 5628 5629### getFocusDistance<sup>12+</sup> 5630 5631getFocusDistance(): number 5632 5633Obtains the focus distance in use. 5634 5635**System API**: This is a system API. 5636 5637**System capability**: SystemCapability.Multimedia.Camera.Core 5638 5639**Return value** 5640 5641| Type | Description | 5642| ---------- | ----------------------------- | 5643| number | Normalized value of the focus distance.| 5644 5645**Error codes** 5646 5647For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5648 5649| ID | Error Message | 5650| --------------- | --------------- | 5651| 7400103 | Session not config. | 5652| 202 | Not System Application. | 5653 5654**Example** 5655 5656```ts 5657import { BusinessError } from '@kit.BasicServicesKit'; 5658 5659function getFocusDistance(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 5660 let distance: number = 0; 5661 try { 5662 distance = professionalPhotoSession.getFocusDistance(); 5663 } catch (error) { 5664 // If the operation fails, error.code is returned and processed. 5665 let err = error as BusinessError; 5666 console.error(`The getFocusDistance call failed. error code: ${err.code}`); 5667 } 5668 return distance; 5669} 5670``` 5671 5672## ManualIsoQuery<sup>12+</sup> 5673 5674Provides APIs to check whether a camera device supports manual ISO setting and obtain the ISO range supported by the device. 5675 5676### isManualIsoSupported<sup>12+</sup> 5677 5678isManualIsoSupported(): boolean 5679 5680Checks whether manual ISO setting is supported. 5681 5682**System API**: This is a system API. 5683 5684**System capability**: SystemCapability.Multimedia.Camera.Core 5685 5686**Return value** 5687 5688| Type | Description | 5689| ---------- | ----------------------------- | 5690| 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.| 5691 5692**Error codes** 5693 5694For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5695 5696| ID | Error Message | 5697| --------------- | --------------- | 5698| 7400103 | Session not config. | 5699| 202 | Not System Application. | 5700 5701**Example** 5702 5703```ts 5704import { BusinessError } from '@kit.BasicServicesKit'; 5705 5706function isManualIsoSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5707 let status: boolean = false; 5708 try { 5709 status = professionalPhotoSession.isManualIsoSupported(); 5710 } catch (error) { 5711 // If the operation fails, error.code is returned and processed. 5712 let err = error as BusinessError; 5713 console.error(`The isManualIsoSupported call failed. error code: ${err.code}`); 5714 } 5715 return status; 5716} 5717``` 5718 5719### getIsoRange<sup>12+</sup> 5720 5721getIsoRange(): Array\<number\> 5722 5723Obtains the supported ISO range. 5724 5725**System API**: This is a system API. 5726 5727**System capability**: SystemCapability.Multimedia.Camera.Core 5728 5729**Return value** 5730 5731| Type | Description | 5732| ---------- | ----------------------------- | 5733| 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.| 5734 5735**Error codes** 5736 5737For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5738 5739| ID | Error Message | 5740| --------------- | --------------- | 5741| 202 | Not System Application. | 5742| 7400103 | Session not config. | 5743 5744**Example** 5745 5746```ts 5747import { BusinessError } from '@kit.BasicServicesKit'; 5748 5749function getIsoRange(professionalPhotoSession: camera.ProfessionalPhotoSession): Array<number> { 5750 let isoRange: Array<number> = []; 5751 try { 5752 isoRange = professionalPhotoSession.getIsoRange(); 5753 } catch (error) { 5754 // If the operation fails, error.code is returned and processed. 5755 let err = error as BusinessError; 5756 console.error(`The getIsoRange call failed. error code: ${err.code}`); 5757 } 5758 return isoRange; 5759} 5760``` 5761 5762## ManualIso<sup>12+</sup> 5763 5764ManualIso extends [ManualIsoQuery](#manualisoquery12) 5765 5766Provides APIs for obtaining and setting the manual ISO (sensitivity) of a camera device. 5767 5768### setIso<sup>12+</sup> 5769setIso(iso: number): void 5770 5771Sets the ISO. 5772 5773**NOTE**: When the ISO is set to 0, automatic ISO is used. 5774 5775**System API**: This is a system API. 5776 5777**System capability**: SystemCapability.Multimedia.Camera.Core 5778 5779**Parameters** 5780 5781| Name | Type | Mandatory| Description | 5782| -------- | ----------------------- | ---- | ------------------- | 5783| iso | number | Yes | ISO.| 5784 5785**Error codes** 5786 5787For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5788 5789| ID | Error Message | 5790| --------------- | --------------- | 5791| 202 | Not System Application. | 5792| 7400101 | Parameter missing or parameter type incorrect. | 5793| 7400103 | Session not config. | 5794 5795**Example** 5796 5797```ts 5798import { BusinessError } from '@kit.BasicServicesKit'; 5799 5800function setIso(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5801 try { 5802 let iso: number = 200; 5803 professionalPhotoSession.setIso(iso); 5804 } catch (error) { 5805 // If the operation fails, error.code is returned and processed. 5806 let err = error as BusinessError; 5807 console.error(`The setIso call failed. error code: ${err.code}`); 5808 } 5809} 5810``` 5811 5812### getIso<sup>12+</sup> 5813 5814getIso(): number 5815 5816Obtains the ISO in use. 5817 5818**System API**: This is a system API. 5819 5820**System capability**: SystemCapability.Multimedia.Camera.Core 5821 5822**Return value** 5823 5824| Type | Description | 5825| ---------- | ----------------------------- | 5826| number | ISO.| 5827 5828**Error codes** 5829 5830For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5831 5832| ID | Error Message | 5833| --------------- | --------------- | 5834| 202 | Not System Application. | 5835| 7400103 | Session not config. | 5836 5837**Example** 5838 5839```ts 5840import { BusinessError } from '@kit.BasicServicesKit'; 5841 5842function getIso(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 5843 let iso: number = 0; 5844 try { 5845 iso = professionalPhotoSession.getIso(); 5846 } catch (error) { 5847 // If the operation fails, error.code is returned and processed. 5848 let err = error as BusinessError; 5849 console.error(`The getIso call failed. error code: ${err.code}`); 5850 } 5851 return iso; 5852} 5853``` 5854 5855## WhiteBalanceMode<sup>12+</sup> 5856 5857Enumerates the white balance modes. 5858 5859**System API**: This is a system API. 5860 5861**System capability**: SystemCapability.Multimedia.Camera.Core 5862 5863| Name | Value | Description | 5864| ----------------------------- | ---- | ----------- | 5865| AUTO | 0 | Automatic.| 5866| CLOUDY | 1 | Cloudy.| 5867| INCANDESCENT | 2 | Incandescent light.| 5868| FLUORESCENT | 3 | Fluorescence light.| 5869| DAYLIGHT | 4 | Daylight.| 5870| MANUAL | 5 | Manual.| 5871 5872## WhiteBalanceQuery<sup>12+</sup> 5873 5874Provides APIs to check whether a white balance mode is supported and obtain the white balance mode range supported. 5875 5876### isWhiteBalanceModeSupported<sup>12+</sup> 5877 5878isWhiteBalanceModeSupported(mode: WhiteBalanceMode): boolean 5879 5880Checks whether a white balance mode is supported. 5881 5882**System API**: This is a system API. 5883 5884**System capability**: SystemCapability.Multimedia.Camera.Core 5885**Parameters** 5886 5887| Name | Type | Mandatory | Description | 5888| -------- | -------------------------------| ---- | ----------------------------- | 5889| mode | [WhiteBalanceMode](#whitebalancemode12) | Yes | White balance mode. | 5890 5891**Return value** 5892 5893| Type | Description | 5894| ---------- | ----------------------------- | 5895| 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.| 5896 5897**Error codes** 5898 5899For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5900 5901| ID | Error Message | 5902| --------------- | --------------- | 5903| 202 | Not System Application. | 5904| 7400101 | Parameter missing or parameter type incorrect. | 5905| 7400103 | Session not config. | 5906 5907**Example** 5908 5909```ts 5910import { BusinessError } from '@kit.BasicServicesKit'; 5911 5912function isWhiteBalanceModeSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5913 let status: boolean = false; 5914 try { 5915 let mode: WhiteBalanceMode = camera.WhiteBalanceMode.DAYLIGHT; 5916 status = professionalPhotoSession.isWhiteBalanceModeSupported(mode); 5917 } catch (error) { 5918 // If the operation fails, error.code is returned and processed. 5919 let err = error as BusinessError; 5920 console.error(`The isWhiteBalanceModeSupported call failed. error code: ${err.code}`); 5921 } 5922 return status; 5923} 5924``` 5925 5926### getWhiteBalanceRange<sup>12+</sup> 5927 5928getWhiteBalanceRange(): Array\<number\> 5929 5930Obtains the white balance range, in which users can manually adjust the white balance. 5931 5932**System API**: This is a system API. 5933 5934**System capability**: SystemCapability.Multimedia.Camera.Core 5935 5936**Return value** 5937 5938| Type | Description | 5939| ---------- | ----------------------------- | 5940| 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.| 5941 5942**Error codes** 5943 5944For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5945 5946| ID | Error Message | 5947| --------------- | --------------- | 5948| 202 | Not System Application. | 5949| 7400103 | Session not config. | 5950 5951**Example** 5952 5953```ts 5954import { BusinessError } from '@kit.BasicServicesKit'; 5955 5956function getWhiteBalanceRange(professionalPhotoSession: camera.ProfessionalPhotoSession): Array<number> { 5957 let range: Array<number> = []; 5958 try { 5959 range = professionalPhotoSession.getWhiteBalanceRange(); 5960 } catch (error) { 5961 // If the operation fails, error.code is returned and processed. 5962 let err = error as BusinessError; 5963 console.error(`The getWhiteBalanceRange call failed. error code: ${err.code}`); 5964 } 5965 return range; 5966} 5967``` 5968 5969## WhiteBalance<sup>12+</sup> 5970 5971WhiteBalance extends [WhiteBalanceQuery](#whitebalancequery12) 5972 5973Provides APIs to process white balance, including obtaining and setting the white balance mode and white balance value. 5974 5975### setWhiteBalanceMode<sup>12+</sup> 5976 5977setWhiteBalanceMode(mode: WhiteBalanceMode): void 5978 5979Sets a white balance mode. 5980 5981Before the setting, call [isWhiteBalanceModeSupported](#iswhitebalancemodesupported12) to check whether the target white balance mode is supported. 5982 5983**System API**: This is a system API. 5984 5985**System capability**: SystemCapability.Multimedia.Camera.Core 5986 5987**Parameters** 5988 5989| Name | Type | Mandatory| Description | 5990| -------- | -------------------------------| ---- | ----------------------- | 5991| mode | [WhiteBalanceMode](#whitebalancemode12) | Yes | White balance mode. | 5992 5993**Error codes** 5994 5995For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5996 5997| ID | Error Message | 5998| --------------- | --------------- | 5999| 202 | Not System Application. | 6000| 7400101 | Parameter missing or parameter type incorrect. | 6001| 7400103 | Session not config. | 6002 6003**Example** 6004 6005```ts 6006import { BusinessError } from '@kit.BasicServicesKit'; 6007 6008function setWhiteBalanceMode(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6009 try { 6010 professionalPhotoSession.setWhiteBalanceMode(camera.WhiteBalanceMode.DAYLIGHT); 6011 } catch (error) { 6012 // If the operation fails, error.code is returned and processed. 6013 let err = error as BusinessError; 6014 console.error(`The setWhiteBalanceMode call failed. error code: ${err.code}`); 6015 } 6016} 6017``` 6018 6019### getWhiteBalanceMode<sup>12+</sup> 6020 6021getWhiteBalanceMode(): WhiteBalanceMode 6022 6023Obtains the white balance mode in use. 6024 6025**System API**: This is a system API. 6026 6027**System capability**: SystemCapability.Multimedia.Camera.Core 6028 6029**Return value** 6030 6031| Type | Description | 6032| ---------- | ----------------------------- | 6033| [WhiteBalanceMode](#whitebalancemode12) | White balance mode in use. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 6034 6035**Error codes** 6036 6037For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6038 6039| ID | Error Message | 6040| --------------- | --------------- | 6041| 202 | Not System Application. | 6042| 7400103 | Session not config. | 6043 6044**Example** 6045 6046```ts 6047import { BusinessError } from '@kit.BasicServicesKit'; 6048 6049function getWhiteBalanceMode(professionalPhotoSession: camera.ProfessionalPhotoSession): camera.WhiteBalanceMode | undefined { 6050 let whiteBalanceMode: camera.WhiteBalanceMode | undefined = undefined; 6051 try { 6052 whiteBalanceMode = professionalPhotoSession.getWhiteBalanceMode(); 6053 } catch (error) { 6054 // If the operation fails, error.code is returned and processed. 6055 let err = error as BusinessError; 6056 console.error(`The getWhiteBalanceMode call failed. error code: ${err.code}`); 6057 } 6058 return whiteBalanceMode; 6059} 6060``` 6061 6062### setWhiteBalance<sup>12+</sup> 6063 6064setWhiteBalance(whiteBalance: number): void 6065 6066Sets a white balance value. 6067 6068**System API**: This is a system API. 6069 6070**System capability**: SystemCapability.Multimedia.Camera.Core 6071 6072**Parameters** 6073 6074| Name | Type | Mandatory| Description | 6075| -------- | ----------------------- | ---- | ------------------- | 6076| whiteBalance | number | Yes | White balance value.| 6077 6078**Error codes** 6079 6080For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6081 6082| ID | Error Message | 6083| --------------- | --------------- | 6084| 202 | Not System Application. | 6085| 7400101 | Parameter missing or parameter type incorrect. | 6086| 7400103 | Session not config. | 6087 6088**Example** 6089 6090```ts 6091import { BusinessError } from '@kit.BasicServicesKit'; 6092 6093function setWhiteBalance(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6094 try { 6095 let whiteBalance: number = 1000; 6096 professionalPhotoSession.setWhiteBalance(whiteBalance); 6097 } catch (error) { 6098 // If the operation fails, error.code is returned and processed. 6099 let err = error as BusinessError; 6100 console.error(`The setWhiteBalance call failed. error code: ${err.code}`); 6101 } 6102} 6103``` 6104 6105### getWhiteBalance<sup>12+</sup> 6106 6107getWhiteBalance(): number 6108 6109Obtains the current white balance value. 6110 6111**System API**: This is a system API. 6112 6113**System capability**: SystemCapability.Multimedia.Camera.Core 6114 6115**Return value** 6116 6117| Type | Description | 6118| ---------- | ----------------------------- | 6119| number | White balance value.| 6120 6121**Error codes** 6122 6123For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6124 6125| ID | Error Message | 6126| --------------- | --------------- | 6127| 202 | Not System Application. | 6128| 7400103 | Session not config. | 6129 6130**Example** 6131 6132```ts 6133import { BusinessError } from '@kit.BasicServicesKit'; 6134 6135function getWhiteBalance(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 6136 let whiteBalance: number = 0; 6137 try { 6138 whiteBalance = professionalPhotoSession.getWhiteBalance(); 6139 } catch (error) { 6140 // If the operation fails, error.code is returned and processed. 6141 let err = error as BusinessError; 6142 console.error(`The getWhiteBalance call failed. error code: ${err.code}`); 6143 } 6144 return whiteBalance; 6145} 6146``` 6147 6148## ProfessionalPhotoSession<sup>12+</sup> 6149 6150ProfessionalPhotoSession extends Session, AutoExposure, ManualExposure, Focus, ManualFocus, WhiteBalance, ManualIso, Flash, Zoom, ColorEffect, Aperture 6151 6152Implements 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). 6153 6154### on('error')<sup>12+</sup> 6155 6156on(type: 'error', callback: ErrorCallback): void 6157 6158Subscribes to **ProfessionalPhotoSession** error events. This API uses an asynchronous callback to return the result. 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 **'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).| 6169| 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).| 6170 6171**Error codes** 6172 6173For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6174 6175| ID | Error Message | 6176|---------| --------------- | 6177| 202 | Not System Application. | 6178 6179**Example** 6180 6181```ts 6182import { BusinessError } from '@kit.BasicServicesKit'; 6183 6184function callback(err: BusinessError): void { 6185 console.error(`Professional photo session error code: ${err.code}`); 6186} 6187 6188function registerSessionError(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6189 professionalPhotoSession.on('error', callback); 6190} 6191``` 6192 6193### off('error')<sup>12+</sup> 6194 6195off(type: 'error', callback?: ErrorCallback): void 6196 6197Unsubscribes from **ProfessionalPhotoSession** error events. 6198 6199**System API**: This is a system API. 6200 6201**System capability**: SystemCapability.Multimedia.Camera.Core 6202 6203**Parameters** 6204 6205| Name | Type | Mandatory| Description | 6206| -------- | ------------------------ | ---- | ------------------------------ | 6207| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 6208| 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. | 6209 6210**Error codes** 6211 6212For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6213 6214| ID | Error Message | 6215|---------| --------------- | 6216| 202 | Not System Application. | 6217 6218**Example** 6219 6220```ts 6221function unregisterSessionError(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6222 professionalPhotoSession.off('error'); 6223} 6224``` 6225 6226### on('focusStateChange')<sup>12+</sup> 6227 6228on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 6229 6230Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 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 **'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.| 6241| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 6242 6243**Error codes** 6244 6245For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6246 6247| ID | Error Message | 6248|---------| --------------- | 6249| 202 | Not System Application. | 6250 6251**Example** 6252 6253```ts 6254import { BusinessError } from '@kit.BasicServicesKit'; 6255 6256function callback(err: BusinessError, focusState: camera.FocusState): void { 6257 if (err !== undefined && err.code !== 0) { 6258 console.error(`Callback Error, errorCode: ${err.code}`); 6259 return; 6260 } 6261 console.info(`Focus state: ${focusState}`); 6262} 6263 6264function registerFocusStateChange(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6265 professionalPhotoSession.on('focusStateChange', callback); 6266} 6267``` 6268 6269### off('focusStateChange')<sup>12+</sup> 6270 6271off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 6272 6273Unsubscribes from focus state change events. 6274 6275**System API**: This is a system API. 6276 6277**System capability**: SystemCapability.Multimedia.Camera.Core 6278 6279**Parameters** 6280 6281| Name | Type | Mandatory| Description | 6282| -------- | ----------------------------------------- | ---- | ------------------------ | 6283| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 6284| 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.) | 6285 6286**Error codes** 6287 6288For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6289 6290| ID | Error Message | 6291|---------| --------------- | 6292| 202 | Not System Application. | 6293 6294**Example** 6295 6296```ts 6297function unregisterFocusStateChange(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6298 professionalPhotoSession.off('focusStateChange'); 6299} 6300``` 6301 6302### on('smoothZoomInfoAvailable')<sup>12+</sup> 6303 6304on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 6305 6306Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 6307 6308**System API**: This is a system API. 6309 6310**System capability**: SystemCapability.Multimedia.Camera.Core 6311 6312**Parameters** 6313 6314| Name | Type | Mandatory| Description | 6315| -------- | ----------------------- | ---- | ------------------------ | 6316| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 6317| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 6318 6319**Error codes** 6320 6321For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6322 6323| ID | Error Message | 6324|---------| --------------- | 6325| 202 | Not System Application. | 6326 6327**Example** 6328 6329```ts 6330import { BusinessError } from '@kit.BasicServicesKit'; 6331 6332function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 6333 if (err !== undefined && err.code !== 0) { 6334 console.error(`Callback Error, errorCode: ${err.code}`); 6335 return; 6336 } 6337 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 6338} 6339 6340function registerSmoothZoomInfo(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6341 professionalPhotoSession.on('smoothZoomInfoAvailable', callback); 6342} 6343``` 6344 6345### off('smoothZoomInfoAvailable')<sup>12+</sup> 6346 6347off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 6348 6349Unsubscribes from smooth zoom state change events. 6350 6351**System API**: This is a system API. 6352 6353**System capability**: SystemCapability.Multimedia.Camera.Core 6354 6355**Parameters** 6356 6357| Name | Type | Mandatory| Description | 6358| -------- | ----------------------------------------- | ---- | ------------------------ | 6359| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 6360| 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.) | 6361 6362**Error codes** 6363 6364For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6365 6366| ID | Error Message | 6367|---------| --------------- | 6368| 202 | Not System Application. | 6369 6370**Example** 6371 6372```ts 6373function unregisterSmoothZoomInfo(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6374 professionalPhotoSession.off('smoothZoomInfoAvailable'); 6375} 6376``` 6377 6378### on('isoInfoChange')<sup>12+</sup> 6379 6380on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 6381 6382Subscribes to automatic ISO change events to obtain real-time ISO information. This API uses an asynchronous callback to return the result. 6383 6384**System API**: This is a system API. 6385 6386**System capability**: SystemCapability.Multimedia.Camera.Core 6387 6388**Parameters** 6389 6390| Name | Type | Mandatory| Description | 6391| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6392| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 6393| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| Yes | Callback used to return the ISO information. | 6394 6395**Error codes** 6396 6397| ID| Error Message | 6398| ------- | ---------------------- | 6399| 202 | Not System Application. | 6400 6401**Example** 6402 6403```ts 6404import { BusinessError } from '@kit.BasicServicesKit'; 6405 6406function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 6407 if (err !== undefined && err.code !== 0) { 6408 console.error(`Callback Error, errorCode: ${err.code}`); 6409 return; 6410 } 6411 console.log(`ISO value: ${info.iso}`); 6412} 6413 6414function registerIsoInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6415 professionalPhotoSession.on('isoInfoChange', isoInfoCallback); 6416} 6417``` 6418 6419### off('isoInfoChange')<sup>12+</sup> 6420 6421off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 6422 6423Unsubscribes from automatic ISO change events. 6424 6425**System API**: This is a system API. 6426 6427**System capability**: SystemCapability.Multimedia.Camera.Core 6428 6429**Parameters** 6430 6431| Name | Type | Mandatory| Description | 6432| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6433| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 6434| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('isoInfoChange')**.| 6435 6436**Error codes** 6437 6438| ID| Error Message | 6439| ------- | ---------------------- | 6440| 202 | Not System Application. | 6441 6442**Example** 6443 6444```ts 6445function unregisterIsoInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6446 professionalPhotoSession.off('isoInfoChange'); 6447} 6448``` 6449 6450### on('exposureInfoChange')<sup>12+</sup> 6451 6452on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 6453 6454Subscribes to exposure information change events to obtain the exposure information. This API uses an asynchronous callback to return the result. 6455 6456**System API**: This is a system API. 6457 6458**System capability**: SystemCapability.Multimedia.Camera.Core 6459 6460**Parameters** 6461 6462| Name | Type | Mandatory| Description | 6463| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6464| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 6465| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| Yes | Callback used to return the exposure information. | 6466 6467**Error codes** 6468 6469| ID| Error Message | 6470| ------- | ---------------------- | 6471| 202 | Not System Application. | 6472 6473**Example** 6474 6475```ts 6476import { BusinessError } from '@kit.BasicServicesKit'; 6477 6478function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 6479 if (err !== undefined && err.code !== 0) { 6480 console.error(`Callback Error, errorCode: ${err.code}`); 6481 return; 6482 } 6483 console.log(`exposureTimeValue: ${info.exposureTime}`); 6484} 6485 6486function registerExposureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6487 professionalPhotoSession.on('exposureInfoChange', exposureInfoCallback); 6488} 6489``` 6490 6491### off('exposureInfoChange')<sup>12+</sup> 6492 6493off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 6494 6495Unsubscribes from exposure information change events. 6496 6497**System API**: This is a system API. 6498 6499**System capability**: SystemCapability.Multimedia.Camera.Core 6500 6501**Parameters** 6502 6503| Name | Type | Mandatory| Description | 6504| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6505| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 6506| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('exposureInfoChange')**.| 6507 6508**Error codes** 6509 6510| ID| Error Message | 6511| ------- | ---------------------- | 6512| 202 | Not System Application. | 6513 6514**Example** 6515 6516```ts 6517function unregisterExposureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6518 professionalPhotoSession.off('exposureInfoChange'); 6519} 6520``` 6521 6522### on('apertureInfoChange')<sup>12+</sup> 6523 6524on(type: 'apertureInfoChange', callback: AsyncCallback\<ApertureInfo\>): void 6525 6526Subscribes to aperture change events to obtain the real-time aperture information. This API uses an asynchronous callback to return the result. 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 **'apertureInfoChange'**. | 6537| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| Yes | Callback used to return the aperture information. | 6538 6539**Error codes** 6540 6541| ID| Error Message | 6542| ------- | ---------------------- | 6543| 202 | Not System Application. | 6544 6545**Example** 6546 6547```ts 6548import { BusinessError } from '@kit.BasicServicesKit'; 6549 6550function apertureInfoCallback(err: BusinessError, info: camera.ApertureInfo): void { 6551 if (err !== undefined && err.code !== 0) { 6552 console.error(`Callback Error, errorCode: ${err.code}`); 6553 return; 6554 } 6555 console.log(`Aperture value: ${info.aperture}`); 6556} 6557 6558function registerApertureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6559 professionalPhotoSession.on('apertureInfoChange', apertureInfoCallback); 6560} 6561``` 6562 6563### off('apertureInfoChange')<sup>12+</sup> 6564 6565off(type: 'apertureInfoChange', callback?: AsyncCallback\<ApertureInfo\>): void 6566 6567Unsubscribes from aperture change events. 6568 6569**System API**: This is a system API. 6570 6571**System capability**: SystemCapability.Multimedia.Camera.Core 6572 6573**Parameters** 6574 6575| Name | Type | Mandatory| Description | 6576| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6577| type | string | Yes | Event type. The value is fixed at **'apertureInfoChange'**. | 6578| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('apertureInfoChange')**.| 6579 6580**Error codes** 6581 6582| ID| Error Message | 6583| ------- | ---------------------- | 6584| 202 | Not System Application. | 6585 6586**Example** 6587 6588```ts 6589function unregisterApertureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6590 professionalPhotoSession.off('apertureInfoChange'); 6591} 6592``` 6593 6594### on('luminationInfoChange')<sup>12+</sup> 6595 6596on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 6597 6598Subscribes to illumination change events to obtain real-time illumination information. This API uses an asynchronous callback to return the result. 6599 6600**System API**: This is a system API. 6601 6602**System capability**: SystemCapability.Multimedia.Camera.Core 6603 6604**Parameters** 6605 6606| Name | Type | Mandatory| Description | 6607| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6608| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 6609| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| Yes | Callback used to return the illumination information. | 6610 6611**Error codes** 6612 6613| ID| Error Message | 6614| ------- | ---------------------- | 6615| 202 | Not System Application. | 6616 6617**Example** 6618 6619```ts 6620import { BusinessError } from '@kit.BasicServicesKit'; 6621 6622function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 6623 if (err !== undefined && err.code !== 0) { 6624 console.error(`Callback Error, errorCode: ${err.code}`); 6625 return; 6626 } 6627 console.log(`Lumination: ${info.lumination}`); 6628} 6629 6630function registerLuminationInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6631 professionalPhotoSession.on('luminationInfoChange', luminationInfoCallback); 6632} 6633``` 6634 6635### off('luminationInfoChange')<sup>12+</sup> 6636 6637off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 6638 6639Unsubscribes from illumination change events. 6640 6641**System API**: This is a system API. 6642 6643**System capability**: SystemCapability.Multimedia.Camera.Core 6644 6645**Parameters** 6646 6647| Name | Type | Mandatory| Description | 6648| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6649| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 6650| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('luminationInfoChange')**.| 6651 6652**Error codes** 6653 6654| ID| Error Message | 6655| ------- | ---------------------- | 6656| 202 | Not System Application. | 6657 6658**Example** 6659 6660```ts 6661function unregisterLuminationInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6662 professionalPhotoSession.off('luminationInfoChange'); 6663} 6664``` 6665 6666## ProfessionalVideoSession<sup>12+</sup> 6667 6668ProfessionalVideoSession extends Session, AutoExposure, ManualExposure, Focus, ManualFocus, WhiteBalance, ManualIso, Flash, Zoom, ColorEffect, Aperture 6669 6670Implements 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). 6671 6672### on('error')<sup>12+</sup> 6673 6674on(type: 'error', callback: ErrorCallback): void 6675 6676Subscribes to **ProfessionalVideo** error events. This API uses an asynchronous callback to return the result. 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 **'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).| 6687| 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).| 6688 6689**Error codes** 6690 6691For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6692 6693| ID | Error Message | 6694|---------| --------------- | 6695| 202 | Not System Application. | 6696 6697**Example** 6698 6699```ts 6700import { BusinessError } from '@kit.BasicServicesKit'; 6701 6702function callback(err: BusinessError): void { 6703 console.error(`Professional video session error code: ${err.code}`); 6704} 6705 6706function registerSessionError(professionalVideoSession: camera.ProfessionalVideoSession): void { 6707 professionalVideoSession.on('error', callback); 6708} 6709``` 6710 6711### off('error')<sup>12+</sup> 6712 6713off(type: 'error', callback?: ErrorCallback): void 6714 6715Unsubscribes from **ProfessionalVideo** error events. 6716 6717**System API**: This is a system API. 6718 6719**System capability**: SystemCapability.Multimedia.Camera.Core 6720 6721**Parameters** 6722 6723| Name | Type | Mandatory| Description | 6724| -------- | ------------------------ | ---- | ------------------------------ | 6725| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 6726| 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. | 6727 6728**Error codes** 6729 6730For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6731 6732| ID | Error Message | 6733|---------| --------------- | 6734| 202 | Not System Application. | 6735 6736**Example** 6737 6738```ts 6739function unregisterSessionError(professionalVideoSession: camera.ProfessionalVideoSession): void { 6740 professionalVideoSession.off('error'); 6741} 6742``` 6743 6744### on('focusStateChange')<sup>12+</sup> 6745 6746on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 6747 6748Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 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 **'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.| 6759| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 6760 6761**Error codes** 6762 6763For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6764 6765| ID | Error Message | 6766|---------| --------------- | 6767| 202 | Not System Application. | 6768 6769**Example** 6770 6771```ts 6772import { BusinessError } from '@kit.BasicServicesKit'; 6773 6774function callback(err: BusinessError, focusState: camera.FocusState): void { 6775 if (err !== undefined && err.code !== 0) { 6776 console.error(`Callback Error, errorCode: ${err.code}`); 6777 return; 6778 } 6779 console.info(`Focus state: ${focusState}`); 6780} 6781 6782function registerFocusStateChange(professionalVideoSession: camera.ProfessionalVideoSession): void { 6783 professionalVideoSession.on('focusStateChange', callback); 6784} 6785``` 6786 6787### off('focusStateChange')<sup>12+</sup> 6788 6789off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 6790 6791Unsubscribes from focus state change events. 6792 6793**System API**: This is a system API. 6794 6795**System capability**: SystemCapability.Multimedia.Camera.Core 6796 6797**Parameters** 6798 6799| Name | Type | Mandatory| Description | 6800| -------- | ----------------------------------------- | ---- | ------------------------ | 6801| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 6802| 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.) | 6803 6804**Error codes** 6805 6806For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6807 6808| ID | Error Message | 6809|---------| --------------- | 6810| 202 | Not System Application. | 6811 6812**Example** 6813 6814```ts 6815function unregisterFocusStateChange(professionalVideoSession: camera.ProfessionalVideoSession): void { 6816 professionalVideoSession.off('focusStateChange'); 6817} 6818``` 6819 6820### on('smoothZoomInfoAvailable')<sup>12+</sup> 6821 6822on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 6823 6824Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 6825 6826**System API**: This is a system API. 6827 6828**System capability**: SystemCapability.Multimedia.Camera.Core 6829 6830**Parameters** 6831 6832| Name | Type | Mandatory| Description | 6833| -------- | ----------------------- | ---- | ------------------------ | 6834| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 6835| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 6836 6837**Error codes** 6838 6839For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6840 6841| ID | Error Message | 6842|---------| --------------- | 6843| 202 | Not System Application. | 6844 6845**Example** 6846 6847```ts 6848import { BusinessError } from '@kit.BasicServicesKit'; 6849 6850function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 6851 if (err !== undefined && err.code !== 0) { 6852 console.error(`Callback Error, errorCode: ${err.code}`); 6853 return; 6854 } 6855 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 6856} 6857 6858function registerSmoothZoomInfo(professionalVideoSession: camera.ProfessionalVideoSession): void { 6859 professionalVideoSession.on('smoothZoomInfoAvailable', callback); 6860} 6861``` 6862 6863### off('smoothZoomInfoAvailable')<sup>12+</sup> 6864 6865off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 6866 6867Unsubscribes from smooth zoom state change events. 6868 6869**System API**: This is a system API. 6870 6871**System capability**: SystemCapability.Multimedia.Camera.Core 6872 6873**Parameters** 6874 6875| Name | Type | Mandatory| Description | 6876| -------- | ----------------------------------------- | ---- | ------------------------ | 6877| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 6878| 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.) | 6879 6880**Error codes** 6881 6882For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6883 6884| ID | Error Message | 6885|---------| --------------- | 6886| 202 | Not System Application. | 6887 6888**Example** 6889 6890```ts 6891function unregisterSmoothZoomInfo(professionalVideoSession: camera.ProfessionalVideoSession): void { 6892 professionalVideoSession.off('smoothZoomInfoAvailable'); 6893} 6894``` 6895 6896### on('isoInfoChange')<sup>12+</sup> 6897 6898on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 6899 6900Subscribes to automatic ISO change events to obtain real-time ISO information. This API uses an asynchronous callback to return the result. 6901 6902**System API**: This is a system API. 6903 6904**System capability**: SystemCapability.Multimedia.Camera.Core 6905 6906**Parameters** 6907 6908| Name | Type | Mandatory| Description | 6909| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6910| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 6911| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| Yes | Callback used to return the ISO information. | 6912 6913**Error codes** 6914 6915| ID| Error Message | 6916| ------- | ---------------------- | 6917| 202 | Not System Application. | 6918 6919**Example** 6920 6921```ts 6922import { BusinessError } from '@kit.BasicServicesKit'; 6923 6924function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 6925 if (err !== undefined && err.code !== 0) { 6926 console.error(`Callback Error, errorCode: ${err.code}`); 6927 return; 6928 } 6929 console.log(`ISO value: ${info.iso}`); 6930} 6931 6932function registerIsoInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6933 professionalVideoSession.on('isoInfoChange', isoInfoCallback); 6934} 6935``` 6936 6937### off('isoInfoChange')<sup>12+</sup> 6938 6939off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 6940 6941Unsubscribes from automatic ISO change events. 6942 6943**System API**: This is a system API. 6944 6945**System capability**: SystemCapability.Multimedia.Camera.Core 6946 6947**Parameters** 6948 6949| Name | Type | Mandatory| Description | 6950| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6951| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 6952| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('isoInfoChange')**.| 6953 6954**Error codes** 6955 6956| ID| Error Message | 6957| ------- | ---------------------- | 6958| 202 | Not System Application. | 6959 6960**Example** 6961 6962```ts 6963function unregisterIsoInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6964 professionalVideoSession.off('isoInfoChange'); 6965} 6966``` 6967 6968### on('exposureInfoChange')<sup>12+</sup> 6969 6970on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 6971 6972Subscribes to exposure information change events to obtain the exposure information. This API uses an asynchronous callback to return the result. 6973 6974**System API**: This is a system API. 6975 6976**System capability**: SystemCapability.Multimedia.Camera.Core 6977 6978**Parameters** 6979 6980| Name | Type | Mandatory| Description | 6981| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6982| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 6983| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| Yes | Callback used to return the exposure information. | 6984 6985**Error codes** 6986 6987| ID| Error Message | 6988| ------- | ---------------------- | 6989| 202 | Not System Application. | 6990 6991**Example** 6992 6993```ts 6994import { BusinessError } from '@kit.BasicServicesKit'; 6995 6996function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 6997 if (err !== undefined && err.code !== 0) { 6998 console.error(`Callback Error, errorCode: ${err.code}`); 6999 return; 7000 } 7001 console.log(`exposureTimeValue: ${info.exposureTime}`); 7002} 7003 7004function registerExposureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7005 professionalVideoSession.on('exposureInfoChange', exposureInfoCallback); 7006} 7007``` 7008 7009### off('exposureInfoChange')<sup>12+</sup> 7010 7011off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 7012 7013Unsubscribes from exposure information change events. 7014 7015**System API**: This is a system API. 7016 7017**System capability**: SystemCapability.Multimedia.Camera.Core 7018 7019**Parameters** 7020 7021| Name | Type | Mandatory| Description | 7022| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7023| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 7024| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('exposureInfoChange')**.| 7025 7026**Error codes** 7027 7028| ID| Error Message | 7029| ------- | ---------------------- | 7030| 202 | Not System Application. | 7031 7032**Example** 7033 7034```ts 7035function unregisterExposureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7036 professionalVideoSession.off('exposureInfoChange'); 7037} 7038``` 7039 7040### on('apertureInfoChange')<sup>12+</sup> 7041 7042on(type: 'apertureInfoChange', callback: AsyncCallback\<ApertureInfo\>): void 7043 7044Subscribes to aperture change events to obtain the aperture information. This API uses an asynchronous callback to return the result. 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 **'apertureInfoChange'**. | 7055| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| Yes | Callback used to return the aperture information. | 7056 7057**Error codes** 7058 7059| ID| Error Message | 7060| ------- | ---------------------- | 7061| 202 | Not System Application. | 7062 7063**Example** 7064 7065```ts 7066import { BusinessError } from '@kit.BasicServicesKit'; 7067 7068function apertureInfoCallback(err: BusinessError, info: camera.ApertureInfo): void { 7069 if (err !== undefined && err.code !== 0) { 7070 console.error(`Callback Error, errorCode: ${err.code}`); 7071 return; 7072 } 7073 console.log(`Aperture value: ${info.aperture}`); 7074} 7075 7076function registerApertureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7077 professionalVideoSession.on('apertureInfoChange', apertureInfoCallback); 7078} 7079``` 7080 7081### off('apertureInfoChange')<sup>12+</sup> 7082 7083off(type: 'apertureInfoChange', callback?: AsyncCallback\<ApertureInfo\>): void 7084 7085Unsubscribes from aperture change events. 7086 7087**System API**: This is a system API. 7088 7089**System capability**: SystemCapability.Multimedia.Camera.Core 7090 7091**Parameters** 7092 7093| Name | Type | Mandatory| Description | 7094| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7095| type | string | Yes | Event type. The value is fixed at **'apertureInfoChange'**. | 7096| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('apertureInfoChange')**.| 7097 7098**Error codes** 7099 7100| ID| Error Message | 7101| ------- | ---------------------- | 7102| 202 | Not System Application. | 7103 7104**Example** 7105 7106```ts 7107function unregisterApertureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7108 professionalVideoSession.off('apertureInfoChange'); 7109} 7110``` 7111 7112### on('luminationInfoChange')<sup>12+</sup> 7113 7114on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 7115 7116Subscribes to illumination change events to obtain illumination information. This API uses an asynchronous callback to return the result. 7117 7118**System API**: This is a system API. 7119 7120**System capability**: SystemCapability.Multimedia.Camera.Core 7121 7122**Parameters** 7123 7124| Name | Type | Mandatory| Description | 7125| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7126| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 7127| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| Yes | Callback used to return the illumination information. | 7128 7129**Error codes** 7130 7131| ID| Error Message | 7132| ------- | ---------------------- | 7133| 202 | Not System Application. | 7134 7135**Example** 7136 7137```ts 7138import { BusinessError } from '@kit.BasicServicesKit'; 7139 7140function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 7141 if (err !== undefined && err.code !== 0) { 7142 console.error(`Callback Error, errorCode: ${err.code}`); 7143 return; 7144 } 7145 console.log(`Lumination: ${info.lumination}`); 7146} 7147 7148function registerLuminationInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7149 professionalVideoSession.on('luminationInfoChange', luminationInfoCallback); 7150} 7151``` 7152 7153### off('luminationInfoChange')<sup>12+</sup> 7154 7155off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 7156 7157Unsubscribes from illumination change events. 7158 7159**System API**: This is a system API. 7160 7161**System capability**: SystemCapability.Multimedia.Camera.Core 7162 7163**Parameters** 7164 7165| Name | Type | Mandatory| Description | 7166| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7167| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 7168| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('luminationInfoChange')**.| 7169 7170**Error codes** 7171 7172| ID| Error Message | 7173| ------- | ---------------------- | 7174| 202 | Not System Application. | 7175 7176**Example** 7177 7178```ts 7179function unregisterLuminationInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7180 professionalVideoSession.off('luminationInfoChange'); 7181} 7182``` 7183 7184## MacroPhotoSession<sup>12+</sup> 7185 7186MacroPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ManualFocus 7187 7188Implements 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). 7189 7190### on('error')<sup>12+</sup> 7191 7192on(type: 'error', callback: ErrorCallback): void 7193 7194Subscribes to **MacroPhotoSession** error events. This API uses an asynchronous callback to return the result. 7195 7196**System API**: This is a system API. 7197 7198**System capability**: SystemCapability.Multimedia.Camera.Core 7199 7200**Parameters** 7201 7202| Name | Type | Mandatory | Description | 7203|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 7204| 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).| 7205| 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). | 7206 7207**Error codes** 7208 7209For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7210 7211| ID| Error Message | 7212|-------|----------------------------| 7213| 202 | Not System Application. | 7214 7215**Example** 7216 7217```ts 7218import { BusinessError } from '@kit.BasicServicesKit'; 7219 7220function callback(err: BusinessError): void { 7221 console.error(`MacroPhotoSession error code: ${err.code}`); 7222} 7223 7224function registerSessionError(macroPhotoSession: camera.MacroPhotoSession): void { 7225 macroPhotoSession.on('error', callback); 7226} 7227``` 7228 7229### off('error')<sup>12+</sup> 7230 7231off(type: 'error', callback?: ErrorCallback): void 7232 7233Unsubscribes from **MacroPhotoSession** error events. 7234 7235**System API**: This is a system API. 7236 7237**System capability**: SystemCapability.Multimedia.Camera.Core 7238 7239**Parameters** 7240 7241| Name | Type | Mandatory| Description | 7242|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 7243| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. | 7244| 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.| 7245 7246**Error codes** 7247 7248For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7249 7250| ID| Error Message | 7251|-------|----------------------------| 7252| 202 | Not System Application. | 7253 7254**Example** 7255 7256```ts 7257function unregisterSessionError(macroPhotoSession: camera.MacroPhotoSession): void { 7258 macroPhotoSession.off('error'); 7259} 7260``` 7261 7262### on('focusStateChange')<sup>12+</sup> 7263 7264on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7265 7266Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 7267 7268**System API**: This is a system API. 7269 7270**System capability**: SystemCapability.Multimedia.Camera.Core 7271 7272**Parameters** 7273 7274| Name | Type | Mandatory| Description | 7275|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 7276| 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.| 7277| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 7278 7279**Error codes** 7280 7281For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7282 7283| ID| Error Message | 7284|-------|----------------------------| 7285| 202 | Not System Application. | 7286 7287**Example** 7288 7289```ts 7290import { BusinessError } from '@kit.BasicServicesKit'; 7291 7292function callback(err: BusinessError, focusState: camera.FocusState): void { 7293 if (err !== undefined && err.code !== 0) { 7294 console.error(`Callback Error, errorCode: ${err.code}`); 7295 return; 7296 } 7297 console.info(`Focus state: ${focusState}`); 7298} 7299 7300function registerFocusStateChange(macroPhotoSession: camera.MacroPhotoSession): void { 7301 macroPhotoSession.on('focusStateChange', callback); 7302} 7303``` 7304 7305### off('focusStateChange')<sup>12+</sup> 7306 7307off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7308 7309Unsubscribes from focus state change events. 7310 7311**System API**: This is a system API. 7312 7313**System capability**: SystemCapability.Multimedia.Camera.Core 7314 7315**Parameters** 7316 7317| Name | Type | Mandatory| Description | 7318|-----------|---------------------------------------------|----|--------------------------------------------------------------| 7319| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. | 7320| 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. | 7321 7322**Error codes** 7323 7324For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7325 7326| ID| Error Message | 7327|-------|----------------------------| 7328| 202 | Not System Application. | 7329 7330**Example** 7331 7332```ts 7333function unregisterFocusStateChange(macroPhotoSession: camera.MacroPhotoSession): void { 7334 macroPhotoSession.off('focusStateChange'); 7335} 7336``` 7337 7338### on('smoothZoomInfoAvailable')<sup>12+</sup> 7339 7340on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 7341 7342Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 7343 7344**System API**: This is a system API. 7345 7346**System capability**: SystemCapability.Multimedia.Camera.Core 7347 7348**Parameters** 7349 7350| Name | Type | Mandatory| Description | 7351| -------- | ----------------------- | ---- | ------------------------ | 7352| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 7353| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 7354 7355**Error codes** 7356 7357For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7358 7359| ID| Error Message | 7360|-------|----------------------------| 7361| 202 | Not System Application. | 7362 7363**Example** 7364 7365```ts 7366import { BusinessError } from '@kit.BasicServicesKit'; 7367 7368function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 7369 if (err !== undefined && err.code !== 0) { 7370 console.error(`Callback Error, errorCode: ${err.code}`); 7371 return; 7372 } 7373 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 7374} 7375 7376function registerSmoothZoomInfo(macroPhotoSession: camera.MacroPhotoSession): void { 7377 macroPhotoSession.on('smoothZoomInfoAvailable', callback); 7378} 7379``` 7380 7381### off('smoothZoomInfoAvailable')<sup>12+</sup> 7382 7383off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 7384 7385Unsubscribes from smooth zoom state change events. 7386 7387**System API**: This is a system API. 7388 7389**System capability**: SystemCapability.Multimedia.Camera.Core 7390 7391**Parameters** 7392 7393| Name | Type | Mandatory| Description | 7394| -------- | ----------------------------------------- | ---- | ------------------------ | 7395| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 7396| 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.| 7397 7398**Error codes** 7399 7400For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7401 7402| ID| Error Message | 7403|-------|----------------------------| 7404| 202 | Not System Application. | 7405 7406**Example** 7407 7408```ts 7409function unregisterSmoothZoomInfo(macroPhotoSession: camera.MacroPhotoSession): void { 7410 macroPhotoSession.off('smoothZoomInfoAvailable'); 7411} 7412``` 7413 7414## MacroVideoSession<sup>12+</sup> 7415 7416MacroVideoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ManualFocus 7417 7418Implements 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). 7419 7420### on('error')<sup>12+</sup> 7421 7422on(type: 'error', callback: ErrorCallback): void 7423 7424Subscribes to **MacroVideoSession** error events. This API uses an asynchronous callback to return the result. 7425 7426**System API**: This is a system API. 7427 7428**System capability**: SystemCapability.Multimedia.Camera.Core 7429 7430**Parameters** 7431 7432| Name | Type | Mandatory | Description | 7433|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 7434| 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).| 7435| 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). | 7436 7437**Error codes** 7438 7439For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7440 7441| ID| Error Message | 7442|-------|----------------------------| 7443| 202 | Not System Application. | 7444 7445**Example** 7446 7447```ts 7448import { BusinessError } from '@kit.BasicServicesKit'; 7449 7450function callback(err: BusinessError): void { 7451 console.error(`MacroPhotoSession error code: ${err.code}`); 7452} 7453 7454function registerSessionError(macroVideoSession: camera.MacroVideoSession): void { 7455 macroVideoSession.on('error', callback); 7456} 7457``` 7458 7459### off('error')<sup>12+</sup> 7460 7461off(type: 'error', callback?: ErrorCallback): void 7462 7463Unsubscribes from **MacroVideoSession** error events. 7464 7465**System API**: This is a system API. 7466 7467**System capability**: SystemCapability.Multimedia.Camera.Core 7468 7469**Parameters** 7470 7471| Name | Type | Mandatory| Description | 7472|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 7473| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. | 7474| 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.| 7475 7476**Error codes** 7477 7478For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7479 7480| ID| Error Message | 7481|-------|----------------------------| 7482| 202 | Not System Application. | 7483 7484**Example** 7485 7486```ts 7487function unregisterSessionError(macroVideoSession: camera.MacroVideoSession): void { 7488 macroVideoSession.off('error'); 7489} 7490``` 7491 7492### on('focusStateChange')<sup>12+</sup> 7493 7494on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7495 7496Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 7497 7498**System API**: This is a system API. 7499 7500**System capability**: SystemCapability.Multimedia.Camera.Core 7501 7502**Parameters** 7503 7504| Name | Type | Mandatory| Description | 7505|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 7506| 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.| 7507| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 7508 7509**Error codes** 7510 7511For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7512 7513| ID| Error Message | 7514|-------|----------------------------| 7515| 202 | Not System Application. | 7516 7517**Example** 7518 7519```ts 7520import { BusinessError } from '@kit.BasicServicesKit'; 7521 7522function callback(err: BusinessError, focusState: camera.FocusState): void { 7523 if (err !== undefined && err.code !== 0) { 7524 console.error(`Callback Error, errorCode: ${err.code}`); 7525 return; 7526 } 7527 console.info(`Focus state: ${focusState}`); 7528} 7529 7530function registerFocusStateChange(macroVideoSession: camera.MacroVideoSession): void { 7531 macroVideoSession.on('focusStateChange', callback); 7532} 7533``` 7534 7535### off('focusStateChange')<sup>12+</sup> 7536 7537off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7538 7539Unsubscribes from focus state change events. 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. | 7550| 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. | 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 7563function unregisterFocusStateChange(macroVideoSession: camera.MacroVideoSession): void { 7564 macroVideoSession.off('focusStateChange'); 7565} 7566``` 7567 7568### on('smoothZoomInfoAvailable')<sup>12+</sup> 7569 7570on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 7571 7572Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 7573 7574**System API**: This is a system API. 7575 7576**System capability**: SystemCapability.Multimedia.Camera.Core 7577 7578**Parameters** 7579 7580| Name | Type | Mandatory| Description | 7581| -------- | ----------------------- | ---- | ------------------------ | 7582| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 7583| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 7584 7585**Error codes** 7586 7587For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7588 7589| ID| Error Message | 7590|-------|----------------------------| 7591| 202 | Not System Application. | 7592 7593**Example** 7594 7595```ts 7596import { BusinessError } from '@kit.BasicServicesKit'; 7597 7598function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 7599 if (err !== undefined && err.code !== 0) { 7600 console.error(`Callback Error, errorCode: ${err.code}`); 7601 return; 7602 } 7603 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 7604} 7605 7606function registerSmoothZoomInfo(macroVideoSession: camera.MacroVideoSession): void { 7607 macroVideoSession.on('smoothZoomInfoAvailable', callback); 7608} 7609``` 7610 7611### off('smoothZoomInfoAvailable')<sup>12+</sup> 7612 7613off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 7614 7615Unsubscribes from smooth zoom state change events. 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 **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 7626| 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.| 7627 7628**Error codes** 7629 7630For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7631 7632| ID| Error Message | 7633|-------|----------------------------| 7634| 202 | Not System Application. | 7635 7636**Example** 7637 7638```ts 7639function unregisterSmoothZoomInfo(macroVideoSession: camera.MacroVideoSession): void { 7640 macroVideoSession.off('smoothZoomInfoAvailable'); 7641} 7642``` 7643 7644## FlashQuery<sup>12+</sup> 7645 7646Provides APIs to obtain the flash information of a camera device, including whether the LCD flash is supported. 7647 7648### isLcdFlashSupported<sup>12+</sup> 7649 7650isLcdFlashSupported(): boolean 7651 7652Checks whether the LCD flash is supported. 7653 7654**System API**: This is a system API. 7655 7656**System capability**: SystemCapability.Multimedia.Camera.Core 7657 7658**Return value** 7659 7660| Type | Description | 7661| -------------- | ----------------------- | 7662| boolean | **true**: The LCD flash is supported.<br>**false**: The LCD flash is not supported.| 7663 7664**Error codes** 7665 7666For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7667 7668| ID | Error Message | 7669| --------------- | --------------- | 7670| 202 | Not System Application. | 7671| 7400103 | Session not config, only throw in session usage. | 7672 7673**Example** 7674 7675```ts 7676function isLcdFlashSupported(nightPhotoSession: camera.NightPhotoSession): boolean { 7677 return nightPhotoSession.isLcdFlashSupported(); 7678} 7679``` 7680 7681## Flash<sup>11+</sup> 7682 7683Flash extends [FlashQuery](js-apis-camera.md#flashquery12) 7684 7685Provides APIs related to the flash. 7686 7687### enableLcdFlash<sup>13+</sup> 7688 7689enableLcdFlash(enabled: boolean): void 7690 7691Enables or disables the LCD flash. 7692 7693Before the setting, call [isLcdFlashSupported](#islcdflashsupported12) to check whether the device supports the LCD flash. 7694 7695**System capability**: SystemCapability.Multimedia.Camera.Core 7696 7697**Parameters** 7698 7699| Name | Type | Mandatory| Description | 7700| --------- | ----------------------- | ---- |--------------------------------------------------| 7701| enabled | boolean | Yes | Whether to enable or disable the LCD flash. If null or undefined is passed, it is treated as 0 and the LCD flash is disabled.| 7702 7703**Error codes** 7704 7705For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7706 7707| ID | Error Message | 7708| --------------- | --------------- | 7709| 7400103 | Session not config. | 7710 7711**Example** 7712 7713```ts 7714import { BusinessError } from '@kit.BasicServicesKit'; 7715 7716function enableLcdFlash(session: camera.PhotoSessionForSys | camera.VideoSessionForSys | camera.NightPhotoSession): void { 7717 try { 7718 session.enableLcdFlash(true); 7719 } catch (error) { 7720 // If the operation fails, error.code is returned and processed. 7721 let err = error as BusinessError; 7722 console.error(`The setFlashMode call failed. error code: ${err.code}`); 7723 } 7724} 7725``` 7726 7727## TimeLapseRecordState<sup>12+</sup> 7728 7729Enumerates the time-lapse recording states. 7730 7731**System API**: This is a system API. 7732 7733**System capability**: SystemCapability.Multimedia.Camera.Core 7734 7735| Name | Value | Description | 7736| ----------------------------- | ---- | ----------- | 7737| IDLE | 0 | Recording not started.| 7738| RECORDING | 1 | Recording.| 7739 7740## TimeLapsePreviewType<sup>12+</sup> 7741 7742Enumerates the time-lapse preview types, which affect the shooting algorithm. 7743 7744**System API**: This is a system API. 7745 7746**System capability**: SystemCapability.Multimedia.Camera.Core 7747 7748| Name | Value | Description | 7749| ----------------------------- | ---- | ----------- | 7750| DARK | 1 | Dark environment, a scenario with poor illumination, for example, at night or in a dark area.| 7751| LIGHT | 2 | Bright environment, a scenario with good illumination, for example, in the daytime or under light.| 7752 7753## TryAEInfo<sup>12+</sup> 7754 7755Describes the Try AE parameters. Try AE indicates that the hardware reports the status based on the ambient illumination change during time-lapse photographing. 7756 7757**System API**: This is a system API. 7758 7759**System capability**: SystemCapability.Multimedia.Camera.Core 7760 7761| Name| Type | Read-only| Optional| Description | 7762| ---- | ------- | ---- |--| -------------- | 7763| isTryAEDone | boolean | Yes | No| Whether Try AE is complete. | 7764| isTryAEHintNeeded | boolean | Yes | Yes| Whether Try AE is required. | 7765| previewType | [TimeLapsePreviewType](#timelapsepreviewtype12) | Yes | Yes| Preview type. | 7766| captureInterval | number | Yes | Yes| Shooting interval, in ms. | 7767 7768## TimeLapsePhotoSession<sup>12+</sup> 7769 7770TimeLapsePhotoSession extends Session, Focus, ManualFocus, AutoExposure, ManualExposure, ManualIso, WhiteBalance, Zoom, ColorEffect 7771 7772Implements 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). 7773 7774### on('error')<sup>12+</sup> 7775 7776on(type: 'error', callback: ErrorCallback): void 7777 7778Subscribes to **TimeLapsePhotoSession** error events. This API uses an asynchronous callback to return the result. 7779 7780**System API**: This is a system API. 7781 7782**System capability**: SystemCapability.Multimedia.Camera.Core 7783 7784**Parameters** 7785 7786| Name | Type | Mandatory| Description | 7787| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 7788| 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).| 7789| 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).| 7790 7791**Error codes** 7792 7793For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7794 7795| ID | Error Message | 7796|---------| --------------- | 7797| 202 | Not System Application. | 7798 7799**Example** 7800 7801```ts 7802import { BusinessError } from '@kit.BasicServicesKit'; 7803 7804function callback(err: BusinessError): void { 7805 console.error(`Time lapse photo session error code: ${err.code}`); 7806} 7807 7808function registerSessionError(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7809 timeLapsePhotoSession.on('error', callback); 7810} 7811``` 7812 7813### off('error')<sup>12+</sup> 7814 7815off(type: 'error', callback?: ErrorCallback): void 7816 7817Unsubscribes from **TimeLapsePhotoSession** error events. 7818 7819**System API**: This is a system API. 7820 7821**System capability**: SystemCapability.Multimedia.Camera.Core 7822 7823**Parameters** 7824 7825| Name | Type | Mandatory| Description | 7826| -------- | ------------------------ | ---- | ------------------------------ | 7827| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 7828| 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. | 7829 7830**Error codes** 7831 7832For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7833 7834| ID | Error Message | 7835|---------| --------------- | 7836| 202 | Not System Application. | 7837 7838**Example** 7839 7840```ts 7841function unregisterSessionError(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7842 timeLapsePhotoSession.off('error'); 7843} 7844``` 7845 7846### on('focusStateChange')<sup>12+</sup> 7847 7848on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7849 7850Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 7851 7852**System API**: This is a system API. 7853 7854**System capability**: SystemCapability.Multimedia.Camera.Core 7855 7856**Parameters** 7857 7858| Name | Type | Mandatory| Description | 7859| -------- | ---------------- | ---- | ------------------------ | 7860| 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.| 7861| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 7862 7863**Error codes** 7864 7865For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7866 7867| ID | Error Message | 7868|---------| --------------- | 7869| 202 | Not System Application. | 7870 7871**Example** 7872 7873```ts 7874import { BusinessError } from '@kit.BasicServicesKit'; 7875 7876function callback(err: BusinessError, focusState: camera.FocusState): void { 7877 if (err !== undefined && err.code !== 0) { 7878 console.error(`Callback Error, errorCode: ${err.code}`); 7879 return; 7880 } 7881 console.info(`Focus state: ${focusState}`); 7882} 7883 7884function registerFocusStateChange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7885 timeLapsePhotoSession.on('focusStateChange', callback); 7886} 7887``` 7888 7889### off('focusStateChange')<sup>12+</sup> 7890 7891off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7892 7893Unsubscribes from focus state change events. 7894 7895**System API**: This is a system API. 7896 7897**System capability**: SystemCapability.Multimedia.Camera.Core 7898 7899**Parameters** 7900 7901| Name | Type | Mandatory| Description | 7902| -------- | ----------------------------------------- | ---- | ------------------------ | 7903| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 7904| 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.) | 7905 7906**Error codes** 7907 7908For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7909 7910| ID | Error Message | 7911|---------| --------------- | 7912| 202 | Not System Application. | 7913 7914**Example** 7915 7916```ts 7917function unregisterFocusStateChange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7918 timeLapsePhotoSession.off('focusStateChange'); 7919} 7920``` 7921 7922### on('isoInfoChange')<sup>12+</sup> 7923 7924on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 7925 7926Subscribes to automatic ISO change events to obtain real-time ISO information. This API uses an asynchronous callback to return the result. 7927 7928**System API**: This is a system API. 7929 7930**System capability**: SystemCapability.Multimedia.Camera.Core 7931 7932**Parameters** 7933 7934| Name | Type | Mandatory| Description | 7935| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7936| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 7937| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| Yes | Callback used to return the ISO information. | 7938 7939**Error codes** 7940 7941| ID| Error Message | 7942| ------- | ---------------------- | 7943| 202 | Not System Application. | 7944 7945**Example** 7946 7947```ts 7948import { BusinessError } from '@kit.BasicServicesKit'; 7949 7950function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 7951 if (err !== undefined && err.code !== 0) { 7952 console.error(`Callback Error, errorCode: ${err.code}`); 7953 return; 7954 } 7955 console.log(`ISO value: ${info.iso}`); 7956} 7957 7958function registerIsoInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7959 timeLapsePhotoSession.on('isoInfoChange', isoInfoCallback); 7960} 7961``` 7962 7963### off('isoInfoChange')<sup>12+</sup> 7964 7965off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 7966 7967Unsubscribes from automatic ISO change events. 7968 7969**System API**: This is a system API. 7970 7971**System capability**: SystemCapability.Multimedia.Camera.Core 7972 7973**Parameters** 7974 7975| Name | Type | Mandatory| Description | 7976| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7977| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 7978| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('isoInfoChange')**.| 7979 7980**Error codes** 7981 7982| ID| Error Message | 7983| ------- | ---------------------- | 7984| 202 | Not System Application. | 7985 7986**Example** 7987 7988```ts 7989function unregisterIsoInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7990 timeLapsePhotoSession.off('isoInfoChange'); 7991} 7992``` 7993 7994### on('exposureInfoChange')<sup>12+</sup> 7995 7996on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 7997 7998Subscribes to exposure information change events to obtain the exposure information. This API uses an asynchronous callback to return the result. 7999 8000**System API**: This is a system API. 8001 8002**System capability**: SystemCapability.Multimedia.Camera.Core 8003 8004**Parameters** 8005 8006| Name | Type | Mandatory| Description | 8007| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8008| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 8009| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| Yes | Callback used to return the exposure information. | 8010 8011**Error codes** 8012 8013| ID| Error Message | 8014| ------- | ---------------------- | 8015| 202 | Not System Application. | 8016 8017**Example** 8018 8019```ts 8020import { BusinessError } from '@kit.BasicServicesKit'; 8021 8022function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 8023 if (err !== undefined && err.code !== 0) { 8024 console.error(`Callback Error, errorCode: ${err.code}`); 8025 return; 8026 } 8027 console.log(`exposureTimeValue: ${info.exposureTime}`); 8028} 8029 8030function registerExposureInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8031 timeLapsePhotoSession.on('exposureInfoChange', exposureInfoCallback); 8032} 8033``` 8034 8035### off('exposureInfoChange')<sup>12+</sup> 8036 8037off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 8038 8039Unsubscribes from exposure information change events. 8040 8041**System API**: This is a system API. 8042 8043**System capability**: SystemCapability.Multimedia.Camera.Core 8044 8045**Parameters** 8046 8047| Name | Type | Mandatory| Description | 8048| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8049| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 8050| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('exposureInfoChange')**.| 8051 8052**Error codes** 8053 8054| ID| Error Message | 8055| ------- | ---------------------- | 8056| 202 | Not System Application. | 8057 8058**Example** 8059 8060```ts 8061function unregisterExposureInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8062 timeLapsePhotoSession.off('exposureInfoChange'); 8063} 8064``` 8065 8066### on('luminationInfoChange')<sup>12+</sup> 8067 8068on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 8069 8070Subscribes to illumination change events to obtain real-time illumination information. This API uses an asynchronous callback to return the result. 8071 8072**System API**: This is a system API. 8073 8074**System capability**: SystemCapability.Multimedia.Camera.Core 8075 8076**Parameters** 8077 8078| Name | Type | Mandatory| Description | 8079| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8080| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 8081| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| Yes | Callback used to return the illumination information. | 8082 8083**Error codes** 8084 8085| ID| Error Message | 8086| ------- | ---------------------- | 8087| 202 | Not System Application. | 8088 8089**Example** 8090 8091```ts 8092import { BusinessError } from '@kit.BasicServicesKit'; 8093 8094function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 8095 if (err !== undefined && err.code !== 0) { 8096 console.error(`Callback Error, errorCode: ${err.code}`); 8097 return; 8098 } 8099 console.log(`Lumination: ${info.lumination}`); 8100} 8101 8102function registerLuminationInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8103 timeLapsePhotoSession.on('luminationInfoChange', luminationInfoCallback); 8104} 8105``` 8106 8107### off('luminationInfoChange')<sup>12+</sup> 8108 8109off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 8110 8111Unsubscribes from illumination change events. 8112 8113**System API**: This is a system API. 8114 8115**System capability**: SystemCapability.Multimedia.Camera.Core 8116 8117**Parameters** 8118 8119| Name | Type | Mandatory| Description | 8120| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8121| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 8122| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('luminationInfoChange')**.| 8123 8124**Error codes** 8125 8126| ID| Error Message | 8127| ------- | ---------------------- | 8128| 202 | Not System Application. | 8129 8130**Example** 8131 8132```ts 8133function unregisterLuminationInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8134 timeLapsePhotoSession.off('luminationInfoChange'); 8135} 8136``` 8137 8138### on('tryAEInfoChange')<sup>12+</sup> 8139 8140on(type: 'tryAEInfoChange', callback: AsyncCallback\<TryAEInfo\>): void 8141 8142Subscribes to Try AE change events to obtain real-time Try AE parameters. This API uses an asynchronous callback to return the result. 8143 8144**System API**: This is a system API. 8145 8146**System capability**: SystemCapability.Multimedia.Camera.Core 8147 8148**Parameters** 8149 8150| Name | Type | Mandatory| Description | 8151| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8152| type | string | Yes | Event type. The value is fixed at **'tryAEInfoChange'**. | 8153| callback | AsyncCallback\<[TryAEInfo](#tryaeinfo12)\>| Yes | Callback used to return the Try AE parameters. | 8154 8155**Error codes** 8156 8157| ID| Error Message | 8158| ------- | ---------------------- | 8159| 202 | Not System Application. | 8160 8161**Example** 8162 8163```ts 8164import { BusinessError } from '@kit.BasicServicesKit'; 8165 8166function tryAEInfoCallback(err: BusinessError, info: camera.TryAEInfo): void { 8167 if (err !== undefined && err.code !== 0) { 8168 console.error(`Callback Error, errorCode: ${err.code}`); 8169 return; 8170 } 8171 console.log(`TryAEInfo: ${info.isTryAEDone}, ${info.isTryAEHintNeeded}, ${info.previewType}, ${info.captureInterval}`); 8172} 8173 8174function registerTryAEInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8175 timeLapsePhotoSession.on('tryAEInfoChange', tryAEInfoCallback); 8176} 8177``` 8178 8179### off('tryAEInfoChange')<sup>12+</sup> 8180 8181off(type: 'tryAEInfoChange', callback?: AsyncCallback\<TryAEInfo\>): void 8182 8183Unsubscribes from Try AE change events. 8184 8185**System API**: This is a system API. 8186 8187**System capability**: SystemCapability.Multimedia.Camera.Core 8188 8189**Parameters** 8190 8191| Name | Type | Mandatory| Description | 8192| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8193| type | string | Yes | Event type. The value is fixed at **'tryAEInfoChange'**. | 8194| callback | AsyncCallback\<[TryAEInfo](#tryaeinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('tryAEInfoChange')**.| 8195 8196**Error codes** 8197 8198| ID| Error Message | 8199| ------- | ---------------------- | 8200| 202 | Not System Application. | 8201 8202**Example** 8203 8204```ts 8205function unregisterTryAEInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8206 timeLapsePhotoSession.off('tryAEInfoChange'); 8207} 8208``` 8209 8210### isTryAENeeded<sup>12+</sup> 8211 8212isTryAENeeded(): boolean 8213 8214Checks whether Try AE is required. 8215 8216**System API**: This is a system API. 8217 8218**System capability**: SystemCapability.Multimedia.Camera.Core 8219 8220**Return value** 8221 8222| Type | Description | 8223| ---------- | ----------------------------- | 8224| 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.| 8225 8226**Error codes** 8227 8228For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8229 8230| ID | Error Message | 8231| --------------- | --------------- | 8232| 202 | Not System Application. | 8233| 7400103 | Session not config. | 8234 8235**Example** 8236 8237```ts 8238import { BusinessError } from '@kit.BasicServicesKit'; 8239 8240function isTryAENeeded(timeLapsePhotoSession: camera.TimeLapsePhotoSession): boolean { 8241 let needed = false; 8242 try { 8243 needed = timeLapsePhotoSession.isTryAENeeded(); 8244 } catch (error) { 8245 // If the operation fails, error.code is returned and processed. 8246 let err = error as BusinessError; 8247 console.error(`The isTryAENeeded call failed. error code: ${err.code}`); 8248 } 8249 return needed; 8250} 8251``` 8252 8253### startTryAE<sup>12+</sup> 8254 8255startTryAE(): void 8256 8257Starts to execute Try AE. 8258 8259**System API**: This is a system API. 8260 8261**System capability**: SystemCapability.Multimedia.Camera.Core 8262 8263**Error codes** 8264 8265For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8266 8267| ID | Error Message | 8268| --------------- | --------------- | 8269| 202 | Not System Application. | 8270| 7400103 | Session not config. | 8271 8272**Example** 8273 8274```ts 8275import { BusinessError } from '@kit.BasicServicesKit'; 8276 8277function startTryAE(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8278 try { 8279 timeLapsePhotoSession.startTryAE(); 8280 } catch (error) { 8281 // If the operation fails, error.code is returned and processed. 8282 let err = error as BusinessError; 8283 console.error(`The startTryAE call failed. error code: ${err.code}`); 8284 } 8285} 8286``` 8287 8288### stopTryAE<sup>12+</sup> 8289 8290stopTryAE(): void 8291 8292Stops the execution of Try AE. 8293 8294**System API**: This is a system API. 8295 8296**System capability**: SystemCapability.Multimedia.Camera.Core 8297 8298**Error codes** 8299 8300For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8301 8302| ID | Error Message | 8303| --------------- | --------------- | 8304| 202 | Not System Application. | 8305| 7400103 | Session not config. | 8306 8307**Example** 8308 8309```ts 8310import { BusinessError } from '@kit.BasicServicesKit'; 8311 8312function stopTryAE(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8313 try { 8314 timeLapsePhotoSession.stopTryAE(); 8315 } catch (error) { 8316 // If the operation fails, error.code is returned and processed. 8317 let err = error as BusinessError; 8318 console.error(`The stopTryAE call failed. error code: ${err.code}`); 8319 } 8320} 8321``` 8322 8323### getSupportedTimeLapseIntervalRange<sup>12+</sup> 8324 8325getSupportedTimeLapseIntervalRange(): Array\<number\> 8326 8327Obtains the supported time-lapse shooting interval range. 8328 8329**System API**: This is a system API. 8330 8331**System capability**: SystemCapability.Multimedia.Camera.Core 8332 8333**Return value** 8334 8335| Type | Description | 8336| ---------- | ----------------------------- | 8337| 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.| 8338 8339**Error codes** 8340 8341For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8342 8343| ID | Error Message | 8344| --------------- | --------------- | 8345| 202 | Not System Application. | 8346| 7400103 | Session not config. | 8347 8348**Example** 8349 8350```ts 8351import { BusinessError } from '@kit.BasicServicesKit'; 8352 8353function getSupportedTimeLapseIntervalRange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): Array<number> { 8354 let intervalRange: Array<number> = []; 8355 try { 8356 intervalRange = timeLapsePhotoSession.getSupportedTimeLapseIntervalRange(); 8357 } catch (error) { 8358 // If the operation fails, error.code is returned and processed. 8359 let err = error as BusinessError; 8360 console.error(`The getSupportedTimeLapseIntervalRange call failed. error code: ${err.code}`); 8361 } 8362 return intervalRange; 8363} 8364``` 8365 8366### getTimeLapseInterval<sup>12+</sup> 8367 8368getTimeLapseInterval(): number 8369 8370Obtains the current time-lapse shooting interval. 8371 8372**System API**: This is a system API. 8373 8374**System capability**: SystemCapability.Multimedia.Camera.Core 8375 8376**Return value** 8377 8378| Type | Description | 8379| ---------- | ----------------------------- | 8380| number | Shooting interval, in ms.| 8381 8382**Error codes** 8383 8384For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8385 8386| ID | Error Message | 8387| --------------- | --------------- | 8388| 202 | Not System Application. | 8389| 7400103 | Session not config. | 8390 8391**Example** 8392 8393```ts 8394import { BusinessError } from '@kit.BasicServicesKit'; 8395 8396function getTimeLapseInterval(timeLapsePhotoSession: camera.TimeLapsePhotoSession): number { 8397 let interval: number = 0; 8398 try { 8399 interval = timeLapsePhotoSession.getTimeLapseInterval(); 8400 } catch (error) { 8401 // If the operation fails, error.code is returned and processed. 8402 let err = error as BusinessError; 8403 console.error(`The getTimeLapseInterval call failed. error code: ${err.code}`); 8404 } 8405 return interval; 8406} 8407``` 8408 8409### setTimeLapseInterval<sup>12+</sup> 8410setTimeLapseInterval(interval: number): void 8411 8412Sets a time-lapse shooting interval. 8413 8414**System API**: This is a system API. 8415 8416**System capability**: SystemCapability.Multimedia.Camera.Core 8417 8418**Parameters** 8419 8420| Name | Type | Mandatory| Description | 8421| -------- | ----------------------- | ---- | ------------------- | 8422| interval | number | Yes | Shooting interval, in ms.| 8423 8424**Error codes** 8425 8426For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8427 8428| ID | Error Message | 8429| --------------- | --------------- | 8430| 202 | Not System Application. | 8431| 7400101 | Parameter missing or parameter type incorrect. | 8432| 7400103 | Session not config. | 8433 8434**Example** 8435 8436```ts 8437import { BusinessError } from '@kit.BasicServicesKit'; 8438 8439function setTimeLapseInterval(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8440 try { 8441 let interval: number = 10000; 8442 timeLapsePhotoSession.setTimeLapseInterval(interval); 8443 } catch (error) { 8444 // If the operation fails, error.code is returned and processed. 8445 let err = error as BusinessError; 8446 console.error(`The setTimeLapseInterval call failed. error code: ${err.code}`); 8447 } 8448} 8449``` 8450 8451### getTimeLapseRecordState<sup>12+</sup> 8452 8453getTimeLapseRecordState(): TimeLapseRecordState 8454 8455Obtains the time-lapse shooting state. 8456 8457**System API**: This is a system API. 8458 8459**System capability**: SystemCapability.Multimedia.Camera.Core 8460 8461**Return value** 8462 8463| Type | Description | 8464| ---------- | ----------------------------- | 8465| [TimeLapseRecordState](#timelapserecordstate12) | Shooting state. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 8466 8467**Error codes** 8468 8469For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8470 8471| ID | Error Message | 8472| --------------- | --------------- | 8473| 202 | Not System Application. | 8474| 7400103 | Session not config. | 8475 8476**Example** 8477 8478```ts 8479import { BusinessError } from '@kit.BasicServicesKit'; 8480 8481function getTimeLapseRecordState(timeLapsePhotoSession: camera.TimeLapsePhotoSession): camera.TimeLapseRecordState { 8482 let state = camera.TimeLapseRecordState.IDLE; 8483 try { 8484 state = timeLapsePhotoSession.getTimeLapseRecordState(); 8485 } catch (error) { 8486 // If the operation fails, error.code is returned and processed. 8487 let err = error as BusinessError; 8488 console.error(`The getTimeLapseRecordState call failed. error code: ${err.code}`); 8489 } 8490 return state; 8491} 8492``` 8493 8494### setTimeLapseRecordState<sup>12+</sup> 8495 8496setTimeLapseRecordState(state: TimeLapseRecordState): void 8497 8498Sets the time-lapse shooting state. 8499 8500**System API**: This is a system API. 8501 8502**System capability**: SystemCapability.Multimedia.Camera.Core 8503 8504**Parameters** 8505 8506| Name | Type | Mandatory| Description | 8507| -------- | -------------------------------| ---- | ----------------------- | 8508| state | [TimeLapseRecordState](#timelapserecordstate12) | Yes | Shooting state. | 8509 8510**Error codes** 8511 8512For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8513 8514| ID | Error Message | 8515| --------------- | --------------- | 8516| 202 | Not System Application. | 8517| 7400101 | Parameter missing or parameter type incorrect. | 8518| 7400103 | Session not config. | 8519 8520**Example** 8521 8522```ts 8523import { BusinessError } from '@kit.BasicServicesKit'; 8524 8525function setTimeLapseRecordState(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8526 try { 8527 timeLapsePhotoSession.setTimeLapseRecordState(camera.TimeLapseRecordState.RECORDING); 8528 } catch (error) { 8529 // If the operation fails, error.code is returned and processed. 8530 let err = error as BusinessError; 8531 console.error(`The setTimeLapseRecordState call failed. error code: ${err.code}`); 8532 } 8533} 8534``` 8535 8536### getTimeLapsePreviewType<sup>12+</sup> 8537 8538getTimeLapsePreviewType(): TimeLapsePreviewType 8539 8540Obtains the time-lapse preview type. 8541 8542**System API**: This is a system API. 8543 8544**System capability**: SystemCapability.Multimedia.Camera.Core 8545 8546**Return value** 8547 8548| Type | Description | 8549| ---------- | ----------------------------- | 8550| [TimeLapsePreviewType](#timelapsepreviewtype12) | Preview type. If the operation fails, an error code defined in [CameraErrorCode](js-apis-camera.md#cameraerrorcode) is returned.| 8551 8552**Error codes** 8553 8554For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8555 8556| ID | Error Message | 8557| --------------- | --------------- | 8558| 202 | Not System Application. | 8559| 7400103 | Session not config. | 8560 8561**Example** 8562 8563```ts 8564import { BusinessError } from '@kit.BasicServicesKit'; 8565 8566function getTimeLapsePreviewType(timeLapsePhotoSession: camera.TimeLapsePhotoSession): camera.TimeLapsePreviewType { 8567 let type = camera.TimeLapsePreviewType.DARK; 8568 try { 8569 type = timeLapsePhotoSession.getTimeLapsePreviewType(); 8570 } catch (error) { 8571 // If the operation fails, error.code is returned and processed. 8572 let err = error as BusinessError; 8573 console.error(`The getTimeLapsePreviewType call failed. error code: ${err.code}`); 8574 } 8575 return type; 8576} 8577``` 8578 8579### setTimeLapsePreviewType<sup>12+</sup> 8580 8581setTimeLapsePreviewType(type: TimeLapsePreviewType): void 8582 8583Sets the time-lapse preview type. 8584 8585**System API**: This is a system API. 8586 8587**System capability**: SystemCapability.Multimedia.Camera.Core 8588 8589**Parameters** 8590 8591| Name | Type | Mandatory| Description | 8592| -------- | -------------------------------| ---- | ----------------------- | 8593| state | [TimeLapsePreviewType](#timelapsepreviewtype12) | Yes | Preview type. | 8594 8595**Error codes** 8596 8597For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8598 8599| ID | Error Message | 8600| --------------- | --------------- | 8601| 202 | Not System Application. | 8602| 7400101 | Parameter missing or parameter type incorrect. | 8603| 7400103 | Session not config. | 8604 8605**Example** 8606 8607```ts 8608import { BusinessError } from '@kit.BasicServicesKit'; 8609 8610function setTimeLapsePreviewType(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8611 try { 8612 timeLapsePhotoSession.setTimeLapsePreviewType(camera.TimeLapsePreviewType.LIGHT); 8613 } catch (error) { 8614 // If the operation fails, error.code is returned and processed. 8615 let err = error as BusinessError; 8616 console.error(`The setTimeLapsePreviewType call failed. error code: ${err.code}`); 8617 } 8618} 8619``` 8620 8621## LightPaintingPhotoSession<sup>12+</sup> 8622 8623LightPaintingPhotoSession extends Session, Flash, Focus, Zoom, ColorEffect 8624 8625Implements 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). 8626 8627### on('error')<sup>12+</sup> 8628 8629on(type: 'error', callback: ErrorCallback): void 8630 8631Subscribes to **LightPaintingPhotoSession** error events. This API uses an asynchronous callback to return the result. 8632 8633**System API**: This is a system API. 8634 8635**System capability**: SystemCapability.Multimedia.Camera.Core 8636 8637**Parameters** 8638 8639| Name | Type | Mandatory | Description | 8640|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 8641| 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).| 8642| 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). | 8643 8644**Error codes** 8645 8646For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8647 8648| ID| Error Message | 8649|-------|----------------------------| 8650| 202 | Not System Application. | 8651 8652**Example** 8653 8654```ts 8655import { BusinessError } from '@kit.BasicServicesKit'; 8656 8657function callback(err: BusinessError): void { 8658 console.error(`LightPaintingPhotoSession error code: ${err.code}`); 8659} 8660 8661function registerSessionError(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8662 lightPaintingPhotoSession.on('error', callback); 8663} 8664``` 8665 8666### off('error')<sup>12+</sup> 8667 8668off(type: 'error', callback?: ErrorCallback): void 8669 8670Unsubscribes from **LightPaintingPhotoSession** error events. 8671 8672**System API**: This is a system API. 8673 8674**System capability**: SystemCapability.Multimedia.Camera.Core 8675 8676**Parameters** 8677 8678| Name | Type | Mandatory| Description | 8679|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 8680| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. | 8681| 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.| 8682 8683**Error codes** 8684 8685For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8686 8687| ID| Error Message | 8688|-------|----------------------------| 8689| 202 | Not System Application. | 8690 8691**Example** 8692 8693```ts 8694function unregisterSessionError(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8695 lightPaintingPhotoSession.off('error'); 8696} 8697``` 8698 8699### on('focusStateChange')<sup>12+</sup> 8700 8701on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 8702 8703Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 8704 8705**System API**: This is a system API. 8706 8707**System capability**: SystemCapability.Multimedia.Camera.Core 8708 8709**Parameters** 8710 8711| Name | Type | Mandatory| Description | 8712|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 8713| 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.| 8714| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | Yes | Callback used to return the focus state change. | 8715 8716**Error codes** 8717 8718For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8719 8720| ID| Error Message | 8721|-------|----------------------------| 8722| 202 | Not System Application. | 8723 8724**Example** 8725 8726```ts 8727import { BusinessError } from '@kit.BasicServicesKit'; 8728 8729function callback(err: BusinessError, focusState: camera.FocusState): void { 8730 if (err !== undefined && err.code !== 0) { 8731 console.error(`Callback Error, errorCode: ${err.code}`); 8732 return; 8733 } 8734 console.info(`Focus state: ${focusState}`); 8735} 8736 8737function registerFocusStateChange(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8738 lightPaintingPhotoSession.on('focusStateChange', callback); 8739} 8740``` 8741 8742### off('focusStateChange')<sup>12+</sup> 8743 8744off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 8745 8746Unsubscribes from focus state change events. 8747 8748**System API**: This is a system API. 8749 8750**System capability**: SystemCapability.Multimedia.Camera.Core 8751 8752**Parameters** 8753 8754| Name | Type | Mandatory| Description | 8755|-----------|---------------------------------------------|----|--------------------------------------------------------------| 8756| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. | 8757| 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. | 8758 8759**Error codes** 8760 8761For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8762 8763| ID| Error Message | 8764|-------|----------------------------| 8765| 202 | Not System Application. | 8766 8767**Example** 8768 8769```ts 8770function unregisterFocusStateChange(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8771 lightPaintingPhotoSession.off('focusStateChange'); 8772} 8773``` 8774 8775### on('smoothZoomInfoAvailable')<sup>12+</sup> 8776 8777on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 8778 8779Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 8780 8781**System API**: This is a system API. 8782 8783**System capability**: SystemCapability.Multimedia.Camera.Core 8784 8785**Parameters** 8786 8787| Name | Type | Mandatory| Description | 8788| -------- | ----------------------- | ---- | ------------------------ | 8789| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 8790| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 8791 8792**Error codes** 8793 8794For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8795 8796| ID| Error Message | 8797|-------|----------------------------| 8798| 202 | Not System Application. | 8799 8800**Example** 8801 8802```ts 8803import { BusinessError } from '@kit.BasicServicesKit'; 8804 8805function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 8806 if (err !== undefined && err.code !== 0) { 8807 console.error(`Callback Error, errorCode: ${err.code}`); 8808 return; 8809 } 8810 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 8811} 8812 8813function registerSmoothZoomInfo(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8814 lightPaintingPhotoSession.on('smoothZoomInfoAvailable', callback); 8815} 8816``` 8817 8818### off('smoothZoomInfoAvailable')<sup>12+</sup> 8819 8820off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 8821 8822Unsubscribes from smooth zoom state change events. 8823 8824**System API**: This is a system API. 8825 8826**System capability**: SystemCapability.Multimedia.Camera.Core 8827 8828**Parameters** 8829 8830| Name | Type | Mandatory| Description | 8831| -------- | ----------------------------------------- | ---- | ------------------------ | 8832| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 8833| 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.| 8834 8835**Error codes** 8836 8837For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8838 8839| ID| Error Message | 8840|-------|----------------------------| 8841| 202 | Not System Application. | 8842 8843**Example** 8844 8845```ts 8846function unregisterSmoothZoomInfo(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8847 lightPaintingPhotoSession.off('smoothZoomInfoAvailable'); 8848} 8849``` 8850 8851### getLightPaintingType<sup>12+</sup> 8852 8853getLightPaintingType(): LightPaintingType 8854 8855Obtains the type of light painting shutter mode in use. 8856 8857**System API**: This is a system API. 8858 8859**System capability**: SystemCapability.Multimedia.Camera.Core 8860 8861**Return value** 8862| Type | Description | 8863|------------------------------------------------- | --------------------- | 8864| [LightPaintingType](#lightpaintingtype12) | Type of light painting shutter mode. | 8865 8866**Error codes** 8867 8868For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8869 8870| ID | Error Message | 8871| --------------- | --------------- | 8872| 202 | Not System Application. | 8873| 7400103 | Session not config. | 8874 8875**Example** 8876 8877```ts 8878function getLightPaintingType(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): camera.LightPaintingType { 8879 let type: camera.LightPaintingType = lightPaintingPhotoSession.getLightPaintingType(); 8880 return type; 8881} 8882``` 8883 8884### setLightPaintingType<sup>12+</sup> 8885 8886setLightPaintingType(type: LightPaintingType): void 8887 8888Sets the type of light painting shutter mode. 8889 8890**System API**: This is a system API. 8891 8892**System capability**: SystemCapability.Multimedia.Camera.Core 8893 8894**Return value** 8895| Name | Type | Mandatory| Description | 8896| -------- | ----------------------- | ---- | ------------------- | 8897| type | [LightPaintingType](#lightpaintingtype12) | Yes | Type of light painting mode.| 8898 8899**Error codes** 8900 8901For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8902 8903| ID | Error Message | 8904| --------------- | --------------- | 8905| 202 | Not System Application. | 8906| 7400101 | Parameter missing or parameter type incorrect. | 8907| 7400103 | Session not config. | 8908 8909**Example** 8910 8911```ts 8912import { BusinessError } from '@kit.BasicServicesKit'; 8913 8914function setLightPaintingType(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8915 try { 8916 let type: camera.LightPaintingType = camera.LightPaintingType.TRAFFIC_TRAILS; 8917 lightPaintingPhotoSession.setLightPaintingType(type); 8918 } catch (error) { 8919 // If the operation fails, error.code is returned and processed. 8920 let err = error as BusinessError; 8921 console.error(`The setLightPaintingType call failed. error code: ${err.code}`); 8922 } 8923} 8924``` 8925 8926### getSupportedLightPaintingTypes<sup>12+</sup> 8927 8928getSupportedLightPaintingTypes(): Array\<LightPaintingType\> 8929 8930Obtains the supported types of light painting shutter mode. 8931 8932**System API**: This is a system API. 8933 8934**System capability**: SystemCapability.Multimedia.Camera.Core 8935 8936**Return value** 8937| Type | Description | 8938|------------------------------------------------- | --------------------- | 8939| Array\<[LightPaintingType](#lightpaintingtype12)\> | Supported types of light painting shutter mode. | 8940 8941**Error codes** 8942 8943For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8944 8945| ID | Error Message | 8946| --------------- | --------------- | 8947| 202 | Not System Application. | 8948| 7400103 | Session not config. | 8949 8950**Example** 8951 8952```ts 8953function getSupportedLightPaintingTypes(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): Array<camera.LightPaintingType> { 8954 let types: Array<camera.LightPaintingType> = lightPaintingPhotoSession.getSupportedLightPaintingTypes(); 8955 return types 8956} 8957``` 8958