1# @ohos.multimedia.camera (Camera Management) (System API) 2<!--Kit: Camera Kit--> 3<!--Subsystem: Multimedia--> 4<!--Owner: @qano--> 5<!--SE: @leo_ysl--> 6<!--TSE: @xchaosioda--> 7 8The 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. 9 10> **NOTE** 11> 12> - 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. 13> - This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.multimedia.camera (Camera Management)](arkts-apis-camera.md). 14 15## Modules to Import 16 17```ts 18import { camera } from '@kit.CameraKit'; 19``` 20 21## SceneMode<sup>11+</sup> 22 23Enumerates the camera scene modes. 24 25**System capability**: SystemCapability.Multimedia.Camera.Core 26 27| Name | Value | Description | 28| ----------------------- | --------- | ------------ | 29| PORTRAIT_PHOTO | 3 | Portrait photo mode. **System API**: This is a system API. | 30| NIGHT_PHOTO | 4 | Night photo mode. **System API**: This is a system API. | 31| PROFESSIONAL_PHOTO<sup>12+</sup> | 5 | Professional photo mode. **System API**: This is a system API. | 32| PROFESSIONAL_VIDEO<sup>12+</sup> | 6 | Professional video mode. **System API**: This is a system API. | 33| SLOW_MOTION_VIDEO<sup>12+</sup> | 7 | Slow-motion video mode. **System API**: This is a system API. | 34| MACRO_PHOTO<sup>12+</sup> | 8 | Macro photo mode. **System API**: This is a system API. | 35| MACRO_VIDEO<sup>12+</sup> | 9 | Macro video mode. **System API**: This is a system API. | 36| LIGHT_PAINTING_PHOTO<sup>12+</sup> | 10 | Light painting mode. **System API**: This is a system API. | 37| HIGH_RESOLUTION_PHOTO<sup>12+</sup> | 11 | High-resolution photo mode. **System API**: This is a system API. | 38| QUICK_SHOT_PHOTO<sup>12+</sup> | 13 | Quick snap mode. **System API**: This is a system API. | 39| APERTURE_VIDEO<sup>12+</sup> | 14 | Large aperture video mode. **System API**: This is a system API. | 40| PANORAMA_PHOTO<sup>12+</sup> | 15 | Panoramic photo mode. **System API**: This is a system API. | 41| TIME_LAPSE_PHOTO<sup>12+</sup> | 16 | Time-lapse photo mode. **System API**: This is a system API. | 42| FLUORESCENCE_PHOTO<sup>13+</sup> | 17 | Fluorescence photo mode. **System API**: This is a system API. | 43 44## SlowMotionStatus<sup>12+</sup> 45 46Enumerates the slow-motion states. 47 48**System capability**: SystemCapability.Multimedia.Camera.Core 49 50| Name | Value | Description | 51|----------------|-----|---------------| 52| DISABLED | 0 | Disabled. | 53| READY | 1 | Ready. | 54| VIDEO_START | 2 | Video start. | 55| VIDEO_DONE | 3 | Video complete. | 56| FINISHED | 4 | Finished. | 57 58## LcdFlashStatus<sup>12+</sup> 59 60Describes the LCD flash information. 61 62**System API**: This is a system API. 63 64**System capability**: SystemCapability.Multimedia.Camera.Core 65 66| Name | Type | Read-only| Optional | Description | 67| -------- | ----------------------------- |---- |-----| ------------- | 68| isLcdFlashNeeded | boolean | Yes | No | Whether the LCD flash is required. **true** if required, **false** otherwise. | 69| lcdCompensation | number | Yes | No | LCD flash compensation. | 70 71## Photo<sup>11+</sup> 72 73Defines a higher-resolution image object. 74 75**System API**: This is a system API. 76 77**System capability**: SystemCapability.Multimedia.Camera.Core 78 79| Name | Type | Read-only | Optional | Description| 80| ------ | ----------------------------- |-----| ---------- | ---------- | 81| raw<sup>12+</sup> | [image.Image](../apis-image-kit/arkts-apis-image-Image.md)| NA | Yes | Raw image.| 82 83## ExposureMode 84 85Enumerates the exposure modes. 86 87**System API**: This is a system API. 88 89**System capability**: SystemCapability.Multimedia.Camera.Core 90 91| Name | Value | Description | 92| ----------------------------- |-----|---------| 93| EXPOSURE_MODE_MANUAL<sup>12+</sup> | 3 | Manual exposure mode.| 94 95## PolicyType<sup>12+</sup> 96 97Enumerates the policy types. 98 99**System API**: This is a system API. 100 101**System capability**: SystemCapability.Multimedia.Camera.Core 102 103| Name | Value | Description | 104| ----------------------------- |-----|---------| 105| PRIVACY<sup>12+</sup> | 1 | Privacy.| 106 107## LightPaintingType<sup>12+</sup> 108 109Enumerates the types of light painting shutter modes. 110 111**System API**: This is a system API. 112 113**System capability**: SystemCapability.Multimedia.Camera.Core 114 115| Name | Value | Description | 116| ----------------------------- |-----|---------| 117| TRAFFIC_TRAILS | 0 | Traffic trails.| 118| STAR_TRAILS | 1 | Star trails.| 119| SILKY_WATER | 2 | Silky water.| 120| LIGHT_GRAFFITI | 3 | Light graffiti.| 121 122## CameraManager 123 124Implements camera management. Before calling any API in CameraManager, you must use [getCameraManager](arkts-apis-camera-f.md#cameragetcameramanager) to obtain a CameraManager instance. 125 126### createDepthDataOutput<sup>13+</sup> 127 128createDepthDataOutput(profile: DepthProfile): DepthDataOutput 129 130Creates a DepthDataOutput instance. This API returns the result synchronously. 131 132**System API**: This is a system API. 133 134**System capability**: SystemCapability.Multimedia.Camera.Core 135 136**Parameters** 137 138| Name | Type | Mandatory| Description | 139| -------- | ----------------------------------------------- | ---- | ------------------------------- | 140| profile | [DepthProfile](#depthprofile13) | Yes | Supported preview profile, which is obtained through [getSupportedOutputCapability](arkts-apis-camera-CameraManager.md#getsupportedoutputcapability11).| 141 142**Return value** 143 144| Type | Description | 145| ---------- | ----------------------------- | 146| [DepthDataOutput](#depthdataoutput13) | DepthDataOutput instance. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 147 148**Error codes** 149 150For details about the error codes, see [Camera Error Codes](errorcode-camera.md) and [Universal Error Codes](../errorcode-universal.md). 151 152| ID | Error Message | 153| --------------- | --------------- | 154| 202 | Not System Application. | 155| 7400101 | Parameter missing or parameter type incorrect. | 156| 7400201 | Camera service fatal error. | 157 158**Example** 159 160```ts 161import { BusinessError } from '@kit.BasicServicesKit'; 162 163function createDepthDataOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager): camera.DepthDataOutput | undefined { 164 let profile: camera.DepthProfile = cameraOutputCapability.depthProfiles[0]; 165 let depthDataOutput: camera.DepthDataOutput | undefined = undefined; 166 try { 167 depthDataOutput = cameraManager.createDepthDataOutput(profile); 168 } catch (error) { 169 // If the operation fails, error.code is returned and processed. 170 let err = error as BusinessError; 171 console.error(`The createDepthDataOutput call failed. error code: ${err.code}`); 172 } 173 return depthDataOutput; 174} 175``` 176 177### isCameraMuteSupported 178 179isCameraMuteSupported(): boolean 180 181Checks whether the camera device can be muted. 182 183**System API**: This is a system API. 184 185**System capability**: SystemCapability.Multimedia.Camera.Core 186 187**Return value** 188 189| Type | Description | 190| ---------- | ----------------------------- | 191| boolean | Check result for whether the camera device can be muted. **true** if it can be muted, **false** otherwise.| 192 193**Error codes** 194 195For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 196 197| ID | Error Message | 198| --------------- | --------------- | 199| 202 | Permission verification failed. A non-system application calls a system API. | 200 201**Example** 202 203```ts 204function isCameraMuteSupported(cameraManager: camera.CameraManager): boolean { 205 let isMuteSupported: boolean = cameraManager.isCameraMuteSupported(); 206 return isMuteSupported; 207} 208``` 209 210### muteCamera 211 212muteCamera(mute: boolean): void 213 214Mutes or unmutes the camera device. 215 216> **NOTE** 217> 218> This API is supported since API version 10 and deprecated since API version 12. You are advised to use [muteCameraPersistent](#mutecamerapersistent12) instead. 219 220**System API**: This is a system API. 221 222**System capability**: SystemCapability.Multimedia.Camera.Core 223 224**Parameters** 225 226| Name | Type | Mandatory | Description | 227| -------- | --------------------------------- | ---- | ---------- | 228| mute | boolean | Yes | Whether to mute the camera device. **true** to mute, **false** otherwise. | 229 230**Example** 231 232```ts 233function muteCamera(cameraManager: camera.CameraManager): void { 234 let mute: boolean = true; 235 cameraManager.muteCamera(mute); 236} 237``` 238 239### muteCameraPersistent<sup>12+</sup> 240 241muteCameraPersistent(mute: boolean, type: PolicyType): void 242 243Mutes the camera device permanently. 244 245**System API**: This is a system API. 246 247**System capability**: SystemCapability.Multimedia.Camera.Core 248 249**Parameters** 250 251| Name | Type | Mandatory | Description | 252| -------- |-----------------------------| ---- |--------------------------------------------| 253| mute | boolean | Yes | Whether to mute the camera device. **true** to mute, **false** otherwise. | 254| type | [PolicyType](#policytype12) | Yes | Policy type. For details about the available options, see [PolicyType](#policytype12).| 255 256**Error codes** 257 258For details about the error codes, see [Camera Error Codes](errorcode-camera.md) and [Universal Error Codes](../errorcode-universal.md). 259 260| ID | Error Message | 261| --------------- | --------------- | 262| 201 | Permission denied. | 263| 202 | Not System Application. | 264| 7400101 | Parameter missing or parameter type incorrect. | 265 266**Example** 267 268```ts 269function muteCameraPersistent(cameraManager: camera.CameraManager): void { 270 let mute: boolean = true; 271 cameraManager.muteCameraPersistent(mute, camera.PolicyType.PRIVACY); 272} 273``` 274 275### on('cameraMute') 276 277on(type: 'cameraMute', callback: AsyncCallback\<boolean\>): void 278 279Subscribes to camera mute status events. This API uses an asynchronous callback to return the result. 280 281**System API**: This is a system API. 282 283**System capability**: SystemCapability.Multimedia.Camera.Core 284 285**Parameters** 286 287| Name | Type | Mandatory| Description | 288| -------- | --------------- | ---- | --------- | 289| 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.| 290| callback | AsyncCallback\<boolean> | Yes | Callback used to return the camera mute status. **true** if muted, **false** otherwise. | 291 292**Example** 293 294```ts 295import { BusinessError } from '@kit.BasicServicesKit'; 296 297function callback(err: BusinessError, curMuted: boolean): void { 298 if (err !== undefined && err.code !== 0) { 299 console.error(`Callback Error, errorCode: ${err.code}`); 300 return; 301 } 302 let isMuted: boolean = curMuted; 303 console.info(`cameraMute status: ${isMuted}`); 304} 305 306function registerCameraMute(cameraManager: camera.CameraManager): void { 307 cameraManager.on('cameraMute', callback); 308} 309``` 310 311### off('cameraMute') 312 313off(type: 'cameraMute', callback?: AsyncCallback\<boolean\>): void 314 315Unsubscribes from camera mute status events. 316 317**System API**: This is a system API. 318 319**System capability**: SystemCapability.Multimedia.Camera.Core 320 321**Parameters** 322 323| Name | Type | Mandatory| Description | 324| -------- | --------------- | ---- |---------------------------------------------------------| 325| 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.| 326| callback | AsyncCallback\<boolean> | No | Callback used to return the camera mute status. **true** if muted, **false** otherwise. 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.) | 327 328**Example** 329 330```ts 331import { BusinessError } from '@kit.BasicServicesKit'; 332 333function callback(err: BusinessError, curMuted: boolean): void { 334 let isMuted: boolean = curMuted; 335} 336 337function unregisterCameraMute(cameraManager: camera.CameraManager): void { 338 cameraManager.off('cameraMute', callback); 339} 340``` 341 342### isPrelaunchSupported 343 344isPrelaunchSupported(camera: CameraDevice): boolean 345 346Checks whether a camera device supports prelaunch. 347 348**System API**: This is a system API. 349 350**System capability**: SystemCapability.Multimedia.Camera.Core 351 352**Parameters** 353 354| Name | Type | Mandatory| Description | 355| -------- |--------------------------------------------------| ---- | --------- | 356| camera | [CameraDevice](arkts-apis-camera-i.md#cameradevice) | Yes| Camera device.| 357 358**Return value** 359 360| Type| Description| 361| -------- | --------------- | 362| boolean | Check result for the support of prelaunch. **true** if supported, **false** otherwise.| 363 364**Error codes** 365 366For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 367 368| ID | Error Message | 369| --------------- | --------------- | 370| 202 | Not System Application. | 371| 7400101 | Parameter missing or parameter type incorrect. | 372 373**Example** 374 375```ts 376import { common } from '@kit.AbilityKit'; 377 378function isPreLaunchSupported(context: common.BaseContext): boolean { 379 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 380 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 381 let isSupported: boolean = false; 382 if (cameras && cameras.length >= 1) { 383 isSupported = cameraManager.isPrelaunchSupported(cameras[0]); 384 console.info(`PreLaunch supported states: ${isSupported}`); 385 return isSupported; 386 } 387 return isSupported; 388} 389``` 390 391### setPrelaunchConfig 392 393setPrelaunchConfig(prelaunchConfig: PrelaunchConfig): void 394 395Sets prelaunch configuration. 396 397Before the setting, call [isPrelaunchSupported](#isprelaunchsupported) to check whether the camera device supports prelaunch. 398 399**System API**: This is a system API. 400 401**Required permissions**: ohos.permission.CAMERA 402 403**System capability**: SystemCapability.Multimedia.Camera.Core 404 405**Parameters** 406 407| Name | Type | Mandatory| Description | 408| -------- | --------------- | ---- | --------- | 409| prelaunchConfig | [PrelaunchConfig](#prelaunchconfig) | Yes| Prelaunch configuration.| 410 411**Error codes** 412 413For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 414 415| ID | Error Message | 416| --------------- | --------------- | 417| 202 | Not System Application. | 418| 7400101 | Parameter missing or parameter type incorrect. | 419| 7400102 | Operation not allowed. | 420| 7400201 | Camera service fatal error. | 421 422**Example** 423 424```ts 425import { common } from '@kit.AbilityKit'; 426import { BusinessError } from '@kit.BasicServicesKit'; 427 428function setPrelaunchConfig(context: common.BaseContext): void { 429 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 430 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 431 if (cameras && cameras.length >= 1) { 432 let cameraDevice: camera.CameraDevice = cameras[0]; 433 if(cameraManager.isPrelaunchSupported(cameraDevice)) { 434 try { 435 cameraManager.setPrelaunchConfig({cameraDevice: cameraDevice}); 436 } catch (error) { 437 let err = error as BusinessError; 438 console.error(`setPrelaunchConfig error. Code: ${err.code}, message: ${err.message}`); 439 } 440 } 441 } 442} 443``` 444 445### prelaunch 446 447prelaunch(): void 448 449Prelaunches the camera device. This API is called when a user clicks the system camera icon to start the camera application. 450 451**System API**: This is a system API. 452 453**System capability**: SystemCapability.Multimedia.Camera.Core 454 455**Error codes** 456 457For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 458 459| ID | Error Message | 460| --------------- | --------------- | 461| 202 | Not System Application. | 462 463**Example** 464 465```ts 466import { common } from '@kit.AbilityKit'; 467import { BusinessError } from '@kit.BasicServicesKit'; 468 469function preLaunch(context: common.BaseContext): void { 470 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 471 try { 472 cameraManager.prelaunch(); 473 } catch (error) { 474 let err = error as BusinessError; 475 console.error(`prelaunch error. Code: ${err.code}, message: ${err.message}`); 476 } 477} 478``` 479 480### createDeferredPreviewOutput 481 482createDeferredPreviewOutput(profile?: Profile): PreviewOutput 483 484Creates a deferred PreviewOutput instance and adds it, instead of a common PreviewOutput instance, to the data stream during stream configuration. 485 486**System API**: This is a system API. 487 488**System capability**: SystemCapability.Multimedia.Camera.Core 489 490**Parameters** 491 492| Name | Type | Mandatory| Description | 493| -------- | --------------- | ---- | --------- | 494| profile | [Profile](arkts-apis-camera-i.md#profile) | No| Configuration file of the camera preview stream.| 495 496**Return value** 497 498| Type| Description| 499| -------- | --------------- | 500| [PreviewOutput](#previewoutput) | PreviewOutput instance obtained.| 501 502**Error codes** 503 504For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 505 506| ID | Error Message | 507| --------------- | --------------- | 508| 202 | Not System Application. | 509| 7400101 | Parameter missing or parameter type incorrect. | 510 511**Example** 512 513```ts 514import { common } from '@kit.AbilityKit'; 515 516function getDeferredPreviewOutput(context: common.BaseContext, previewProfile: camera.Profile): camera.PreviewOutput { 517 const cameraManager: camera.CameraManager = camera.getCameraManager(context); 518 const output: camera.PreviewOutput = cameraManager.createDeferredPreviewOutput(previewProfile); 519 return output; 520} 521``` 522 523### preSwitchCamera<sup>11+</sup> 524 525preSwitchCamera(cameraId: string): void 526 527Pre-switches a camera device to speed up its startup. 528 529**System API**: This is a system API. 530 531**System capability**: SystemCapability.Multimedia.Camera.Core 532 533**Parameters** 534 535| Name | Type | Mandatory| Description | 536| -------- | --------------- | ---- | --------- | 537| cameraId | string | Yes| Camera ID.| 538 539**Error codes** 540 541For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 542 543| ID | Error Message | 544| ------- |------------------------------------------------| 545| 202 | Not System Application. | 546| 7400101 | Parameter missing or parameter type incorrect. | 547| 7400201 | Camera service fatal error. | 548 549**Example** 550 551```ts 552import { common } from '@kit.AbilityKit'; 553import { BusinessError } from '@kit.BasicServicesKit'; 554 555function preSwitch(cameraDevice: camera.CameraDevice, context: common.BaseContext): void { 556 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 557 try { 558 cameraManager.preSwitchCamera(cameraDevice.cameraId); 559 } catch (error) { 560 let err = error as BusinessError; 561 console.error(`prelaunch error. Code: ${err.code}, message: ${err.message}`); 562 } 563} 564``` 565 566## CameraOcclusionDetectionResult<sup>12+</sup> 567Describes the status indicating whether the camera is occluded. 568 569**System API**: This is a system API. 570 571**System capability**: SystemCapability.Multimedia.Camera.Core 572 573| Name | Type | Read-only| Optional| Description | 574| ----------------------------- | --------------------------------------------------- | ---- | ---- |-------------------| 575| isCameraOccluded | boolean | Yes | No|Whether the camera is occluded. **true** if occluded, **false** otherwise. | 576 577## CameraOutputCapability<sup>13+</sup> 578 579Describes the camera output capability. 580 581**System API**: This is a system API. 582 583**System capability**: SystemCapability.Multimedia.Camera.Core 584 585| Name | Type | Read-only| Optional| Description | 586| ----------------------------- | --------------------------------------------------- | ---- | ---- |-------------------| 587| depthProfiles | Array\<[DepthProfile](#depthprofile13)\> | Yes | No| Supported depth stream profiles. | 588 589## CameraFormat 590 591Enumerates the camera output formats. 592 593**System API**: This is a system API. 594 595**System capability**: SystemCapability.Multimedia.Camera.Core 596 597| Name | Value | Description | 598| ----------------------- | --------- | ------------ | 599| CAMERA_FORMAT_DEPTH_16<sup>13+</sup> | 3000 | Depth map in DEPTH_16 format. | 600| CAMERA_FORMAT_DEPTH_32<sup>13+</sup> | 3001 | Depth map in DEPTH_32 format. | 601 602## CameraInput 603 604Defines the camera input object. 605 606It provides camera device information used in [Session](arkts-apis-camera-Session.md). 607 608### on('cameraOcclusionDetection')<sup>12+</sup> 609 610on(type: 'cameraOcclusionDetection', callback: AsyncCallback\<CameraOcclusionDetectionResult\>): void 611 612Subscribes to CameraInput occlusion events. This API uses an asynchronous callback to return the result. 613 614**System capability**: SystemCapability.Multimedia.Camera.Core 615 616**Parameters** 617 618| Name | Type | Mandatory| Description | 619| -------- | -------------------------------- | --- | ------------------------------------------- | 620| 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.| 621| callback | AsyncCallback\<[CameraOcclusionDetectionResult](#cameraocclusiondetectionresult12)\> | Yes | Callback used to return the occlusion status. | 622 623**Example** 624 625```ts 626import { BusinessError } from '@kit.BasicServicesKit'; 627 628function callback(err: BusinessError, CameraOcclusionDetectionResult: camera.CameraOcclusionDetectionResult): void { 629 if (err !== undefined && err.code !== 0) { 630 console.error('cameraOcclusionDetection with errorCode = ' + err.code); 631 return; 632 } 633 console.info(`isCameraOccluded : ${CameraOcclusionDetectionResult.isCameraOccluded}`); 634} 635 636function registerCameraOcclusionDetection(cameraInput: camera.CameraInput): void { 637 cameraInput.on('cameraOcclusionDetection', callback); 638} 639``` 640 641### off('cameraOcclusionDetection')<sup>12+</sup> 642 643off(type: 'cameraOcclusionDetection', callback?: AsyncCallback\<CameraOcclusionDetectionResult\>): void 644 645Unsubscribes from CameraInput occlusion events. 646 647**System capability**: SystemCapability.Multimedia.Camera.Core 648 649**Parameters** 650 651| Name | Type | Mandatory| Description | 652| -------- | --------------- | ---- |---------------------------------------------------------| 653| type | string | Yes | Event type. The value is fixed at **'cameraOcclusionDetection'**. The event can be listened for when a CameraInput instance is created.| 654| 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.) | 655 656**Example** 657 658```ts 659import { BusinessError } from '@kit.BasicServicesKit'; 660 661function callback(err: BusinessError, CameraOcclusionDetectionResult: camera.CameraOcclusionDetectionResult): void { 662 if (err !== undefined && err.code !== 0) { 663 console.error('cameraOcclusionDetection with errorCode = ' + err.code); 664 return; 665 } 666 console.info(`isCameraOccluded : ${CameraOcclusionDetectionResult.isCameraOccluded}`); 667} 668 669function unregisterCameraOcclusionDetection(cameraInput: camera.CameraInput): void { 670 cameraInput.off('cameraOcclusionDetection', callback); 671} 672``` 673 674## DepthDataAccuracy<sup>13+</sup> 675 676Describes the accuracy of depth data. 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| DEPTH_DATA_ACCURACY_RELATIVE | number | Yes | No| Relative accuracy, which is the depth map calculated based on the disparity. | 685| DEPTH_DATA_ACCURACY_ABSOLUTE | number | Yes | No| Absolute accuracy, which is the depth map calculated from distance measurement. | 686 687## DepthProfile<sup>13+</sup> 688 689Describes the profile of depth data. It inherits from [Profile](arkts-apis-camera-i.md#profile). 690 691**System API**: This is a system API. 692 693**System capability**: SystemCapability.Multimedia.Camera.Core 694 695| Name | Type | Read-only| Optional| Description | 696| ------------------------- | ----------------------------------------- | --- | ---- |----------- | 697| depthDataAccuracy | [DepthDataAccuracy](#depthdataaccuracy13) | Yes | No | Accuracy of the depth data, which can be either relative accuracy or absolute accuracy.| 698 699## DepthDataQualityLevel<sup>13+</sup> 700 701Enumerates the quality levels of depth data. 702 703**System API**: This is a system API. 704 705**System capability**: SystemCapability.Multimedia.Camera.Core 706 707| Name | Type | Read-only| Optional| Description | 708| -------- | ----------------------------- |----- |---| -------------- | 709| DEPTH_DATA_QUALITY_BAD | number | Yes | No| The depth map is of poor quality and cannot be used for blurring. | 710| DEPTH_DATA_QUALITY_FAIR | number | Yes | No| The depth map is of average quality and cannot be used for high-quality blurring. | 711| DEPTH_DATA_QUALITY_GOOD | number | Yes | No| The depth map is of high quality and can be used for high-quality blurring. | 712 713## DepthData<sup>13+</sup> 714 715Describes a depth data object. 716 717### Properties 718 719**System API**: This is a system API. 720 721**System capability**: SystemCapability.Multimedia.Camera.Core 722 723| Name | Type | Read-only| Optional| Description | 724| -------- | ----------------------------- |----- |---| -------------- | 725| format | [CameraFormat](#cameraformat) | Yes| No | Camera output format.| 726| depthMap | [image.PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md) | Yes| No | Depth map.| 727| qualityLevel | [DepthDataQualityLevel](#depthdataqualitylevel13) | Yes| No | Quality level of the depth map.| 728| accuracy | [DepthDataAccuracy](#depthdataaccuracy13) | Yes| No | Accuracy of the depth map.| 729 730### release<sup>13+</sup> 731 732release(): void 733 734Releases depth data output resources. 735 736**System API**: This is a system API. 737 738**System capability**: SystemCapability.Multimedia.Camera.Core 739 740**Example** 741 742```ts 743async function releaseDepthData(depthData: camera.DepthData): Promise<void> { 744 await depthData.release(); 745} 746``` 747 748## DepthDataOutput<sup>13+</sup> 749 750Implements depth data output. It inherits from [CameraOutput](arkts-apis-camera-CameraOutput.md). 751 752### start<sup>13+</sup> 753 754start(): Promise\<void\> 755 756Starts a depth data output stream. This API uses a promise to return the result. 757 758**System API**: This is a system API. 759 760**System capability**: SystemCapability.Multimedia.Camera.Core 761 762**Return value** 763 764| Type | Description | 765| -------------- | ----------------------- | 766| Promise\<void\> | Promise that returns no value.| 767 768**Error codes** 769 770For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 771 772| ID | Error Message | 773| --------------- | --------------- | 774| 7400103 | Session not config. | 775| 7400201 | Camera service fatal error. | 776 777**Example** 778 779```ts 780import { BusinessError } from '@kit.BasicServicesKit'; 781 782function startDepthDataOutput(depthDataOutput: camera.DepthDataOutput): void { 783 depthDataOutput.start().then(() => { 784 console.info('Promise returned to indicate that start method execution success.'); 785 }).catch((error: BusinessError) => { 786 console.error(`Failed to depth data output start, error code: ${error.code}.`); 787 }); 788} 789``` 790 791### stop<sup>13+</sup> 792 793stop(): Promise\<void\> 794 795Stops a depth data output stream. This API uses a promise to return the result. 796 797**System API**: This is a system API. 798 799**System capability**: SystemCapability.Multimedia.Camera.Core 800 801**Return value** 802 803| Type | Description | 804| -------------- | ----------------------- | 805| Promise\<void\> | Promise that returns no value.| 806 807**Example** 808 809```ts 810import { BusinessError } from '@kit.BasicServicesKit'; 811 812function stopDepthDataOutput(depthDataOutput: camera.DepthDataOutput): void { 813 depthDataOutput.stop().then(() => { 814 console.info('Promise returned to indicate that stop method execution success.'); 815 }).catch((error: BusinessError) => { 816 console.error(`Failed to depth data output stop, error code: ${error.code}.`); 817 }); 818} 819``` 820 821### on('depthDataAvailable')<sup>13+</sup> 822 823on(type: 'depthDataAvailable', callback: AsyncCallback\<DepthData\>): void 824 825Subscribes to depth data availability events. This API uses an asynchronous callback to return the result. 826 827> **NOTE** 828> 829> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**. 830 831**System API**: This is a system API. 832 833**System capability**: SystemCapability.Multimedia.Camera.Core 834 835**Parameters** 836 837| Name | Type | Mandatory| Description | 838| -------- | ---------- | --- | ------------------------------------ | 839| type | string | Yes | Event type. The value is fixed at **'depthDataAvailable'**. The event can be listened for when a depthDataOutput instance is created.| 840| callback | AsyncCallback\<[DepthData](#depthdata13)\> | Yes | Callback used to listen for depth data.| 841 842**Example** 843 844```ts 845import { BusinessError } from '@kit.BasicServicesKit'; 846 847function callback(err: BusinessError, depthData: camera.DepthData): void { 848 if (err !== undefined && err.code !== 0) { 849 console.error(`Callback Error, errorCode: ${err.code}`); 850 return; 851 } 852} 853 854function registerDepthDataAvailable(depthDataOutput: camera.DepthDataOutput): void { 855 depthDataOutput.on('depthDataAvailable', callback); 856} 857``` 858 859### off('depthDataAvailable')<sup>13+</sup> 860 861off(type: 'depthDataAvailable', callback?: AsyncCallback\<DepthData\>): void 862 863Unsubscribes from depth data availability events. 864 865**System API**: This is a system API. 866 867**System capability**: SystemCapability.Multimedia.Camera.Core 868 869**Parameters** 870 871| Name | Type | Mandatory| Description | 872| -------- | ---------------------- | ---- | ------------------------------------------ | 873| type | string | Yes | Event type. The value is fixed at **'depthDataAvailable'**. The event can be listened for when a depthDataOutput instance is created.| 874| callback | AsyncCallback\<[DepthData](#depthdata13)\> | 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.| 875 876**Example** 877 878```ts 879import { BusinessError } from '@kit.BasicServicesKit'; 880 881function callback(err: BusinessError, depthData: camera.DepthData): void { 882 if (err !== undefined && err.code !== 0) { 883 console.error(`Callback Error, errorCode: ${err.code}`); 884 return; 885 } 886} 887 888function unRegisterDepthDataAvailable(depthDataOutput: camera.DepthDataOutput): void { 889 depthDataOutput.off('depthDataAvailable', callback); 890} 891``` 892 893### on('error')<sup>13+</sup> 894 895on(type: 'error', callback: ErrorCallback): void 896 897Subscribes to DepthDataOutput error events. This API uses an asynchronous callback to return the result. 898 899> **NOTE** 900> 901> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**. 902 903**System API**: This is a system API. 904 905**System capability**: SystemCapability.Multimedia.Camera.Core 906 907**Parameters** 908 909| Name | Type | Mandatory| Description | 910| -------- | --------------| ---- | ------------------------ | 911| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a depthDataOutput instance is created.| 912| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes | Callback used to return an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode). | 913 914**Example** 915 916```ts 917import { BusinessError } from '@kit.BasicServicesKit'; 918 919function callback(depthDataOutputError: BusinessError): void { 920 console.error(`Depth data output error code: ${depthDataOutputError.code}`); 921} 922 923function registerDepthDataOutputError(depthDataOutput: camera.DepthDataOutput): void { 924 depthDataOutput.on('error', callback); 925} 926``` 927 928### off('error')<sup>13+</sup> 929 930off(type: 'error', callback?: ErrorCallback): void 931 932Unsubscribes from DepthDataOutput error events. 933 934**System API**: This is a system API. 935 936**System capability**: SystemCapability.Multimedia.Camera.Core 937 938**Parameters** 939 940| Name | Type | Mandatory| Description | 941| -------- | --------------| ---- | ------------------------ | 942| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a depthDataOutput instance is created.| 943| 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.| 944 945**Example** 946 947```ts 948function unregisterDepthDataOutputError(depthDataOutput: camera.DepthDataOutput): void { 949 depthDataOutput.off('error'); 950} 951``` 952 953## DepthFusionQuery<sup>14+</sup> 954 955A class for querying depth fusion capabilities. 956 957### isDepthFusionSupported<sup>14+</sup> 958 959isDepthFusionSupported(): boolean 960 961Checks whether depth fusion is supported. 962 963**System API**: This is a system API. 964 965**System capability**: SystemCapability.Multimedia.Camera.Core 966 967**Return value** 968 969| Type | Description | 970| -------------- | ----------------------- | 971| boolean | Check result for the support of depth fusion. **true** if supported, **false** otherwise.| 972 973**Error codes** 974 975For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Camera Error Codes](errorcode-camera.md). 976 977| ID | Error Message | 978| --------------- | --------------- | 979| 202 | Not System Application. | 980| 7400103 | Session not config, only throw in session usage. | 981 982**Example** 983```ts 984import { BusinessError } from '@kit.BasicServicesKit'; 985 986function isDepthFusionSupported(DepthFusionQuery: camera.DepthFusionQuery): void { 987 try { 988 let isSupperted: boolean = DepthFusionQuery.isDepthFusionSupported(); 989 console.info('Promise returned to indicate that isDepthFusionSupported method execution success.'); 990 } catch (error) { 991 let err = error as BusinessError; 992 console.error(`Failed to depth fusion query isDepthFusionSupported, error code: ${err.code}.`); 993 } 994} 995 996``` 997### getDepthFusionThreshold<sup>14+</sup> 998 999getDepthFusionThreshold(): Array\<number\> 1000 1001Obtains the depth fusion threshold. 1002 1003**System API**: This is a system API. 1004 1005**System capability**: SystemCapability.Multimedia.Camera.Core 1006 1007**Return value** 1008 1009| Type | Description | 1010| -------------- | ----------------------- | 1011| Array\<number\> | Depth fusion threshold. | 1012 1013**Error codes** 1014 1015For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Camera Error Codes](errorcode-camera.md). 1016 1017| ID | Error Message | 1018| --------------- | --------------- | 1019| 202 | Not System Application. | 1020| 7400103 | Session not config, only throw in session usage. | 1021 1022**Example** 1023```ts 1024import { BusinessError } from '@kit.BasicServicesKit'; 1025 1026function getDepthFusionThreshold(DepthFusionQuery: camera.DepthFusionQuery): void { 1027 try { 1028 let threshold: Array<number> = DepthFusionQuery.getDepthFusionThreshold(); 1029 console.info('Promise returned to indicate that getDepthFusionThreshold method execution success.'); 1030 } catch (error) { 1031 let err = error as BusinessError; 1032 console.error(`Failed to depth fusion query getDepthFusionThreshold, error code: ${err.code}.`); 1033 } 1034} 1035``` 1036## DepthFusion<sup>14+</sup> 1037 1038Depth fusion class. It inherits from [DepthFusionQuery](js-apis-camera-sys.md#depthfusionquery14). 1039 1040### isDepthFusionEnabled<sup>14+</sup> 1041 1042isDepthFusionEnabled(): boolean 1043 1044Checks whether depth fusion is enabled. 1045 1046**System API**: This is a system API. 1047 1048**System capability**: SystemCapability.Multimedia.Camera.Core 1049 1050**Return value** 1051 1052| Type | Description | 1053| -------------- | ----------------------- | 1054| boolean | Check result for whether depth fusion is enabled. **true** if enabled, **false** otherwise.| 1055 1056**Error codes** 1057 1058For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Camera Error Codes](errorcode-camera.md). 1059 1060| ID | Error Message | 1061| --------------- | --------------- | 1062| 202 | Not System Application. | 1063| 7400103 | Session not config. | 1064 1065**Example** 1066```ts 1067import { BusinessError } from '@kit.BasicServicesKit'; 1068 1069function isDepthFusionEnabled(DepthFusion: camera.DepthFusion): void { 1070 try { 1071 let isEnable: boolean = DepthFusion.isDepthFusionEnabled(); 1072 console.info('Promise returned to indicate that isDepthFusionEnabled method execution success.'); 1073 } catch (error) { 1074 let err = error as BusinessError; 1075 console.error(`Failed to depth fusion isDepthFusionEnabled, error code: ${err.code}.`); 1076 }; 1077} 1078``` 1079 1080### enableDepthFusion<sup>14+</sup> 1081 1082enableDepthFusion(enabled: boolean): void 1083 1084Enables depth fusion. 1085 1086**System API**: This is a system API. 1087 1088**System capability**: SystemCapability.Multimedia.Camera.Core 1089 1090**Parameters** 1091 1092| Name | Type | Mandatory| Description | 1093| -------- | ---------- | --- | ------------------------------------ | 1094| enabled | boolean | Yes | Whether to enable depth fusion. **true** to enable, **false** otherwise.| 1095 1096**Error codes** 1097 1098For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Camera Error Codes](errorcode-camera.md). 1099 1100| ID | Error Message | 1101|---------|------------------------------------------------| 1102| 202 | Not System Application. | 1103| 7400101 | Parameter missing or parameter type incorrect. | 1104| 7400103 | Session not config. | 1105| 7400201 | Camera service fatal error. | 1106 1107**Example** 1108```ts 1109import { BusinessError } from '@kit.BasicServicesKit'; 1110 1111function enableDepthFusion(DepthFusion: camera.DepthFusion): void { 1112 try { 1113 let enabled: boolean = true; 1114 DepthFusion.enableDepthFusion(enabled); 1115 console.info('Promise returned to indicate that enableDepthFusion method execution success.'); 1116 } catch (error) { 1117 let err = error as BusinessError; 1118 console.error(`Failed to depth fusion enableDepthFusion, error code: ${err.code}.`); 1119 }; 1120} 1121``` 1122 1123## PrelaunchConfig 1124 1125Defines the camera prelaunch configuration. 1126 1127Currently, the configuration is used for sensor-level prelaunch. It will be used for stream-level prelaunch in a later version. 1128 1129**System API**: This is a system API. 1130 1131**System capability**: SystemCapability.Multimedia.Camera.Core 1132 1133| Name | Type | Read-only | Mandatory | Description | 1134| ------------------------------- |--------------------------------------------------| ----------- | ------------ | ---------- | 1135| cameraDevice | [CameraDevice](arkts-apis-camera-i.md#cameradevice) | No | Yes | Camera device. | 1136| restoreParamType<sup>11+</sup> | [RestoreParamType](#restoreparamtype11) | No | No | Type of the parameter used for prelaunch. | 1137| activeTime<sup>11+</sup> | number | No | No | Activation time, in minutes.| 1138| settingParam<sup>11+</sup> | [SettingParam](#settingparam11) | No | No | Setting parameter. | 1139 1140## RestoreParamType<sup>11+</sup> 1141 1142Enumerates the types of the parameters used for prelaunch. 1143 1144**System API**: This is a system API. 1145 1146**System capability**: SystemCapability.Multimedia.Camera.Core 1147 1148| Name | Value | Description | 1149| ----------------| ---- | ---------| 1150| NO_NEED_RESTORE_PARAM | 0 | The parameter used for prelaunch is not required. | 1151| PRESISTENT_DEFAULT_PARAM | 1 | Persistent parameter type. This parameter is used to restore stream information with the specified time point. | 1152| 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. | 1153 1154## SettingParam<sup>11+</sup> 1155 1156Defines the effect parameters used to preheat an image. 1157 1158**System API**: This is a system API. 1159 1160**System capability**: SystemCapability.Multimedia.Camera.Core 1161 1162| Name | Type | Read-only | Optional | Description | 1163| --------------- | ------ | --------- |-----|---------------------------------------------------------------------------------------------------| 1164| skinSmoothLevel | number | No | No | Skin smoothing level, which is obtained through [Beauty.getSupportedBeautyRange](#getsupportedbeautyrange11). For example, the value **1** indicates level-1 smoothing. | 1165| faceSlender | number | No | No | Face slimming level, which is obtained through [Beauty.getSupportedBeautyRange](#getsupportedbeautyrange11). For example, the value **1** indicates level-1 slimming. | 1166| skinTone | number | No | No | Skin tone perfection level, which is obtained through [Beauty.getSupportedBeautyRange](#getsupportedbeautyrange11). For example, the value **0xBF986C** indicates a specific color.| 1167 1168## PreviewOutput 1169 1170Implements preview output. It inherits from [CameraOutput](arkts-apis-camera-CameraOutput.md). 1171 1172### addDeferredSurface 1173 1174addDeferredSurface(surfaceId: string): void 1175 1176Adds a surface for delayed preview. This API can run after [Session.commitConfig](arkts-apis-camera-Session.md#commitconfig11-1) or [Session.start](arkts-apis-camera-Session.md#start11-1) is called. 1177 1178**System API**: This is a system API. 1179 1180**System capability**: SystemCapability.Multimedia.Camera.Core 1181 1182**Parameters** 1183 1184| Name | Type | Mandatory| Description | 1185| -------- | --------------| ---- | ------------------------ | 1186| surfaceId | string | Yes| Surface ID, which is obtained from [XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md).| 1187 1188**Error codes** 1189 1190For details about the error codes, see [Camera Error Codes](errorcode-camera.md) and [Universal Error Codes](../errorcode-universal.md). 1191 1192| ID | Error Message | 1193| --------------- | --------------- | 1194| 202 | Permission verification failed. A non-system application calls a system API. | 1195| 7400101 | Parameter missing or parameter type incorrect. | 1196 1197**Example** 1198 1199```ts 1200import { common } from '@kit.AbilityKit'; 1201 1202async function preview(context: common.BaseContext, cameraDevice: camera.CameraDevice, previewProfile: camera.Profile, photoProfile: camera.Profile, mode: camera.SceneMode, previewSurfaceId: string): Promise<void> { 1203 const cameraManager: camera.CameraManager = camera.getCameraManager(context); 1204 const cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameraDevice); 1205 const previewOutput: camera.PreviewOutput = cameraManager.createDeferredPreviewOutput(previewProfile); 1206 const photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 1207 const session: camera.Session = cameraManager.createSession(mode); 1208 session.beginConfig(); 1209 session.addInput(cameraInput); 1210 session.addOutput(previewOutput); 1211 session.addOutput(photoOutput); 1212 await session.commitConfig(); 1213 await session.start(); 1214 previewOutput.addDeferredSurface(previewSurfaceId); 1215} 1216``` 1217 1218### isSketchSupported<sup>11+</sup> 1219 1220isSketchSupported(): boolean 1221 1222Checks whether Picture-in-Picture (PiP) preview is supported. 1223 1224**System API**: This is a system API. 1225 1226**System capability**: SystemCapability.Multimedia.Camera.Core 1227 1228**Return value** 1229 1230| Type | Description | 1231| -------------- | ----------------------- | 1232| boolean | Check result for the support of the PiP preview. **true** if supported, **false** otherwise.| 1233 1234**Error codes** 1235 1236For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1237 1238| ID | Error Message | 1239| --------------- |-------------------------| 1240| 202 | Not System Application. | 1241 1242**Example** 1243 1244```ts 1245import { BusinessError } from '@kit.BasicServicesKit'; 1246 1247function isSketchSupported(previewOutput: camera.PreviewOutput): boolean { 1248 try { 1249 let isSupported: boolean = previewOutput.isSketchSupported(); 1250 return isSupported; 1251 } catch (error) { 1252 // If the operation fails, error.code is returned and processed. 1253 let err = error as BusinessError; 1254 console.error(`The isSketchSupported call failed. error code: ${err.code}`); 1255 } 1256 return false; 1257} 1258``` 1259 1260### getSketchRatio<sup>11+</sup> 1261 1262getSketchRatio(): number 1263 1264Obtains the zoom ratio when PiP preview is enabled. 1265 1266**System API**: This is a system API. 1267 1268**System capability**: SystemCapability.Multimedia.Camera.Core 1269 1270**Return value** 1271 1272| Type | Description | 1273| -------------- | ----------------------- | 1274| number | Zoom ratio obtained. If PiP preview is not supported, the value **-1** is returned.| 1275 1276**Error codes** 1277 1278For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1279 1280| ID | Error Message | 1281| --------------- | --------------- | 1282| 7400103 | Session not config. | 1283| 202 | Not System Application. | 1284 1285**Example** 1286 1287```ts 1288function getSketchRatio(previewOutput: camera.PreviewOutput): number { 1289 let sketchRatio: number = previewOutput.getSketchRatio(); 1290 return sketchRatio; 1291} 1292``` 1293 1294### enableSketch<sup>11+</sup> 1295 1296enableSketch(enabled: boolean): void 1297 1298Enables or disables PiP preview. 1299 1300**System API**: This is a system API. 1301 1302**System capability**: SystemCapability.Multimedia.Camera.Core 1303 1304**Parameters** 1305 1306| Name | Type | Mandatory| Description | 1307|---------|---------| ---- | ------------------------ | 1308| enabled | boolean | Yes| Whether to enable or disable PiP view. **true** to enable, **false** otherwise.| 1309 1310**Error codes** 1311 1312For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1313 1314| ID | Error Message | 1315|-----------|-----------------------------| 1316| 202 | Not System Application. | 1317| 7400102 | Operation not allowed. | 1318| 7400103 | Session not config. | 1319| 7400201 | Camera service fatal error. | 1320 1321**Example** 1322 1323```ts 1324import { BusinessError } from '@kit.BasicServicesKit'; 1325 1326function enableSketch(previewOutput: camera.PreviewOutput, session: camera.Session, cameraInput: camera.CameraInput): void { 1327 try { 1328 session.beginConfig(); 1329 session.addInput(cameraInput); 1330 session.addOutput(previewOutput); 1331 previewOutput.enableSketch(true); 1332 session.commitConfig(); 1333 } catch (error) { 1334 // If the operation fails, error.code is returned and processed. 1335 let err = error as BusinessError; 1336 console.error(`The enableSketch call failed. error code: ${err.code}`); 1337 } 1338} 1339``` 1340 1341### attachSketchSurface<sup>11+</sup> 1342 1343attachSketchSurface(surfaceId: string): void 1344 1345Attaches a surface for PiP preview. 1346 1347**System API**: This is a system API. 1348 1349**System capability**: SystemCapability.Multimedia.Camera.Core 1350 1351**Parameters** 1352 1353| Name | Type | Mandatory| Description | 1354| -------- | --------------| ---- | ------------------------ | 1355| surfaceId | string | Yes| Surface ID, which is obtained from [XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md).| 1356 1357**Error codes** 1358 1359For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1360 1361| ID | Error Message | 1362|---------|------------------------------------------------| 1363| 202 | Not System Application. | 1364| 7400101 | Parameter missing or parameter type incorrect. | 1365| 7400103 | Session not config. | 1366| 7400201 | Camera service fatal error. | 1367 1368**Example** 1369 1370```ts 1371import { BusinessError } from '@kit.BasicServicesKit'; 1372 1373function attachSketchSurface(previewOutput: camera.PreviewOutput, session: camera.Session, cameraInput: camera.CameraInput, sketchSurfaceId: string): void { 1374 try { 1375 session.beginConfig(); 1376 session.addInput(cameraInput); 1377 session.addOutput(previewOutput); 1378 previewOutput.enableSketch(true); 1379 session.commitConfig(); 1380 previewOutput.attachSketchSurface(sketchSurfaceId); 1381 } catch (error) { 1382 // If the operation fails, error.code is returned and processed. 1383 let err = error as BusinessError; 1384 console.error(`The attachSketchSurface call failed. error code: ${err.code}`); 1385 } 1386} 1387``` 1388 1389### on('sketchStatusChanged')<sup>11+</sup> 1390 1391on(type: 'sketchStatusChanged', callback: AsyncCallback\<SketchStatusData\>): void 1392 1393Subscribes to PiP status change events. This API uses an asynchronous callback to return the result. 1394 1395**System API**: This is a system API. 1396 1397**System capability**: SystemCapability.Multimedia.Camera.Core 1398 1399**Parameters** 1400 1401| Name | Type | Mandatory| Description | 1402| -------- | ---------------------- | ---- | ------------------------------------------ | 1403| 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.| 1404| callback | AsyncCallback\<[SketchStatusData](#sketchstatusdata11)\> | Yes | Callback used to return the PiP status data. | 1405 1406**Error codes** 1407 1408For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1409 1410| ID | Error Message | 1411|---------|-------------------------------| 1412| 202 | Not System Application. | 1413 1414**Example** 1415 1416```ts 1417import { BusinessError } from '@kit.BasicServicesKit'; 1418 1419function callback(error: BusinessError, data: camera.SketchStatusData): void { 1420 if (error !== undefined && error.code !== 0) { 1421 console.error(`Callback Error, errorCode: ${error.code}`); 1422 return; 1423 } 1424 console.info(`sketch errorCode is ${error.code}, data is ${JSON.stringify(data)}`); 1425} 1426 1427function registerSketchStatusChanged(previewOutput: camera.PreviewOutput): void { 1428 previewOutput.on('sketchStatusChanged', callback); 1429} 1430``` 1431 1432### off('sketchStatusChanged')<sup>11+</sup> 1433 1434off(type: 'sketchStatusChanged', callback?: AsyncCallback\<SketchStatusData\>): void 1435 1436Unsubscribes from PiP status change events. 1437 1438**System API**: This is a system API. 1439 1440**System capability**: SystemCapability.Multimedia.Camera.Core 1441 1442**Parameters** 1443 1444| Name | Type | Mandatory| Description | 1445| -------- | ---------------------- | ---- | ------------------------------------------ | 1446| type | string | Yes | Event type. The value is fixed at **'sketchStatusChanged'**. The event can be listened for when a PiP preview stream is created.| 1447| 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.) | 1448 1449**Error codes** 1450 1451For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1452 1453| ID | Error Message | 1454|---------|-------------------------------| 1455| 202 | Not System Application. | 1456 1457**Example** 1458 1459```ts 1460function unregisterSketchStatusChanged(previewOutput: camera.PreviewOutput): void { 1461 previewOutput.off('sketchStatusChanged'); 1462} 1463``` 1464 1465## DeferredDeliveryImageType<sup>11+</sup> 1466 1467Enumerates 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. 1468 1469**System API**: This is a system API. 1470 1471**System capability**: SystemCapability.Multimedia.Camera.Core 1472 1473| Name | Value | Description | 1474| ------- | ---- | ------------ | 1475| NONE | 0 | Deferred delivery is not supported.| 1476| PHOTO | 1 | Deferred delivery for photo capture.| 1477| VIDEO | 2 | Deferred delivery for video capture.| 1478 1479## DeferredPhotoProxy<sup>11+</sup> 1480 1481A class object that functions as a thumbnail proxy. 1482 1483### getThumbnail<sup>11+</sup> 1484 1485getThumbnail(): Promise<image.PixelMap> 1486 1487Obtains the PixelMap of a thumbnail. 1488 1489**System API**: This is a system API. 1490 1491**System capability**: SystemCapability.Multimedia.Camera.Core 1492 1493**Return value** 1494 1495| Type | Description | 1496| -------------- | ----------------------- | 1497| Promise\<image.PixelMap\> | PixelMap of the thumbnail.| 1498 1499**Error codes** 1500 1501For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1502 1503| ID | Error Message | 1504| --------------- | --------------- | 1505| 202 | Not System Application. | 1506 1507**Example** 1508 1509```ts 1510import { image } from '@kit.ImageKit'; 1511 1512function getThumbnail(proxyObj: camera.DeferredPhotoProxy): void { 1513 proxyObj.getThumbnail().then((thumbnail: image.PixelMap) => { 1514 AppStorage.setOrCreate('proxyThumbnail', thumbnail); 1515 }); 1516} 1517``` 1518 1519### release<sup>11+</sup> 1520 1521release(): Promise\<void\> 1522 1523Releases output resources. This API uses a promise to return the result. 1524 1525**System API**: This is a system API. 1526 1527**System capability**: SystemCapability.Multimedia.Camera.Core 1528 1529**Return value** 1530 1531| Type | Description | 1532| -------------- |------------------| 1533| Promise\<void\> | Promise that returns no value.| 1534 1535**Error codes** 1536 1537For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1538 1539| ID | Error Message | 1540| --------------- | --------------- | 1541| 202 | Not System Application. | 1542 1543**Example** 1544 1545```ts 1546async function releaseDeferredPhotoProxy(proxyObj: camera.DeferredPhotoProxy): Promise<void> { 1547 await proxyObj.release(); 1548} 1549``` 1550 1551## PhotoOutput 1552 1553Implements output information used in a photo session. It inherits from [CameraOutput](arkts-apis-camera-CameraOutput.md). 1554 1555### burstCapture<sup>12+</sup> 1556 1557burstCapture(setting: PhotoCaptureSetting): Promise\<void\> 1558 1559Starts 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. 1560 1561**System API**: This is a system API. 1562 1563**System capability**: SystemCapability.Multimedia.Camera.Core 1564 1565**Parameters** 1566 1567| Name | Type | Mandatory| Description | 1568| ------- | ------------------------------------------- | ---- | -------- | 1569| setting | [PhotoCaptureSetting](arkts-apis-camera-i.md#photocapturesetting) | Yes | Shooting parameters. The input of **undefined** is processed as if no parameters were passed.| 1570 1571**Return value** 1572 1573| Type | Description | 1574| -------------- | ------------------------ | 1575| Promise\<void\> | Promise that returns no value.| 1576 1577**Error codes** 1578 1579For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1580 1581| ID | Error Message | 1582| --------------- | --------------- | 1583| 202 | Not System Application. | 1584| 7400101 | Parameter missing or parameter type incorrect. | 1585| 7400104 | Session not running. | 1586| 7400201 | Camera service fatal error. | 1587 1588**Example** 1589 1590```ts 1591import { BusinessError } from '@kit.BasicServicesKit'; 1592 1593function burstCapture(photoOutput: camera.PhotoOutput): void { 1594 let captureLocation: camera.Location = { 1595 latitude: 0, 1596 longitude: 0, 1597 altitude: 0 1598 } 1599 let settings: camera.PhotoCaptureSetting = { 1600 quality: camera.QualityLevel.QUALITY_LEVEL_LOW, 1601 rotation: camera.ImageRotation.ROTATION_0, 1602 location: captureLocation, 1603 mirror: false 1604 } 1605 photoOutput.burstCapture(settings).then(() => { 1606 console.info('Promise returned to indicate that photo burstCapture request success.'); 1607 }).catch((error: BusinessError) => { 1608 console.error(`Failed to photo output burstCapture, error code: ${error.code}.`); 1609 }); 1610} 1611``` 1612 1613### confirmCapture<sup>11+</sup> 1614 1615confirmCapture() 1616 1617Confirms 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. 1618 1619This API is used to end the burst mode, which is started by calling [burstCapture](#burstcapture12). 1620 1621**System API**: This is a system API. 1622 1623**System capability**: SystemCapability.Multimedia.Camera.Core 1624 1625**Error codes** 1626 1627For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1628 1629| ID | Error Message | 1630| --------------- | --------------- | 1631| 202 | Not System Application. | 1632| 7400104 | Session not running. | 1633| 7400201 | Camera service fatal error. | 1634 1635**Example** 1636 1637```ts 1638import { BusinessError } from '@kit.BasicServicesKit'; 1639 1640function confirmCapture(photoOutput: camera.PhotoOutput): void { 1641 try { 1642 photoOutput.confirmCapture(); 1643 } catch (error) { 1644 let err = error as BusinessError; 1645 console.error(`The confirmCapture call failed. error code: ${err.code}`); 1646 } 1647} 1648``` 1649 1650### isDeferredImageDeliverySupported<sup>11+</sup> 1651 1652isDeferredImageDeliverySupported(type: DeferredDeliveryImageType): boolean 1653 1654Checks whether deferred delivery of a certain type is supported. 1655 1656**System API**: This is a system API. 1657 1658**System capability**: SystemCapability.Multimedia.Camera.Core 1659 1660**Parameters** 1661 1662| Name | Type | Mandatory| Description | 1663| -------- | -------------------- | ---- | ------------------- | 1664| type | [DeferredDeliveryImageType](#deferreddeliveryimagetype11) | Yes | Deferred delivery image type. | 1665 1666**Return value** 1667 1668| Type | Description | 1669| -------------- | ----------------------- | 1670| boolean | Check result for the support of deferred delivery. **true** if supported, **false** otherwise.| 1671 1672**Error codes** 1673 1674For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1675 1676| ID | Error Message | 1677| --------------- |-----------------------------------------------------| 1678| 7400101 | Parameter missing or parameter type incorrect. | 1679| 7400104 | Session not running. | 1680| 7400201 | Camera service fatal error. | 1681| 202 | Not System Application. | 1682 1683**Example** 1684 1685```ts 1686function isDeferredImageDeliverySupported(photoOutput: camera.PhotoOutput, type: camera.DeferredDeliveryImageType): boolean { 1687 let res: boolean = false; 1688 res = photoOutput.isDeferredImageDeliverySupported(type); 1689 return res; 1690} 1691``` 1692 1693### isDeferredImageDeliveryEnabled<sup>11+</sup> 1694 1695isDeferredImageDeliveryEnabled(type: DeferredDeliveryImageType): boolean 1696 1697Checks whether deferred delivery of a certain type is enabled. 1698 1699**System API**: This is a system API. 1700 1701**System capability**: SystemCapability.Multimedia.Camera.Core 1702 1703**Parameters** 1704 1705| Name | Type | Mandatory| Description | 1706| -------- | -------------------- | ---- | ------------------- | 1707| type | [DeferredDeliveryImageType](#deferreddeliveryimagetype11) | Yes | Deferred delivery image type. | 1708 1709**Return value** 1710 1711| Type | Description | 1712| -------------- | ----------------------- | 1713| boolean | Check result for whether deferred delivery is enabled. **true** if enabled, **false** otherwise.| 1714 1715**Error codes** 1716 1717For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1718 1719| ID | Error Message | 1720| --------------- | --------------- | 1721| 7400101 | Parameter missing or parameter type incorrect. | 1722| 7400104 | Session not running. | 1723| 7400201 | Camera service fatal error. | 1724| 202 | Not System Application. | 1725 1726**Example** 1727 1728```ts 1729function isDeferredImageDeliveryEnabled(photoOutput: camera.PhotoOutput, type: camera.DeferredDeliveryImageType): boolean { 1730 let res: boolean = false; 1731 res = photoOutput.isDeferredImageDeliveryEnabled(type); 1732 return res; 1733} 1734``` 1735 1736### deferImageDelivery<sup>11+</sup> 1737 1738deferImageDelivery(type: DeferredDeliveryImageType): void 1739 1740Enables deferred delivery of a certain type. 1741 1742**System API**: This is a system API. 1743 1744**System capability**: SystemCapability.Multimedia.Camera.Core 1745 1746**Parameters** 1747 1748| Name | Type | Mandatory| Description | 1749| -------- | -------------------- | ---- | ------------------- | 1750| type | [DeferredDeliveryImageType](#deferreddeliveryimagetype11) | Yes | Deferred delivery image type. | 1751 1752**Error codes** 1753 1754For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1755 1756| ID | Error Message | 1757| --------------- | --------------- | 1758| 7400101 | Parameter missing or parameter type incorrect. | 1759| 7400104 | Session not running. | 1760| 7400201 | Camera service fatal error. | 1761| 202 | Not System Application. | 1762 1763**Example** 1764 1765```ts 1766function deferImageDelivery(photoOutput: camera.PhotoOutput, type: camera.DeferredDeliveryImageType): void { 1767 photoOutput.deferImageDelivery(type); 1768} 1769``` 1770 1771### isAutoHighQualityPhotoSupported<sup>13+</sup> 1772 1773isAutoHighQualityPhotoSupported(): boolean 1774 1775Checks whether automatic high quality is supported for photos. 1776 1777**System API**: This is a system API. 1778 1779**System capability**: SystemCapability.Multimedia.Camera.Core 1780 1781**Return value** 1782 1783| Type | Description | 1784| -------------- | ----------------------- | 1785| boolean | Check result for whether automatic high quality is supported. **true** if supported, **false** otherwise.| 1786 1787**Error codes** 1788 1789For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1790 1791| ID | Error Message | 1792| --------------- | --------------- | 1793| 202 | Not System Application. | 1794| 7400104 | Session not running. | 1795| 7400201 | Camera service fatal error. | 1796 1797**Example** 1798 1799```ts 1800import { BusinessError } from '@kit.BasicServicesKit'; 1801 1802function isAutoHighQualityPhotoSupported(photoOutput: camera.PhotoOutput): boolean { 1803 return photoOutput.isAutoHighQualityPhotoSupported(); 1804} 1805``` 1806 1807### enableAutoHighQualityPhoto<sup>13+</sup> 1808 1809enableAutoHighQualityPhoto(enabled: boolean): void 1810 1811Enables automatic high quality for photos. 1812 1813Before using this API, call [isAutoHighQualityPhotoSupported](#isautohighqualityphotosupported13) to check whether automatic high quality is supported. 1814 1815**System API**: This is a system API. 1816 1817**System capability**: SystemCapability.Multimedia.Camera.Core 1818 1819**Parameters** 1820 1821| Name | Type | Mandatory| Description | 1822| -------- | -------------------- | ---- | ------------------- | 1823| enabled | boolean | Yes | Whether to enable or disable automatic high quality for photos. **true** to enable, **false** otherwise. | 1824 1825**Error codes** 1826 1827For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1828 1829| ID | Error Message | 1830| --------------- | --------------- | 1831| 202 | Not System Application. | 1832| 7400101 | Parameter missing or parameter type incorrect. | 1833| 7400104 | Session not running. | 1834| 7400201 | Camera service fatal error. | 1835 1836**Example** 1837 1838```ts 1839import { BusinessError } from '@kit.BasicServicesKit'; 1840 1841function enableAutoHighQualityPhoto(photoOutput: camera.PhotoOutput): void { 1842 return photoOutput.enableAutoHighQualityPhoto(true); 1843} 1844``` 1845 1846### on('deferredPhotoProxyAvailable')<sup>11+</sup> 1847 1848on(type: 'deferredPhotoProxyAvailable', callback: AsyncCallback\<DeferredPhotoProxy\>): void 1849 1850Subscribes to events indicating available thumbnail proxies. This API uses an asynchronous callback to return the result. 1851 1852**System API**: This is a system API. 1853 1854**System capability**: SystemCapability.Multimedia.Camera.Core 1855 1856**Parameters** 1857 1858| Name | Type | Mandatory| Description | 1859| -------- | ---------- | --- | ------------------------------------ | 1860| type | string | Yes | Event type. The value is fixed at **'deferredPhotoProxyAvailable'**. The event can be listened for when a photoOutput instance is created.| 1861| callback | AsyncCallback\<[DeferredPhotoProxy](#deferredphotoproxy11)\> | Yes | Callback used to return the thumbnail proxy.| 1862 1863**Error codes** 1864 1865For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1866 1867| ID | Error Message | 1868| --------------- | --------------- | 1869| 202 | Not System Application. | 1870 1871**Example** 1872 1873```ts 1874import { BusinessError } from '@kit.BasicServicesKit'; 1875import { image } from '@kit.ImageKit'; 1876 1877function callback(err: BusinessError, proxyObj: camera.DeferredPhotoProxy): void { 1878 if (err !== undefined && err.code !== 0) { 1879 console.error(`Callback Error, errorCode: ${err.code}`); 1880 return; 1881 } 1882 proxyObj.getThumbnail().then((thumbnail: image.PixelMap) => { 1883 AppStorage.setOrCreate('proxyThumbnail', thumbnail); 1884 }); 1885} 1886 1887function registerPhotoOutputDeferredPhotoProxyAvailable(photoOutput: camera.PhotoOutput): void { 1888 photoOutput.on('deferredPhotoProxyAvailable', callback); 1889} 1890``` 1891 1892### off('deferredPhotoProxyAvailable')<sup>11+</sup> 1893 1894off(type: 'deferredPhotoProxyAvailable', callback?: AsyncCallback\<DeferredPhotoProxy\>): void 1895 1896Unsubscribes from events indicating available thumbnail proxies. 1897 1898**System API**: This is a system API. 1899 1900**System capability**: SystemCapability.Multimedia.Camera.Core 1901 1902**Parameters** 1903 1904| Name | Type | Mandatory| Description | 1905| -------- | ---------------------- | ---- | ------------------------------------------ | 1906| type | string | Yes | Event type. The value is fixed at **'deferredPhotoProxyAvailable'**. The event can be listened for when a photoOutput instance is created.| 1907| 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.) | 1908 1909**Error codes** 1910 1911For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1912 1913| ID | Error Message | 1914| --------------- | --------------- | 1915| 202 | Not System Application. | 1916 1917**Example** 1918 1919```ts 1920import { BusinessError } from '@kit.BasicServicesKit'; 1921import { image } from '@kit.ImageKit'; 1922 1923function callback(err: BusinessError, proxyObj: camera.DeferredPhotoProxy): void { 1924 proxyObj.getThumbnail().then((thumbnail: image.PixelMap) => { 1925 AppStorage.setOrCreate('proxyThumbnail', thumbnail); 1926 }); 1927} 1928 1929function unRegisterPhotoOutputDeferredPhotoProxyAvailable(photoOutput: camera.PhotoOutput): void { 1930 photoOutput.off('deferredPhotoProxyAvailable', callback); 1931} 1932``` 1933 1934### isQuickThumbnailSupported 1935 1936isQuickThumbnailSupported(): boolean 1937 1938Checks whether the quick thumbnail feature is supported. 1939 1940This API takes effect after [addOutput](arkts-apis-camera-Session.md#addoutput11) and [addInput](arkts-apis-camera-Session.md#addinput11) and before [commitConfig](arkts-apis-camera-Session.md#commitconfig11-1). 1941 1942**System API**: This is a system API. 1943 1944**System capability**: SystemCapability.Multimedia.Camera.Core 1945 1946**Return value** 1947 1948| Type| Description| 1949| --------- | ------ | 1950| boolean | Check result for the support of the quick thumbnail feature. **true** if supported, **false** otherwise.| 1951 1952**Error codes** 1953 1954For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1955 1956| ID | Error Message | 1957| --------------- | --------------- | 1958| 202 | Not System Application. | 1959| 7400104 | session is not running. | 1960 1961**Example** 1962 1963```ts 1964import { common } from '@kit.AbilityKit'; 1965 1966async function isQuickThumbnailSupported(context: common.BaseContext, mode: camera.SceneMode, photoProfile: camera.Profile): Promise<boolean> { 1967 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 1968 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 1969 // Create a CaptureSession instance. 1970 let session: camera.Session = cameraManager.createSession(mode); 1971 // Start configuration for the session. 1972 session.beginConfig(); 1973 // Add a CameraInput instance to the session. 1974 let cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameras[0]); 1975 await cameraInput.open(); 1976 session.addInput(cameraInput); 1977 // Add a PhotoOutput instance to the session. 1978 let photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 1979 session.addOutput(photoOutput); 1980 let isSupported: boolean = photoOutput.isQuickThumbnailSupported(); 1981 return isSupported; 1982} 1983``` 1984 1985### enableQuickThumbnail 1986 1987enableQuickThumbnail(enabled: boolean): void 1988 1989Enables or disables the quick thumbnail feature. 1990 1991This API takes effect after [addOutput](arkts-apis-camera-Session.md#addoutput11) and [addInput](arkts-apis-camera-Session.md#addinput11) and before [commitConfig](arkts-apis-camera-Session.md#commitconfig11-1). 1992 1993**System API**: This is a system API. 1994 1995**System capability**: SystemCapability.Multimedia.Camera.Core 1996 1997**Parameters** 1998 1999| Name | Type | Mandatory| Description | 2000| -------- | ------------- | ---- | ----------------------------------- | 2001| enabled | boolean | Yes | Whether to enable the quick thumbnail feature. **true** to enable, **false** otherwise.| 2002 2003**Error codes** 2004 2005For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2006 2007| ID | Error Message | 2008| --------------- | --------------- | 2009| 202 | Not System Application. | 2010| 7400101 | Parameter missing or parameter type incorrect. | 2011| 7400104 | session is not running. | 2012| 7400201 | Camera service fatal error. | 2013 2014**Example** 2015 2016```ts 2017import { common } from '@kit.AbilityKit'; 2018import { BusinessError } from '@kit.BasicServicesKit'; 2019 2020async function enableQuickThumbnail(context: common.BaseContext, mode: camera.SceneMode, photoProfile: camera.Profile): Promise<void> { 2021 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 2022 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 2023 // Create a CaptureSession instance. 2024 let session: camera.Session = cameraManager.createSession(mode); 2025 // Start configuration for the session. 2026 session.beginConfig(); 2027 // Add a CameraInput instance to the session. 2028 let cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameras[0]); 2029 await cameraInput.open(); 2030 session.addInput(cameraInput); 2031 // Add a PhotoOutput instance to the session. 2032 let photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 2033 session.addOutput(photoOutput); 2034 let isSupported: boolean = photoOutput.isQuickThumbnailSupported(); 2035 if (!isSupported) { 2036 console.info('Quick Thumbnail is not supported to be turned on.'); 2037 return; 2038 } 2039 try { 2040 photoOutput.enableQuickThumbnail(true); 2041 } catch (error) { 2042 let err = error as BusinessError; 2043 console.error(`The enableQuickThumbnail call failed. error code: ${err.code}`); 2044 } 2045} 2046``` 2047 2048### on('quickThumbnail') 2049 2050on(type: 'quickThumbnail', callback: AsyncCallback\<image.PixelMap>): void 2051 2052Subscribes to quick thumbnail output events. This API uses an asynchronous callback to return the result. 2053 2054The listening takes effect after **enableQuickThumbnail(true)** is called. 2055 2056**System API**: This is a system API. 2057 2058**System capability**: SystemCapability.Multimedia.Camera.Core 2059 2060**Parameters** 2061 2062| Name | Type | Mandatory| Description | 2063| -------- | ------------- | ---- | ----------------------------------- | 2064| type | string | Yes | Event type. The value is fixed at **'quickThumbnail'**.| 2065| callback | AsyncCallback\<[image.PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md)> | Yes| Callback that returns a PixelMap instance.| 2066 2067**Example** 2068 2069```ts 2070import { common } from '@kit.AbilityKit'; 2071import { BusinessError } from '@kit.BasicServicesKit'; 2072import { image } from '@kit.ImageKit'; 2073 2074function callback(err: BusinessError, pixelMap: image.PixelMap): void { 2075 if (err || pixelMap === undefined) { 2076 console.error('photoOutput on thumbnail failed'); 2077 return; 2078 } 2079 // Display or save the PixelMap instance. 2080 // do something. 2081} 2082 2083async function registerQuickThumbnail(context: common.BaseContext, mode: camera.SceneMode, photoProfile: camera.Profile): Promise<void> { 2084 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 2085 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 2086 // Create a CaptureSession instance. 2087 let session: camera.Session = cameraManager.createSession(mode); 2088 // Start configuration for the session. 2089 session.beginConfig(); 2090 // Add a CameraInput instance to the session. 2091 let cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameras[0]); 2092 await cameraInput.open(); 2093 session.addInput(cameraInput); 2094 // Add a PhotoOutput instance to the session. 2095 let photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 2096 session.addOutput(photoOutput); 2097 let isSupported: boolean = photoOutput.isQuickThumbnailSupported(); 2098 if (!isSupported) { 2099 console.info('Quick Thumbnail is not supported to be turned on.'); 2100 return; 2101 } 2102 try { 2103 photoOutput.enableQuickThumbnail(true); 2104 } catch (error) { 2105 let err = error as BusinessError; 2106 console.error(`The enableQuickThumbnail call failed. error code: ${err.code}`); 2107 } 2108 2109 photoOutput.on('quickThumbnail', callback); 2110} 2111``` 2112 2113### off('quickThumbnail') 2114 2115off(type: 'quickThumbnail', callback?: AsyncCallback\<image.PixelMap>): void 2116 2117Unsubscribes from quick thumbnail output events. 2118 2119**System API**: This is a system API. 2120 2121**System capability**: SystemCapability.Multimedia.Camera.Core 2122 2123**Parameters** 2124 2125| Name | Type | Mandatory| Description | 2126| -------- | ------------- | ---- | ----------------------------------- | 2127| type | string | Yes | Event type. The value is fixed at **'quickThumbnail'**.| 2128| callback | AsyncCallback\<[image.PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md)> | 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.)| 2129 2130**Example** 2131 2132```ts 2133function unregisterQuickThumbnail(photoOutput: camera.PhotoOutput): void { 2134 photoOutput.off('quickThumbnail'); 2135} 2136``` 2137 2138## MetadataOutput 2139 2140Implements metadata streams. It inherits from [CameraOutput](arkts-apis-camera-CameraOutput.md). 2141 2142### addMetadataObjectTypes<sup>13+</sup> 2143 2144addMetadataObjectTypes(types: Array\<MetadataObjectType\>): void 2145 2146Adds the types of metadata objects to be detected. 2147 2148**System capability**: SystemCapability.Multimedia.Camera.Core 2149 2150**Parameters** 2151 2152| Name | Type | Mandatory| Description | 2153| -------------------- | -------------------------------------------------- | --- | ---------------------------- | 2154| metadataObjectTypes | Array\<[MetadataObjectType](#metadataobjecttype)\> | Yes | Metadata object types, which are obtained through **getSupportedOutputCapability**.| 2155 2156**Error codes** 2157 2158For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2159 2160| ID | Error Message | 2161| --------------- | --------------- | 2162| 202 | Not system application. | 2163| 7400101 | Parameter missing or parameter type incorrect. | 2164| 7400103 | Session not config. | 2165| 7400201 | Camera service fatal error. | 2166 2167**Example** 2168 2169```ts 2170import { BusinessError } from '@kit.BasicServicesKit'; 2171 2172function addMetadataObjectTypes(metadataOutput: camera.MetadataOutput, types: Array<camera.MetadataObjectType>): void { 2173 try { 2174 metadataOutput.addMetadataObjectTypes(types); 2175 } catch (error) { 2176 // If the operation fails, error.code is returned and processed. 2177 let err = error as BusinessError; 2178 console.error(`addMetadataObjectTypes error. error code: ${err.code}`); 2179 } 2180} 2181``` 2182 2183### removeMetadataObjectTypes<sup>13+</sup> 2184 2185removeMetadataObjectTypes(types: Array\<MetadataObjectType\>): void 2186 2187Removes the types of metadata objects to be detected. 2188 2189**System capability**: SystemCapability.Multimedia.Camera.Core 2190 2191**Parameters** 2192 2193| Name | Type | Mandatory| Description | 2194| -------------------- | -------------------------------------------------- | --- | ---------------------------- | 2195| metadataObjectTypes | Array\<[MetadataObjectType](#metadataobjecttype)\> | Yes | Metadata object types, which are obtained through **getSupportedOutputCapability**.| 2196 2197**Error codes** 2198 2199For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2200 2201| ID | Error Message | 2202| --------------- | --------------- | 2203| 202 | Not system application. | 2204| 7400101 | Parameter missing or parameter type incorrect. | 2205| 7400103 | Session not config. | 2206| 7400201 | Camera service fatal error. | 2207 2208**Example** 2209 2210```ts 2211import { BusinessError } from '@kit.BasicServicesKit'; 2212 2213function removeMetadataObjectTypes(metadataOutput: camera.MetadataOutput, types: Array<camera.MetadataObjectType>): void { 2214 try { 2215 metadataOutput.removeMetadataObjectTypes(types); 2216 } catch (error) { 2217 // If the operation fails, error.code is returned and processed. 2218 let err = error as BusinessError; 2219 console.error(`removeMetadataObjectTypes error. error code: ${err.code}`); 2220 } 2221} 2222``` 2223 2224## MetadataObjectType 2225 2226Enumerates the types of metadata objects used for camera detection. 2227 2228**System capability**: SystemCapability.Multimedia.Camera.Core 2229 2230| Name | Value | Description | 2231| -------------------------- | ---- | ----------------- | 2232| HUMAN_BODY<sup>13+</sup> | 1 | Metadata object used for human body detection.| 2233| CAT_FACE<sup>13+</sup> | 2 | Metadata object used for cat face detection.| 2234| CAT_BODY<sup>13+</sup> | 3 | Metadata object used for cat body detection.| 2235| DOG_FACE<sup>13+</sup> | 4 | Metadata object used for dog face detection.| 2236| DOG_BODY<sup>13+</sup> | 5 | Metadata object used for dog body detection.| 2237| SALIENT_DETECTION<sup>13+</sup> | 6 | Metadata object used for salient detection.| 2238 2239## Emotion<sup>13+</sup> 2240Enumerates the types of emotions in the detected human face information. 2241 2242**System capability**: SystemCapability.Multimedia.Camera.Core 2243 2244| Name | Value | Description | 2245| -------------------------- | ---- | ----------------- | 2246| NEUTRAL | 0 | Quiet and calm.| 2247| SADNESS | 1 | Sad.| 2248| SMILE | 2 | Smile.| 2249| SURPRISE | 3 | Surprise.| 2250 2251## MetadataObject 2252 2253Implements 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')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable). 2254 2255**System capability**: SystemCapability.Multimedia.Camera.Core 2256 2257| Name | Type | Read-only| Optional|Description | 2258| ----------- | ------------------------------------------- | ---- | ---- | ----------------- | 2259| objectId<sup>13+</sup> | number | Yes | No | Metadata object ID.| 2260| confidence<sup>13+</sup> | number | Yes | No | Confidence of the detection, with a value range of [0,1].| 2261 2262## MetadataFaceObject<sup>13+</sup> 2263 2264Implements 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')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable). 2265 2266**System capability**: SystemCapability.Multimedia.Camera.Core 2267 2268| Name | Type | Read-only| Optional|Description | 2269| ---------------------- | --------------------------------- | ---- | ---- | --------------------- | 2270| leftEyeBoundingBox | [Rect](arkts-apis-camera-i.md#rect) | Yes | No | Left eye area.| 2271| rightEyeBoundingBox | [Rect](arkts-apis-camera-i.md#rect) | Yes | No | Right eye area.| 2272| emotion | [Emotion](#emotion13) | Yes | No | Detected emotion.| 2273| emotionConfidence | number | Yes | No | Confidence of the emotion detection, with a value range of [0,1].| 2274| pitchAngle | number | Yes | No | Pitch angle, with a value range of [-90, 90], where downward is positive.| 2275| yawAngle | number | Yes | No | Yaw angle, with a value range of [-90, 90], where rightward is positive.| 2276| rollAngle | number | Yes | No | Row angle, with a value range of [-180, 180], where clockwise direction is positive.| 2277 2278## MetadataHumanBodyObject<sup>13+</sup> 2279 2280Implements 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')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable). 2281 2282**System capability**: SystemCapability.Multimedia.Camera.Core 2283 2284## MetadataCatFaceObject<sup>13+</sup> 2285 2286Implements 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')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable). 2287 2288**System capability**: SystemCapability.Multimedia.Camera.Core 2289 2290| Name | Type | Read-only| Optional|Description | 2291| ---------------------- | --------------------------------- | ---- | ---- | --------------------- | 2292| leftEyeBoundingBox | [Rect](arkts-apis-camera-i.md#rect) | Yes | No | Left eye area.| 2293| rightEyeBoundingBox | [Rect](arkts-apis-camera-i.md#rect) | Yes | No | Right eye area.| 2294 2295## MetadataCatBodyObject<sup>13+</sup> 2296 2297Implements 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')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable). 2298 2299**System capability**: SystemCapability.Multimedia.Camera.Core 2300 2301## MetadataDogFaceObject<sup>13+</sup> 2302 2303Implements 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')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable). 2304 2305**System capability**: SystemCapability.Multimedia.Camera.Core 2306 2307| Name | Type | Read-only| Optional|Description | 2308| ---------------------- | --------------------------------- | ---- | ---- | --------------------- | 2309| leftEyeBoundingBox | [Rect](arkts-apis-camera-i.md#rect) | Yes | No | Left eye area.| 2310| rightEyeBoundingBox | [Rect](arkts-apis-camera-i.md#rect) | Yes | No | Right eye area.| 2311 2312## MetadataDogBodyObject<sup>13+</sup> 2313 2314Implements 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')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable). 2315 2316**System capability**: SystemCapability.Multimedia.Camera.Core 2317 2318## MetadataSalientDetectionObject<sup>13+</sup> 2319 2320Implements 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')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable). 2321 2322**System capability**: SystemCapability.Multimedia.Camera.Core 2323 2324## MetadataBarcodeObject<sup>14+</sup> 2325 2326Implements 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')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable). 2327 2328**System capability**: SystemCapability.Multimedia.Camera.Core 2329 2330## PortraitEffect 2331 2332Enumerates the portrait effects. 2333 2334**System API**: This is a system API. 2335 2336**System capability**: SystemCapability.Multimedia.Camera.Core 2337 2338| Name | Value | Description | 2339| ----------------| ---- | ---------| 2340| OFF | 0 | Disabled. | 2341| CIRCLES | 1 | Circles. | 2342| HEART<sup>11+</sup> | 2 | Heart-shaped. | 2343| ROTATED<sup>11+</sup> | 3 | Rotated. | 2344| STUDIO<sup>11+</sup> | 4 | Studio light. | 2345| THEATER<sup>11+</sup> | 5 | Theater light. | 2346 2347## BeautyQuery<sup>12+</sup> 2348 2349Provides APIs to obtain and set the beauty effect. 2350 2351### getSupportedBeautyTypes<sup>11+</sup> 2352 2353getSupportedBeautyTypes(): Array\<BeautyType\> 2354 2355Obtains the supported beauty types. 2356 2357**System API**: This is a system API. 2358 2359**System capability**: SystemCapability.Multimedia.Camera.Core 2360 2361**Return value** 2362 2363| Type | Description | 2364| ---------- | ----------------------------- | 2365| Array\<[BeautyType](#beautytype)\>| Array of beauty types supported. | 2366 2367**Error codes** 2368 2369For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2370 2371| ID | Error Message | 2372| --------------- | --------------- | 2373| 202 | Not System Application. | 2374| 7400103 | Session not config. | 2375 2376**Example** 2377 2378```ts 2379function getSupportedBeautyTypes(portraitPhotoSession: camera.PortraitPhotoSession): Array<camera.BeautyType> { 2380 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2381 return beautyTypes; 2382} 2383``` 2384 2385### getSupportedBeautyRange<sup>11+</sup> 2386 2387getSupportedBeautyRange(type: BeautyType): Array\<number\> 2388 2389Obtains the levels that can be set a beauty type. 2390 2391The beauty levels vary according to the device type. The following table is only an example. 2392 2393| Input Parameter | Example Return Value | Return Value Description | 2394| ----------------| ---- | ---------| 2395| 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. | 2396| 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. | 2397| 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. | 2398| 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, 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. | 2399 2400**System API**: This is a system API. 2401 2402**System capability**: SystemCapability.Multimedia.Camera.Core 2403 2404**Parameters** 2405 2406| Name | Type | Mandatory| Description | 2407| -------- | --------------------------| ---- | ----------| 2408| type | [BeautyType](#beautytype) | Yes | Beauty type. | 2409 2410**Return value** 2411 2412| Type | Description | 2413| ---------- | ----------------------------- | 2414| Array\<number\> | Array of levels supported.| 2415 2416**Error codes** 2417 2418For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2419 2420| ID | Error Message | 2421| --------------- | --------------- | 2422| 202 | Not System Application. | 2423| 7400103 | Session not config. | 2424 2425**Example** 2426 2427```ts 2428function getSupportedBeautyRange(portraitPhotoSession: camera.PortraitPhotoSession): Array<number> { 2429 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2430 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2431 return []; 2432 } 2433 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2434 return beautyLevels; 2435} 2436``` 2437 2438## BeautyType 2439 2440Enumerates the beauty types. 2441 2442**System API**: This is a system API. 2443 2444**System capability**: SystemCapability.Multimedia.Camera.Core 2445 2446| Name | Value | Description | 2447| ----------------| ---- | ---------| 2448| AUTO | 0 | Automatic. | 2449| SKIN_SMOOTH | 1 | Skin smoothing. | 2450| FACE_SLENDER | 2 | Face slimming. | 2451| SKIN_TONE | 3 | Skin tone perfection. | 2452 2453## ManualExposureQuery<sup>12+</sup> 2454 2455Provides APIs to obtain the manual exposure range supported. 2456 2457### getSupportedExposureRange<sup>11+</sup> 2458 2459getSupportedExposureRange(): Array\<number\> 2460 2461Obtains the supported manual exposure durations. 2462 2463**System API**: This is a system API. 2464 2465**System capability**: SystemCapability.Multimedia.Camera.Core 2466 2467**Return value** 2468 2469| Type | Description | 2470| ---------- | ----------------------------- | 2471| Array\<number\>| Array of manual exposure durations supported, in ms. | 2472 2473**Error codes** 2474 2475For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2476 2477| ID | Error Message | 2478| --------------- | --------------- | 2479| 202 | Not System Application. | 2480| 7400101 | Parameter missing or parameter type incorrect. | 2481| 7400103 | Session not config, only throw in session usage. | 2482 2483 **Example** 2484 2485```ts 2486function getSupportedExposureRange(nightPhotoSession: camera.NightPhotoSession): Array<number> { 2487 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2488 return exposureRange; 2489} 2490``` 2491 2492## ManualExposure<sup>11+</sup> 2493 2494ManualExposure extends [ManualExposureQuery](#manualexposurequery12) 2495 2496Provides APIs to obtain and set the exposure duration. 2497 2498### getExposure<sup>11+</sup> 2499 2500getExposure(): number 2501 2502Obtains the manual exposure duration in use. 2503 2504**System API**: This is a system API. 2505 2506**System capability**: SystemCapability.Multimedia.Camera.Core 2507 2508**Return value** 2509| Name | Type | Mandatory| Description | 2510| -------- | ------------------------------------------------- | ---- | --------------------- | 2511| value | number | Yes | Manual exposure duration, in ms. | 2512 2513**Error codes** 2514 2515For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2516 2517| ID | Error Message | 2518| --------------- | --------------- | 2519| 202 | Not System Application. | 2520| 7400101 | Parameter missing or parameter type incorrect. | 2521| 7400103 | Session not config. | 2522 2523**Example** 2524 2525```ts 2526function getExposure(nightPhotoSession: camera.NightPhotoSession): number | undefined { 2527 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2528 if (exposureRange === undefined || exposureRange.length <= 0) { 2529 return undefined; 2530 } 2531 let exposure: number = nightPhotoSession.getExposure(); 2532 return exposure; 2533} 2534``` 2535 2536### setExposure<sup>11+</sup> 2537 2538setExposure(exposure: number): void 2539 2540Sets the manual exposure duration. Before using this API, call [getSupportedExposureRange](#getsupportedexposurerange11) to obtain the supported manual exposure durations, in ms. 2541 2542**System API**: This is a system API. 2543 2544**System capability**: SystemCapability.Multimedia.Camera.Core 2545 2546**Parameters** 2547 2548| Name | Type | Mandatory| Description | 2549| -------- | --------------------------| ---- |-------------------------------------------------------------------------| 2550| value | number | Yes | Manual exposure duration, which must be one of the supported durations obtained by running [getSupportedExposureRange](#getsupportedexposurerange11).| 2551 2552 **Error codes** 2553 2554| ID | Error Message | 2555| --------------- | --------------- | 2556| 202 | Not System Application. | 2557| 7400102 | Operation not allowed. | 2558| 7400103 | Session not config. | 2559 2560```ts 2561function setExposure(nightPhotoSession: camera.NightPhotoSession): void { 2562 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2563 if (exposureRange === undefined || exposureRange.length <= 0) { 2564 return; 2565 } 2566 nightPhotoSession.setExposure(exposureRange[0]); 2567} 2568``` 2569 2570## TripodStatus<sup>13+</sup> 2571 2572Enumerates the tripod statuses. 2573 2574**System capability**: SystemCapability.Multimedia.Camera.Core 2575 2576| Name | Value | Description | 2577|----------|-----|-------------------------------------| 2578| INVALID | 0 | Error status, or no tripod detected. **System API**: This is a system API.| 2579| ACTIVE | 1 | The tripod is active. **System API**: This is a system API. | 2580| ENTERING | 2 | The system is transitioning into a stable tripod mode. **System API**: This is a system API. | 2581| EXITING | 3 | The system is leaving the stable tripod mode. **System API**: This is a system API. | 2582 2583 2584## SceneFeatureType<sup>12+</sup> 2585 2586Enumerates the scene features. 2587 2588**System capability**: SystemCapability.Multimedia.Camera.Core 2589 2590| Name | Value | Description | 2591|-------------------------------|-----|---------------------------| 2592| MOON_CAPTURE_BOOST | 0 | Moon scene. **System API**: This is a system API. | 2593| TRIPOD_DETECTION<sup>13+</sup> | 1 | Scene where a tripod is used for photo capture. **System API**: This is a system API. | 2594| LOW_LIGHT_BOOST<sup>13+</sup> | 2 | Scene for long exposure photography. **System API**: This is a system API.| 2595 2596## SceneFeatureDetectionResult<sup>12+</sup> 2597 2598Describes the scene feature detection result. 2599 2600**System capability**: SystemCapability.Multimedia.Camera.Core 2601 2602| Name | Type | Read-only | Mandatory | Description | 2603| -------- | ---------- | -------- | -------- | ---------- | 2604| featureType | [SceneFeatureType](#scenefeaturetype12) | Yes | Yes | Scene feature type. | 2605| detected | boolean | Yes | Yes | Check result for whether the specified scene feature is detected. **true** if detected, **false** otherwise.| 2606 2607## TripodDetectionResult<sup>13+</sup> 2608 2609TripodDetectionResult extends [SceneFeatureDetectionResult](#scenefeaturedetectionresult12) 2610 2611Describes the tripod detection result. 2612 2613**System capability**: SystemCapability.Multimedia.Camera.Core 2614 2615| Name | Type | Read-only | Mandatory | Description | 2616| -------- |---------------------------------| -------- | -------- |---------| 2617| tripodStatus | [TripodStatus](#tripodstatus13) | Yes | Yes | Tripod status.| 2618 2619## SceneDetection<sup>12+</sup> 2620 2621Provides the scene detection capability. 2622 2623### isSceneFeatureSupported<sup>12+</sup> 2624 2625isSceneFeatureSupported(type: SceneFeatureType): boolean 2626 2627Checks whether a scene feature is supported. 2628 2629**System API**: This is a system API. 2630 2631**System capability**: SystemCapability.Multimedia.Camera.Core 2632 2633**Parameters** 2634 2635| Name | Type | Mandatory | Description | 2636|-------|-------------------------------------------|-----|-------------| 2637| type | [SceneFeatureType](#scenefeaturetype12) | Yes | Scene feature. | 2638 2639**Return value** 2640 2641| Type | Description | 2642|-----------|--------------| 2643| boolean | Check result for the support of the scene feature. **true** if supported, **false** otherwise. | 2644 2645**Error codes** 2646 2647For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2648 2649| ID | Error Message | 2650|---------|------------------------------------------------| 2651| 202 | Not System Application. | 2652| 7400101 | Parameter missing or parameter type incorrect. | 2653 2654**Example** 2655 2656```ts 2657function isSceneFeatureSupported(photoSessionForSys: camera.PhotoSessionForSys, featureType: camera.SceneFeatureType): boolean { 2658 let isSupported: boolean = photoSessionForSys.isSceneFeatureSupported(featureType); 2659 return isSupported; 2660} 2661``` 2662 2663### enableSceneFeature<sup>12+</sup> 2664 2665enableSceneFeature(type: SceneFeatureType, enabled: boolean): void 2666 2667Enables or disables a scene feature. This API must be called after [SceneFeatureDetectionResult](#scenefeaturedetectionresult12) of the corresponding scene feature is received. 2668 2669**System API**: This is a system API. 2670 2671**System capability**: SystemCapability.Multimedia.Camera.Core 2672 2673**Parameters** 2674 2675| Name | Type | Mandatory | Description | 2676|---------|-------------------------------------------|-----|-----------------------------| 2677| type | [SceneFeatureType](#scenefeaturetype12) | Yes | Scene feature. | 2678| enabled | boolean | Yes | Whether to enable the scene feature. **true** to enable, **false** otherwise.| 2679 2680**Error codes** 2681 2682For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2683 2684| ID | Error Message | 2685|---------|------------------------------------------------| 2686| 202 | Not System Application. | 2687| 7400101 | Parameter missing or parameter type incorrect. | 2688 2689**Example** 2690 2691```ts 2692import { BusinessError } from '@kit.BasicServicesKit'; 2693 2694function enableSceneFeature(photoSession: camera.PhotoSessionForSys, cameraInput: camera.CameraInput, previewOutput: camera.PreviewOutput): void { 2695 photoSession.beginConfig(); 2696 photoSession.addInput(cameraInput); 2697 photoSession.addOutput(previewOutput); 2698 photoSession.commitConfig(); 2699 2700 photoSession.on('featureDetection', camera.SceneFeatureType.MOON_CAPTURE_BOOST, 2701 (err: BusinessError, statusObject: camera.SceneFeatureDetectionResult) => { 2702 if (err !== undefined && err.code !== 0) { 2703 console.error(`Callback Error, errorCode: ${err.code}`); 2704 return; 2705 } 2706 console.info( 2707 `on featureDetectionStatus featureType:${statusObject.featureType} detected:${statusObject.detected}`); 2708 if (statusObject.featureType === camera.SceneFeatureType.MOON_CAPTURE_BOOST) { 2709 try { 2710 photoSession.enableSceneFeature(statusObject.featureType, statusObject.detected); 2711 } catch (error) { 2712 let err = error as BusinessError; 2713 console.error(`The enableSceneFeature call failed. error code: ${err.code}`); 2714 } 2715 } 2716 }); 2717} 2718``` 2719 2720## ZoomPointInfo<sup>12+</sup> 2721 2722Describes the equivalent focal length information. 2723 2724**System API**: This is a system API. 2725 2726**System capability**: SystemCapability.Multimedia.Camera.Core 2727 2728| Name | Type | Read-only | Optional | Description | 2729| -------- | ---------- | -------- |-----| ---------- | 2730| zoomRatio | number | Yes | No | Zoom ratio.| 2731| equivalentFocalLength | number | Yes | No | Equivalent focal length corresponding to the current focal length ratio.| 2732 2733## ZoomQuery<sup>12+</sup> 2734 2735Provides the API to obtain the equivalent focal length information list in the current mode. 2736 2737### getZoomPointInfos<sup>12+</sup> 2738 2739getZoomPointInfos(): Array\<ZoomPointInfo\> 2740 2741Obtains the equivalent focal length information list in the current mode. 2742 2743**System API**: This is a system API. 2744 2745**System capability**: SystemCapability.Multimedia.Camera.Core 2746 2747**Return value** 2748 2749| Type | Description | 2750| ---------- | ----------------------------- | 2751| Array\<[ZoomPointInfo](#zoompointinfo12)\>| Equivalent focal length information list in the current mode. | 2752 2753**Error codes** 2754 2755For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2756 2757| ID | Error Message | 2758| --------------- | --------------- | 2759| 202 | Not System Application. | 2760| 7400103 | Session not config. | 2761 2762**Example** 2763 2764```ts 2765import { camera } from '@kit.CameraKit'; 2766import { BusinessError } from '@kit.BasicServicesKit'; 2767 2768function getZoomPointInfos(photoSessionForSys: camera.PhotoSessionForSys): Array<camera.ZoomPointInfo> { 2769 let zoomPointInfos: Array<camera.ZoomPointInfo> = []; 2770 try { 2771 zoomPointInfos = photoSessionForSys.getZoomPointInfos(); 2772 } catch (error) { 2773 // If the operation fails, error.code is returned and processed. 2774 let err = error as BusinessError; 2775 console.error(`The getZoomPointInfos call failed. error code: ${err.code}`); 2776 } 2777 return zoomPointInfos; 2778} 2779``` 2780 2781## Zoom<sup>11+</sup> 2782 2783Zoom extend [ZoomQuery](#zoomquery12) 2784 2785Provides 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. 2786 2787### prepareZoom<sup>11+</sup> 2788 2789prepareZoom(): void 2790 2791Instructs the bottom layer to prepare for zooming, for example, powering on the sensor. 2792 2793**System API**: This is a system API. 2794 2795**System capability**: SystemCapability.Multimedia.Camera.Core 2796 2797**Error codes** 2798 2799For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2800 2801| ID | Error Message | 2802| --------------- | --------------- | 2803| 202 | Not System Application. | 2804| 7400103 | Session not config. | 2805 2806**Example** 2807 2808```ts 2809import { BusinessError } from '@kit.BasicServicesKit'; 2810 2811function prepareZoom(sessionExtendsZoom: camera.Zoom): void { 2812 try { 2813 sessionExtendsZoom.prepareZoom(); 2814 } catch (error) { 2815 // If the operation fails, error.code is returned and processed. 2816 let err = error as BusinessError; 2817 console.error(`The prepareZoom call failed. error code: ${err.code}`); 2818 } 2819} 2820``` 2821 2822### unprepareZoom<sup>11+</sup> 2823 2824unprepareZoom(): void 2825 2826Instructs the bottom layer to unprepare for zooming. 2827 2828**System API**: This is a system API. 2829 2830**System capability**: SystemCapability.Multimedia.Camera.Core 2831 2832**Error codes** 2833 2834For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2835 2836| ID | Error Message | 2837| --------------- | --------------- | 2838| 202 | Not System Application. | 2839| 7400103 | Session not config. | 2840 2841**Example** 2842 2843```ts 2844import { BusinessError } from '@kit.BasicServicesKit'; 2845 2846function unprepareZoom(sessionExtendsZoom: camera.Zoom): void { 2847 try { 2848 sessionExtendsZoom.unprepareZoom(); 2849 } catch (error) { 2850 // If the operation fails, error.code is returned and processed. 2851 let err = error as BusinessError; 2852 console.error(`The unprepareZoom call failed. error code: ${err.code}`); 2853 } 2854} 2855``` 2856 2857## ZoomRange<sup>11+</sup> 2858 2859Obtains the supported zoom ratio range. The range is [min, max), which includes the minimum value but excludes the maximum value. 2860 2861**System API**: This is a system API. 2862 2863**System capability**: SystemCapability.Multimedia.Camera.Core 2864 2865| Name | Type | Read-only| Mandatory| Description | 2866| -------- | ------------- |---- | ---- | -------------| 2867| min | number | Yes | N/A | Minimum value of the zoom ratio range. | 2868| max | number | Yes | N/A | Maximum value of the zoom ratio range.| 2869 2870## Beauty<sup>11+</sup> 2871 2872Beauty extends [BeautyQuery](#beautyquery12) 2873 2874Provides APIs to obtain and set the beauty effect. 2875 2876### setBeauty<sup>11+</sup> 2877 2878setBeauty(type: BeautyType, value: number): void 2879 2880Sets a beauty type and its level. Beauty mode is turned off only when all the [beauty types](#beautytype) obtained through [getSupportedBeautyTypes](#getsupportedbeautytypes11) are disabled. 2881 2882**System API**: This is a system API. 2883 2884**System capability**: SystemCapability.Multimedia.Camera.Core 2885 2886**Parameters** 2887 2888| Name | Type | Mandatory| Description | 2889| -------- | --------------------------| ---- |-------------------------------------------------------------------| 2890| type | [BeautyType](#beautytype) | Yes | Beauty type. | 2891| value | number | Yes | Beauty level, which is obtained through [getSupportedBeautyRange](#getsupportedbeautyrange11).| 2892 2893**Error codes** 2894 2895For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2896 2897| ID | Error Message | 2898| --------------- | --------------- | 2899| 202 | Not System Application. | 2900| 7400103 | Session not config. | 2901 2902**Example** 2903 2904```ts 2905function setBeauty(portraitPhotoSession: camera.PortraitPhotoSession): void { 2906 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2907 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2908 return; 2909 } 2910 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2911 if (beautyLevels === undefined || beautyLevels.length <= 0) { 2912 return; 2913 } 2914 portraitPhotoSession.setBeauty(beautyTypes[0], beautyLevels[0]); 2915} 2916``` 2917 2918### getBeauty<sup>11+</sup> 2919 2920getBeauty(type: BeautyType): number 2921 2922Obtains the level of the beauty type in use. 2923 2924**System API**: This is a system API. 2925 2926**System capability**: SystemCapability.Multimedia.Camera.Core 2927 2928**Parameters** 2929 2930| Name | Type | Mandatory| Description | 2931| -------- | ------------------------------------------------- | ---- | --------------------- | 2932| type | [BeautyType](#beautytype) | Yes | Beauty type. | 2933 2934**Return value** 2935| Name | Type | Mandatory| Description | 2936| -------- | ------------------------------------------------- | ---- | --------------------- | 2937| value | number | Yes | Beauty level. | 2938 2939**Error codes** 2940 2941For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2942 2943| ID | Error Message | 2944| --------------- | --------------- | 2945| 202 | Not System Application. | 2946| 7400103 | Session not config. | 2947 2948**Example** 2949 2950```ts 2951function getBeauty(portraitPhotoSession: camera.PortraitPhotoSession): number { 2952 const invalidValue: number = -1; 2953 let beautyTypes = portraitPhotoSession.getSupportedBeautyTypes(); 2954 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2955 return invalidValue; 2956 } 2957 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2958 if (beautyLevels === undefined || beautyLevels.length <= 0) { 2959 return invalidValue; 2960 } 2961 portraitPhotoSession.setBeauty(beautyTypes[0], beautyLevels[0]); 2962 let beautyLevel: number = portraitPhotoSession.getBeauty(beautyTypes[0]); 2963 return beautyLevel; 2964} 2965``` 2966 2967## ColorEffectQuery<sup>12+</sup> 2968 2969Provides the API to obtain the color effects supported. 2970 2971### getSupportedColorEffects<sup>11+</sup> 2972 2973getSupportedColorEffects(): Array\<ColorEffectType\> 2974 2975Obtains the supported color effects. 2976 2977**System API**: This is a system API. 2978 2979**System capability**: SystemCapability.Multimedia.Camera.Core 2980 2981**Return value** 2982 2983| Type | Description | 2984| ----------------------------------------------- | ---------------------------- | 2985| Array<[ColorEffectType](#coloreffecttype11)> | Array of color effects supported. | 2986 2987**Error codes** 2988 2989For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 2990 2991| ID | Error Message | 2992| --------------- | --------------- | 2993| 7400103 | Session not config. | 2994| 202 | Not System Application. | 2995 2996**Example** 2997 2998```ts 2999function getSupportedColorEffects(session: camera.PhotoSessionForSys): Array<camera.ColorEffectType> { 3000 let colorEffects: Array<camera.ColorEffectType> = session.getSupportedColorEffects(); 3001 return colorEffects; 3002} 3003``` 3004 3005## ColorEffect<sup>11+</sup> 3006 3007ColorEffect extends [ColorEffectQuery](#coloreffectquery12) 3008 3009Provides the APIs to obtain and set the lens color effect. 3010 3011### setColorEffect<sup>11+</sup> 3012 3013setColorEffect(type: ColorEffectType): void 3014 3015Sets a color effect. Before the setting, call [getSupportedColorEffects](#getsupportedcoloreffects11) to obtain the supported color effects. 3016 3017**System API**: This is a system API. 3018 3019**System capability**: SystemCapability.Multimedia.Camera.Core 3020 3021**Parameters** 3022 3023| Name | Type | Mandatory| Description | 3024| ------------ |--------------------------------------------------------------- | -- | -------------------------- | 3025| type | [ColorEffectType](#coloreffecttype11) | Yes| Color effect, which can be obtained through [getSupportedColorEffects](#getsupportedcoloreffects11). | 3026 3027**Error codes** 3028 3029For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3030 3031| ID | Error Message | 3032| --------------- | --------------- | 3033| 7400103 | Session not config. | 3034| 202 | Not System Application. | 3035 3036**Example** 3037 3038```ts 3039function setColorEffect(session: camera.PhotoSessionForSys, colorEffect: camera.ColorEffectType): void { 3040 session.setColorEffect(colorEffect); 3041} 3042``` 3043 3044### getColorEffect<sup>11+</sup> 3045 3046getColorEffect(): ColorEffectType 3047 3048Obtains the color effect in use. 3049 3050**System API**: This is a system API. 3051 3052**System capability**: SystemCapability.Multimedia.Camera.Core 3053 3054**Return value** 3055 3056| Type | Description | 3057| ----------------------------------------------- | ---------------------------- | 3058| [ColorEffectType](#coloreffecttype11) | Color effect. | 3059 3060**Error codes** 3061 3062For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3063 3064| ID | Error Message | 3065| --------------- | --------------- | 3066| 7400103 | Session not config. | 3067| 202 | Not System Application. | 3068 3069**Example** 3070 3071```ts 3072function getColorEffect(session: camera.PhotoSessionForSys): camera.ColorEffectType { 3073 let colorEffect: camera.ColorEffectType = session.getColorEffect(); 3074 return colorEffect; 3075} 3076``` 3077 3078## ColorEffectType<sup>11+</sup> 3079 3080Enumerates the color effect types. 3081 3082**System API**: This is a system API. 3083 3084**System capability**: SystemCapability.Multimedia.Camera.Core 3085 3086| Name | Value | Description | 3087| --------------------- | ---- | --------- | 3088| NORMAL | 0 | Regular color effect. | 3089| BRIGHT | 1 | Bright color effect. | 3090| SOFT | 2 | Soft color effect. | 3091| BLACK_WHITE<sup>12+</sup> | 3 | Black and white color effect. | 3092 3093## Portrait<sup>11+</sup> 3094 3095Provides the APIs for portrait photo settings. 3096 3097### getSupportedPortraitEffects<sup>10+</sup> 3098 3099getSupportedPortraitEffects(): Array\<PortraitEffect\> 3100 3101Obtains the supported portrait effects. 3102 3103**System API**: This is a system API. 3104 3105**System capability**: SystemCapability.Multimedia.Camera.Core 3106 3107**Return value** 3108 3109| Type | Description | 3110| ----------------------------------------------- | ---------------------------- | 3111| Array<[PortraitEffect](#portraiteffect)> | Array of portrait effects supported. | 3112 3113**Error codes** 3114 3115For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3116 3117| ID | Error Message | 3118| --------------- | --------------- | 3119| 7400103 | Session not config. | 3120| 202 | Not System Application. | 3121 3122**Example** 3123 3124```ts 3125function getSupportedPortraitEffects(portraitPhotoSession: camera.PortraitPhotoSession): Array<camera.PortraitEffect> { 3126 let portraitEffects: Array<camera.PortraitEffect> = portraitPhotoSession.getSupportedPortraitEffects(); 3127 return portraitEffects; 3128} 3129``` 3130 3131### setPortraitEffect<sup>10+</sup> 3132 3133setPortraitEffect(effect: PortraitEffect): void 3134 3135Sets a portrait effect. Before the setting, call [getSupportedPortraitEffects](#getsupportedportraiteffects10) to obtain the supported portrait effects and check whether the target portrait effect is supported. 3136 3137**System API**: This is a system API. 3138 3139**System capability**: SystemCapability.Multimedia.Camera.Core 3140 3141**Parameters** 3142 3143| Name | Type | Mandatory| Description | 3144| ------------ |----------------------------- | -- | -------------------------- | 3145| effect | [PortraitEffect](#portraiteffect) | Yes| Portrait effect, which can be obtained through [getSupportedPortraitEffects](#getsupportedportraiteffects10). | 3146 3147**Error codes** 3148 3149For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3150 3151| ID | Error Message | 3152| --------------- | --------------- | 3153| 7400103 | Session not config. | 3154| 202 | Not System Application. | 3155 3156**Example** 3157 3158```ts 3159import { BusinessError } from '@kit.BasicServicesKit'; 3160 3161function setPortraitEffect(portraitPhotoSession: camera.PortraitPhotoSession, portraitEffects: Array<camera.PortraitEffect>): void { 3162 if (portraitEffects === undefined || portraitEffects.length <= 0) { 3163 return; 3164 } 3165 try { 3166 portraitPhotoSession.setPortraitEffect(portraitEffects[0]); 3167 } catch (error) { 3168 let err = error as BusinessError; 3169 console.error(`The setPortraitEffect call failed. error code: ${err.code}`); 3170 } 3171} 3172``` 3173 3174### getPortraitEffect<sup>10+</sup> 3175 3176getPortraitEffect(): PortraitEffect 3177 3178Obtains the portrait effect in use. 3179 3180**System API**: This is a system API. 3181 3182**System capability**: SystemCapability.Multimedia.Camera.Core 3183 3184**Return value** 3185 3186| Type | Description | 3187| ----------------------------------------------- | ---------------------------- | 3188| [PortraitEffect](#portraiteffect) | Portrait effect. | 3189 3190**Error codes** 3191 3192For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3193 3194| ID | Error Message | 3195| --------------- | --------------- | 3196| 7400103 | Session not config. | 3197| 202 | Not System Application. | 3198 3199**Example** 3200 3201```ts 3202function getPortraitEffect(portraitPhotoSession: camera.PortraitPhotoSession): camera.PortraitEffect { 3203 let portraitEffect: camera.PortraitEffect = portraitPhotoSession.getPortraitEffect(); 3204 return portraitEffect; 3205} 3206``` 3207 3208## PhysicalAperture<sup>11+</sup> 3209 3210Defines the physical aperture information. 3211 3212**System API**: This is a system API. 3213 3214**System capability**: SystemCapability.Multimedia.Camera.Core 3215 3216| Name | Type | Read-only| Optional | Description | 3217| ---------- | ------------------------- | ----- |-----| ----------------- | 3218| zoomRange | [ZoomRange](#zoomrange11) | No | No | Zoom range of a given physical aperture. | 3219| apertures | Array\<number\> | No | No | Array of physical apertures supported. | 3220 3221## Aperture<sup>11+</sup> 3222 3223Provides the APIs for aperture settings. 3224 3225### getSupportedVirtualApertures<sup>11+</sup> 3226 3227getSupportedVirtualApertures(): Array\<number\> 3228 3229Obtains the supported virtual apertures. 3230 3231**System API**: This is a system API. 3232 3233**System capability**: SystemCapability.Multimedia.Camera.Core 3234 3235**Return value** 3236 3237| Type | Description | 3238| ----------------------------------------------- | ---------------------------- | 3239| Array\<number\> | Array of virtual apertures supported. | 3240 3241**Error codes** 3242 3243For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3244 3245| ID | Error Message | 3246| --------------- | --------------- | 3247| 7400103 | Session not config. | 3248| 202 | Not System Application. | 3249 3250**Example** 3251 3252```ts 3253function getSupportedVirtualApertures(session: camera.PortraitPhotoSession): Array<number> { 3254 let virtualApertures: Array<number> = session.getSupportedVirtualApertures(); 3255 return virtualApertures; 3256} 3257``` 3258 3259### getVirtualAperture<sup>11+</sup> 3260 3261getVirtualAperture(): number 3262 3263Obtains the virtual aperture in use. 3264 3265**System API**: This is a system API. 3266 3267**System capability**: SystemCapability.Multimedia.Camera.Core 3268 3269**Return value** 3270 3271| Type | Description | 3272| ----------------------------------------------- | ---------------------------- | 3273| number | Virtual aperture. | 3274 3275**Error codes** 3276 3277For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3278 3279| ID | Error Message | 3280| --------------- | --------------- | 3281| 7400103 | Session not config. | 3282| 202 | Not System Application. | 3283 3284**Example** 3285 3286```ts 3287function getVirtualAperture(session: camera.PortraitPhotoSession): number { 3288 let virtualAperture: number = session.getVirtualAperture(); 3289 return virtualAperture; 3290} 3291``` 3292 3293### setVirtualAperture<sup>11+</sup> 3294 3295setVirtualAperture(aperture: number): void 3296 3297Sets a virtual aperture. Before the setting, call [getSupportedVirtualApertures](#getsupportedvirtualapertures11) to obtain the supported virtual apertures. 3298 3299**System API**: This is a system API. 3300 3301**System capability**: SystemCapability.Multimedia.Camera.Core 3302 3303**Parameters** 3304 3305| Name | Type | Mandatory| Description | 3306| ------------ |------------------------- | -- | -------------------------- | 3307| aperture | number | Yes| Virtual aperture, which can be obtained by calling [getSupportedVirtualApertures](#getsupportedvirtualapertures11). | 3308 3309**Error codes** 3310 3311For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3312 3313| ID | Error Message | 3314| --------------- | --------------- | 3315| 7400103 | Session not config. | 3316| 202 | Not System Application. | 3317 3318**Example** 3319 3320```ts 3321function setVirtualAperture(session: camera.PortraitPhotoSession, virtualAperture: number): void { 3322 session.setVirtualAperture(virtualAperture); 3323} 3324``` 3325 3326### getSupportedPhysicalApertures<sup>11+</sup> 3327 3328getSupportedPhysicalApertures(): Array\<PhysicalAperture\> 3329 3330Obtains the supported physical apertures. 3331 3332**System API**: This is a system API. 3333 3334**System capability**: SystemCapability.Multimedia.Camera.Core 3335 3336**Return value** 3337 3338| Type | Description | 3339| ----------------------------------------------- | ---------------------------- | 3340| Array<[PhysicalAperture](#physicalaperture11)> | Array of physical apertures supported. | 3341 3342**Error codes** 3343 3344For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3345 3346| ID | Error Message | 3347| --------------- | --------------- | 3348| 7400103 | Session not config. | 3349| 202 | Not System Application. | 3350 3351**Example** 3352 3353```ts 3354function getSupportedPhysicalApertures(session: camera.PortraitPhotoSession): Array<camera.PhysicalAperture> { 3355 let physicalApertures: Array<camera.PhysicalAperture> = session.getSupportedPhysicalApertures(); 3356 return physicalApertures; 3357} 3358``` 3359 3360### getPhysicalAperture<sup>11+</sup> 3361 3362getPhysicalAperture(): number 3363 3364Obtains the physical aperture in use. 3365 3366**System API**: This is a system API. 3367 3368**System capability**: SystemCapability.Multimedia.Camera.Core 3369 3370**Return value** 3371 3372| Type | Description | 3373| -------------------- | ---------------------------- | 3374| number | Physical aperture. | 3375 3376**Error codes** 3377 3378For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3379 3380| ID | Error Message | 3381| --------------- | --------------- | 3382| 7400103 | Session not config. | 3383| 202 | Not System Application. | 3384 3385**Example** 3386 3387```ts 3388function getPhysicalAperture(session: camera.PortraitPhotoSession): number { 3389 let physicalAperture: number = session.getPhysicalAperture(); 3390 return physicalAperture; 3391} 3392``` 3393 3394### setPhysicalAperture<sup>11+</sup> 3395 3396setPhysicalAperture(aperture: number): void 3397 3398Sets a physical aperture. Before the setting, call [getSupportedPhysicalApertures](#getsupportedphysicalapertures11) to obtain the supported physical apertures. 3399 3400**System API**: This is a system API. 3401 3402**System capability**: SystemCapability.Multimedia.Camera.Core 3403 3404**Parameters** 3405 3406| Name | Type | Mandatory| Description | 3407| ------------ |------------------------- | -- | -------------------------- | 3408| aperture | number | Yes| Physical aperture, which can be obtained by calling [getSupportedPhysicalApertures](#getsupportedphysicalapertures11). | 3409 3410**Error codes** 3411 3412For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3413 3414| ID | Error Message | 3415| --------------- | --------------- | 3416| 7400103 | Session not config. | 3417| 202 | Not System Application. | 3418 3419**Example** 3420 3421```ts 3422function setPhysicalAperture(session: camera.PortraitPhotoSession, physicalAperture: number): void { 3423 session.setPhysicalAperture(physicalAperture); 3424} 3425``` 3426 3427## CaptureSession<sup>(deprecated)</sup> 3428 3429Implements a capture session, which saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera and requests the camera to complete shooting or video recording. 3430 3431> **NOTE** 3432> 3433> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [PhotoSession](arkts-apis-camera-PhotoSession.md) and [VideoSession](arkts-apis-camera-VideoSession.md) instead. 3434 3435### getSupportedBeautyTypes<sup>(deprecated)</sup> 3436 3437getSupportedBeautyTypes(): Array\<BeautyType> 3438 3439Obtains the supported beauty types. 3440 3441> **NOTE** 3442> 3443> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Beauty.getSupportedBeautyTypes](#getsupportedbeautytypes11) instead. 3444 3445**System API**: This is a system API. 3446 3447**System capability**: SystemCapability.Multimedia.Camera.Core 3448 3449**Return value** 3450 3451| Type | Description | 3452| ---------- | ----------------------------- | 3453| Array\<[BeautyType](#beautytype)\>| Array of beauty types supported. | 3454 3455**Error codes** 3456 3457For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3458 3459| ID | Error Message | 3460| --------------- | --------------- | 3461| 7400103 | Session not config. | 3462 3463**Example** 3464 3465```ts 3466function getSupportedBeautyTypes(captureSession: camera.CaptureSession): Array<camera.BeautyType> { 3467 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3468 return beautyTypes; 3469} 3470``` 3471 3472### getSupportedBeautyRange<sup>(deprecated)</sup> 3473 3474getSupportedBeautyRange(type: BeautyType): Array\<number\> 3475 3476Obtains 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. 3477 3478| Input Parameter | Example Return Value | Return Value Description | 3479| ----------------| ---- | ---------| 3480| 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. | 3481| 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. | 3482| 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. | 3483| 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, 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. | 3484 3485> **NOTE** 3486> 3487> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Beauty.getSupportedBeautyRange](#getsupportedbeautyrange11) instead. 3488 3489**System API**: This is a system API. 3490 3491**System capability**: SystemCapability.Multimedia.Camera.Core 3492 3493**Parameters** 3494 3495| Name | Type | Mandatory| Description | 3496| -------- | --------------------------| ---- | ----------| 3497| type | [BeautyType](#beautytype) | Yes | Beauty type. | 3498 3499**Return value** 3500 3501| Type | Description | 3502| ---------- | ----------------------------- | 3503| Array\<number\> | Array of levels supported.| 3504 3505**Error codes** 3506 3507For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3508 3509| ID | Error Message | 3510| --------------- | --------------- | 3511| 7400103 | Session not config. | 3512 3513**Example** 3514 3515```ts 3516function getSupportedBeautyRange(captureSession: camera.CaptureSession): Array<number> { 3517 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3518 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3519 return []; 3520 } 3521 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3522 return beautyLevels; 3523} 3524``` 3525 3526### setBeauty<sup>(deprecated)</sup> 3527 3528setBeauty(type: BeautyType, value: number): void 3529 3530Sets a beauty type and its level. Beauty mode is turned off only when all the [beauty types](#beautytype) obtained through [getSupportedBeautyTypes](#getsupportedbeautytypesdeprecated) are disabled. 3531 3532> **NOTE** 3533> 3534> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Beauty.setBeauty](#setbeauty11) instead. 3535 3536**System API**: This is a system API. 3537 3538**System capability**: SystemCapability.Multimedia.Camera.Core 3539 3540**Parameters** 3541 3542| Name | Type | Mandatory| Description | 3543| -------- | --------------------------| ---- | --------------------- | 3544| type | [BeautyType](#beautytype) | Yes | Beauty type. | 3545| value | number | Yes | Beauty level, which is obtained through [getSupportedBeautyRange](#getsupportedbeautyrangedeprecated).| 3546 3547**Error codes** 3548 3549For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3550 3551| ID | Error Message | 3552| --------------- | --------------- | 3553| 7400103 | Session not config. | 3554 3555**Example** 3556 3557```ts 3558function setBeauty(captureSession: camera.CaptureSession): void { 3559 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3560 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3561 return; 3562 } 3563 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3564 if (beautyLevels === undefined || beautyLevels.length <= 0) { 3565 return; 3566 } 3567 captureSession.setBeauty(beautyTypes[0], beautyLevels[0]); 3568} 3569``` 3570 3571### getBeauty<sup>(deprecated)</sup> 3572 3573getBeauty(type: BeautyType): number 3574 3575Obtains the level of the beauty type in use. 3576 3577> **NOTE** 3578> 3579> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Beauty.getBeauty](#getbeauty11) instead. 3580 3581**System API**: This is a system API. 3582 3583**System capability**: SystemCapability.Multimedia.Camera.Core 3584 3585**Parameters** 3586 3587| Name | Type | Mandatory| Description | 3588| -------- | ------------------------------------------------- | ---- | --------------------- | 3589| type | [BeautyType](#beautytype) | Yes | Beauty type. | 3590 3591**Return value** 3592| Name | Type | Mandatory| Description | 3593| -------- | ------------------------------------------------- | ---- | --------------------- | 3594| value | number | Yes | Beauty level. | 3595 3596**Error codes** 3597 3598For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3599 3600| ID | Error Message | 3601| --------------- | --------------- | 3602| 7400103 | Session not config. | 3603 3604**Example** 3605 3606```ts 3607function getBeauty(captureSession: camera.CaptureSession): number { 3608 const invalidValue: number = -1; 3609 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3610 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3611 return invalidValue; 3612 } 3613 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3614 if (beautyLevels === undefined || beautyLevels.length <= 0) { 3615 return invalidValue; 3616 } 3617 captureSession.setBeauty(beautyTypes[0], beautyLevels[0]); 3618 let beautyLevel: number = captureSession.getBeauty(beautyTypes[0]); 3619 return beautyLevel; 3620} 3621``` 3622 3623## PhotoSessionForSys<sup>11+</sup> 3624 3625PhotoSessionForSys extends PhotoSession, Beauty, ColorEffect, ColorManagement, SceneDetection 3626 3627Implements a photo session for system applications, which sets the parameters of the normal photo mode and saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera. It inherits from [Session](arkts-apis-camera-Session.md). 3628 3629**System API**: This is a system API. 3630 3631**System capability**: SystemCapability.Multimedia.Camera.Core 3632 3633## PhotoSession<sup>11+</sup> 3634 3635PhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorManagement 3636 3637Implements a photo session, which sets the parameters of the normal photo mode and saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera. It inherits from [Session](arkts-apis-camera-Session.md). 3638 3639### on('macroStatusChanged')<sup>11+</sup> 3640 3641on(type: 'macroStatusChanged', callback: AsyncCallback\<boolean\>): void 3642 3643Subscribes to macro state change events. This API uses an asynchronous callback to return the result. 3644 3645**System API**: This is a system API. 3646 3647**System capability**: SystemCapability.Multimedia.Camera.Core 3648 3649**Parameters** 3650 3651| Name | Type | Mandatory| Description | 3652| -------- | ----------------------------------------- | ---- | ------------------------ | 3653| type | string | Yes | Event type. The value is fixed at **'macroStatusChanged'**. The event can be listened for when a session is created.| 3654| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the macro state. **true** if enabled, **false** otherwise. | 3655 3656**Error codes** 3657 3658For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3659 3660| ID| Error Message | 3661|-------|---------------------------| 3662| 202 | Not System Application. | 3663 3664**Example** 3665 3666```ts 3667import { BusinessError } from '@kit.BasicServicesKit'; 3668 3669function callback(err: BusinessError, macroStatus: boolean): void { 3670 if (err !== undefined && err.code !== 0) { 3671 console.error(`Callback Error, errorCode: ${err.code}`); 3672 return; 3673 } 3674 console.info(`Macro state: ${macroStatus}`); 3675} 3676 3677function registerMacroStatusChanged(photoSession: camera.PhotoSession): void { 3678 photoSession.on('macroStatusChanged', callback); 3679} 3680``` 3681 3682### off('macroStatusChanged')<sup>11+</sup> 3683 3684off(type: 'macroStatusChanged', callback?: AsyncCallback\<boolean\>): void 3685 3686Unsubscribes from macro state change events. 3687 3688**System API**: This is a system API. 3689 3690**System capability**: SystemCapability.Multimedia.Camera.Core 3691 3692**Parameters** 3693 3694| Name | Type | Mandatory| Description | 3695| -------- | ------------------------ | ---- | ------------------------ | 3696| type | string | Yes | Event type. The value is fixed at **'macroStatusChanged'**. The event can be listened for when a session is created.| 3697| callback | AsyncCallback\<boolean\> | No | Callback used to return the macro state. **true** if enabled, **false** otherwise. 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.)| 3698 3699**Error codes** 3700 3701For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3702 3703| ID| Error Message | 3704|-------|---------------------------| 3705| 202 | Not System Application. | 3706 3707**Example** 3708 3709```ts 3710function unregisterMacroStatusChanged(photoSession: camera.PhotoSession): void { 3711 photoSession.off('macroStatusChanged'); 3712} 3713``` 3714 3715### on('featureDetection')<sup>12+</sup> 3716 3717on(type: 'featureDetection', featureType: SceneFeatureType, callback: AsyncCallback\<SceneFeatureDetectionResult\>): void 3718 3719Subscribe to scene feature detection status change events. This API uses an asynchronous callback to return the result. 3720 3721**System API**: This is a system API. 3722 3723**System capability**: SystemCapability.Multimedia.Camera.Core 3724 3725**Parameters** 3726 3727| Name | Type | Mandatory| Description | 3728| -------- | ----------------------------------------- | ---- | ------------------------ | 3729| type | string | Yes | Event type. The value is fixed at **'featureDetection'**. The event can be listened for when a photo session is created.| 3730| featureType | [SceneFeatureType](#scenefeaturetype12) | Yes | Scene feature type.| 3731| callback | AsyncCallback\<[SceneFeatureDetectionResult](#scenefeaturedetectionresult12)\> | Yes | Callback used to return the status of the scene feature detection. | 3732 3733**Error codes** 3734 3735For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3736 3737| ID| Error Message | 3738|-------|---------------------------| 3739| 202 | Not System Application. | 3740 3741**Example** 3742 3743```ts 3744import { BusinessError } from '@kit.BasicServicesKit'; 3745 3746function callback(err: BusinessError, result: camera.SceneFeatureDetectionResult): void { 3747 if (err !== undefined && err.code !== 0) { 3748 console.error(`Callback Error, errorCode: ${err.code}`); 3749 return; 3750 } 3751 console.info(`feature type: ${result.featureType}`); 3752 console.info(`feature status: ${result.detected}`); 3753} 3754 3755function registerFeatureDetectionStatus(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): void { 3756 photoSession.on('featureDetection', featureType, callback); 3757} 3758``` 3759 3760### off('featureDetection')<sup>12+</sup> 3761 3762off(type: 'featureDetection', featureType: SceneFeatureType, callback?: AsyncCallback\<SceneFeatureDetectionResult\>): void 3763 3764Unsubscribe from camera feature detection status change events. 3765 3766**System API**: This is a system API. 3767 3768**System capability**: SystemCapability.Multimedia.Camera.Core 3769 3770**Parameters** 3771 3772| Name | Type | Mandatory| Description | 3773| -------- | ------------------------ | ---- | ------------------------ | 3774| type | string | Yes | Event type. The value is fixed at **'featureDetection'**. The event can be listened for when a session is created.| 3775| featureType | [SceneFeatureType](#scenefeaturetype12) | Yes | Scene feature type.| 3776| 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.)| 3777 3778**Error codes** 3779 3780For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3781 3782| ID| Error Message | 3783|-------|---------------------------| 3784| 202 | Not System Application. | 3785 3786**Example** 3787 3788```ts 3789function unregisterFeatureDetectionStatus(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): void { 3790 photoSession.off('featureDetection', featureType); 3791} 3792``` 3793 3794### on('lcdFlashStatus')<sup>13+</sup> 3795 3796on(type: 'lcdFlashStatus', callback: AsyncCallback\<LcdFlashStatus\>): void 3797 3798Subscribes to LCD flash status change events. This API uses an asynchronous callback to return the result. 3799 3800**System API**: This is a system API. 3801 3802**System capability**: SystemCapability.Multimedia.Camera.Core 3803 3804**Parameters** 3805 3806| Name | Type | Mandatory| Description | 3807| -------- | ----------------------------------------- | ---- |------------------------------------------| 3808| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created.| 3809| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | Yes | Callback used to return the LCD flash status change. | 3810 3811**Error codes** 3812 3813For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3814 3815| ID| Error Message | 3816|-------|---------------------------| 3817| 202 | Not System Application. | 3818 3819**Example** 3820 3821```ts 3822import { BusinessError } from '@kit.BasicServicesKit'; 3823 3824function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 3825 if (err !== undefined && err.code !== 0) { 3826 console.error(`Callback Error, errorCode: ${err.code}`); 3827 return; 3828 } 3829 console.info(`isLcdFlashNeeded: ${lcdFlashStatus.isLcdFlashNeeded}`); 3830 console.info(`lcdCompensation: ${lcdFlashStatus.lcdCompensation}`); 3831} 3832 3833function registerLcdFlashStatus(photoSession: camera.PhotoSession): void { 3834 photoSession.on('lcdFlashStatus', callback); 3835} 3836``` 3837 3838### off('lcdFlashStatus')<sup>13+</sup> 3839 3840off(type: 'lcdFlashStatus', callback?: AsyncCallback\<LcdFlashStatus\>): void 3841 3842Unsubscribes from LCD flash status change events. 3843 3844**System API**: This is a system API. 3845 3846**System capability**: SystemCapability.Multimedia.Camera.Core 3847 3848**Parameters** 3849 3850| Name | Type | Mandatory| Description | 3851| -------- | ------------------------ | ---- |------------------------------------------------------------------| 3852| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created. | 3853| 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.)| 3854 3855**Error codes** 3856 3857For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3858 3859| ID| Error Message | 3860|-------|---------------------------| 3861| 202 | Not System Application. | 3862 3863**Example** 3864 3865```ts 3866function unregisterLcdFlashStatus(photoSession: camera.PhotoSession): void { 3867 photoSession.off('lcdFlashStatus'); 3868} 3869``` 3870 3871## FocusTrackingMode<sup>15+</sup> 3872 3873Enumerates the focus tracking modes. 3874 3875**System capability**: SystemCapability.Multimedia.Camera.Core 3876 3877| Name| Value | Description | 3878| ---- | ---- | ------ | 3879| AUTO | 0 | Automatic.| 3880 3881## FocusTrackingInfo<sup>15+</sup> 3882 3883Describes the focus tracking information, which is obtained by calling VideoSessionForSys.[on('focusTrackingInfoAvailable')](#onfocustrackinginfoavailable15). 3884 3885**System capability**: SystemCapability.Multimedia.Camera.Core 3886 3887| Name | Type | Read-only| Optional| Description | 3888| -------------- | ----------------------------------------- | ---- | ---- | ---------- | 3889| trackingMode | [FocusTrackingMode](#focustrackingmode15) | No | No | Tracing mode.| 3890| trackingRegion | [Rect](arkts-apis-camera-i.md#rect) | No | No | Tracking region.| 3891 3892## LightStatus<sup>18+</sup> 3893 3894Enumerates the camera light statuses, which are obtained by calling VideoSessionForSys.[on('lightStatusChange')](#onlightstatuschange18). 3895 3896**System API**: This is a system API. 3897 3898**System capability**: SystemCapability.Multimedia.Camera.Core 3899 3900| Name | Value | Description | 3901|--------------| ---- |-------| 3902| NORMAL | 0 | Normal lighting conditions.| 3903| INSUFFICIENT | 1 | Insufficient lighting (too dark).| 3904 3905## VideoSessionForSys<sup>11+</sup> 3906 3907VideoSessionForSys extends VideoSession, Beauty, ColorEffect, ColorManagement, Aperture, ColorReservation 3908 3909Implements a video session for system applications, which sets the parameters of the normal video mode and saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera. It inherits from [Session](arkts-apis-camera-Session.md). 3910 3911**System API**: This is a system API. 3912 3913**System capability**: SystemCapability.Multimedia.Camera.Core 3914 3915## VideoSession<sup>11+</sup> 3916 3917VideoSession extends Session, Flash, AutoExposure, Focus, Zoom, Stabilization, ColorManagement 3918 3919Implements a video session, which sets the parameters of the normal video mode and saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera. It inherits from [Session](arkts-apis-camera-Session.md). 3920 3921### on('macroStatusChanged')<sup>11+</sup> 3922 3923on(type: 'macroStatusChanged', callback: AsyncCallback\<boolean\>): void 3924 3925Subscribes to macro state change events. This API uses an asynchronous callback to return the result. 3926 3927**System API**: This is a system API. 3928 3929**System capability**: SystemCapability.Multimedia.Camera.Core 3930 3931**Parameters** 3932 3933| Name | Type | Mandatory| Description | 3934| -------- | ----------------------------------------- | ---- | ------------------------ | 3935| type | string | Yes | Event type. The value is fixed at **'macroStatusChanged'**. The event can be listened for when a session is created.| 3936| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the macro state. **true** if enabled, **false** otherwise. | 3937 3938**Error codes** 3939 3940For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3941 3942| ID| Error Message | 3943|-------|---------------------------| 3944| 202 | Not System Application. | 3945 3946**Example** 3947 3948```ts 3949import { BusinessError } from '@kit.BasicServicesKit'; 3950 3951function callback(err: BusinessError, macroStatus: boolean): void { 3952 if (err !== undefined && err.code !== 0) { 3953 console.error(`Callback Error, errorCode: ${err.code}`); 3954 return; 3955 } 3956 console.info(`Macro state: ${macroStatus}`); 3957} 3958 3959function registerMacroStatusChanged(videoSession: camera.VideoSession): void { 3960 videoSession.on('macroStatusChanged', callback); 3961} 3962``` 3963 3964### off('macroStatusChanged')<sup>11+</sup> 3965 3966off(type: 'macroStatusChanged', callback?: AsyncCallback\<boolean\>): void 3967 3968Unsubscribes from macro state change events. 3969 3970**System API**: This is a system API. 3971 3972**System capability**: SystemCapability.Multimedia.Camera.Core 3973 3974**Parameters** 3975 3976| Name | Type | Mandatory| Description | 3977| -------- | ------------------------ | ---- | ------------------------ | 3978| type | string | Yes | Event type. The value is fixed at **'macroStatusChanged'**. The event can be listened for when a session is created.| 3979| callback | AsyncCallback\<boolean\> | No | Callback used to return the macro state. **true** if enabled, **false** otherwise. 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.)| 3980 3981**Error codes** 3982 3983For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 3984 3985| ID| Error Message | 3986|-------|---------------------------| 3987| 202 | Not System Application. | 3988 3989**Example** 3990 3991```ts 3992function unregisterMacroStatusChanged(videoSession: camera.VideoSession): void { 3993 videoSession.off('macroStatusChanged'); 3994} 3995``` 3996 3997### on('lcdFlashStatus')<sup>13+</sup> 3998 3999on(type: 'lcdFlashStatus', callback: AsyncCallback\<LcdFlashStatus\>): void 4000 4001Subscribes to LCD flash status change events. This API uses an asynchronous callback to return the result. 4002 4003**System API**: This is a system API. 4004 4005**System capability**: SystemCapability.Multimedia.Camera.Core 4006 4007**Parameters** 4008 4009| Name | Type | Mandatory| Description | 4010| -------- | ----------------------------------------- | ---- |------------------------------------------| 4011| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created.| 4012| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | Yes | Callback used to return the LCD flash status change. | 4013 4014**Error codes** 4015 4016For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4017 4018| ID| Error Message | 4019|-------|---------------------------| 4020| 202 | Not System Application. | 4021 4022**Example** 4023 4024```ts 4025import { BusinessError } from '@kit.BasicServicesKit'; 4026 4027function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 4028 if (err !== undefined && err.code !== 0) { 4029 console.error(`Callback Error, errorCode: ${err.code}`); 4030 return; 4031 } 4032 console.info(`isLcdFlashNeeded: ${lcdFlashStatus.isLcdFlashNeeded}`); 4033 console.info(`lcdCompensation: ${lcdFlashStatus.lcdCompensation}`); 4034} 4035 4036function registerLcdFlashStatus(videoSession: camera.VideoSession): void { 4037 videoSession.on('lcdFlashStatus', callback); 4038} 4039``` 4040 4041### off('lcdFlashStatus')<sup>13+</sup> 4042 4043off(type: 'lcdFlashStatus', callback?: AsyncCallback\<LcdFlashStatus\>): void 4044 4045Unsubscribes from LCD flash status change events. 4046 4047**System API**: This is a system API. 4048 4049**System capability**: SystemCapability.Multimedia.Camera.Core 4050 4051**Parameters** 4052 4053| Name | Type | Mandatory| Description | 4054| -------- | ------------------------ | ---- |------------------------------------------------------------------| 4055| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created. | 4056| 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.)| 4057 4058**Error codes** 4059 4060For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4061 4062| ID| Error Message | 4063|-------|---------------------------| 4064| 202 | Not System Application. | 4065 4066**Example** 4067 4068```ts 4069function unregisterLcdFlashStatus(videoSession: camera.VideoSession): void { 4070 videoSession.off('lcdFlashStatus'); 4071} 4072``` 4073 4074### on('focusTrackingInfoAvailable')<sup>15+</sup> 4075 4076on(type: 'focusTrackingInfoAvailable', callback: Callback\<FocusTrackingInfo\>): void 4077 4078Subscribes to focus tracking information events. This API uses an asynchronous callback to return the result. 4079 4080**System API**: This is a system API. 4081 4082**System capability**: SystemCapability.Multimedia.Camera.Core 4083 4084**Parameters** 4085 4086| Name | Type | Mandatory| Description | 4087| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | 4088| type | string | Yes | Event type. The value is fixed at **'focusTrackingInfoAvailable'**. The event can be listened for when a VideoSessionForSys object is created.| 4089| callback | Callback\<[FocusTrackingInfo](#focustrackinginfo15)\> | Yes | Callback used to return the focus tracking information. | 4090 4091**Error codes** 4092 4093For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4094 4095| ID| Error Message | 4096| -------- | ----------------------- | 4097| 202 | Not System Application. | 4098 4099**Example** 4100 4101```ts 4102function callback(focusTrackingInfo: camera.FocusTrackingInfo): void { 4103 console.info(`Focus tracking mode: ${focusTrackingInfo.trackingMode}`); 4104 console.info(`Focus tracking Region: topLeftX ${focusTrackingInfo.trackingRegion.topLeftX} 4105 topLeftY ${focusTrackingInfo.trackingRegion.topLeftY} 4106 width ${focusTrackingInfo.trackingRegion.width} 4107 height ${focusTrackingInfo.trackingRegion.height}`); 4108} 4109 4110function registerFocusTrakingInfoChanged(session: camera.VideoSessionForSys): void { 4111 session.on('focusTrackingInfoAvailable', callback); 4112} 4113``` 4114 4115### off('focusTrackingInfoAvailable')<sup>15+</sup> 4116 4117off(type: 'focusTrackingInfoAvailable', callback?: Callback\<FocusTrackingInfo\>): void 4118 4119Unsubscribes from focus tracking information events. 4120 4121**System API**: This is a system API. 4122 4123**System capability**: SystemCapability.Multimedia.Camera.Core 4124 4125**Parameters** 4126 4127| Name | Type | Mandatory| Description | 4128| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | 4129| type | string | Yes | Event type. The value is fixed at **'focusTrackingInfoAvailable'**. The event can be listened for when a VideoSessionForSys object is created.| 4130| callback | Callback\<[FocusTrackingInfo](#focustrackinginfo15)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('focusTrackingInfoAvailable')** with the specified callback is canceled. (The callback object cannot be an anonymous function.)| 4131 4132**Error codes** 4133 4134For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4135 4136| ID| Error Message | 4137| -------- | ----------------------- | 4138| 202 | Not System Application. | 4139 4140**Example** 4141 4142```ts 4143function unregisterFocusTrakingInfoChanged(session: camera.VideoSessionForSys): void { 4144 session.off('focusTrackingInfoAvailable'); 4145} 4146``` 4147 4148### on('lightStatusChange')<sup>18+</sup> 4149 4150on(type: 'lightStatusChange', callback: AsyncCallback\<LightStatus\>): void 4151 4152Subscribes to camera light status changes. This API uses an asynchronous callback to return the result. 4153 4154**System API**: This is a system API. 4155 4156**System capability**: SystemCapability.Multimedia.Camera.Core 4157 4158**Parameters** 4159 4160| Name | Type | Mandatory| Description | 4161| -------- |------------------------------------------------| ---- |---------------------------------------------------------------------------------| 4162| type | string | Yes | Event type. The value is fixed at **'lightStatusChange'**.<br>The event can be listened for when a VideoSessionForSys object is created.| 4163| callback | AsyncCallback\<[LightStatus](#lightstatus18)\> | Yes | Callback used to return the light status information. | 4164 4165**Error codes** 4166 4167For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 4168 4169| ID| Error Message | 4170| -------- | ----------------------- | 4171| 202 | Not System Application. | 4172 4173**Example** 4174 4175```ts 4176import { BusinessError } from '@kit.BasicServicesKit'; 4177 4178function handleLightStatusCallback(err: BusinessError, lightStatus: camera.LightStatus) : void { 4179 if (err !== undefined && err.code !== 0) { 4180 console.error(`Callback Error, errorCode: ${err.code}`); 4181 return; 4182 } 4183 console.info(`lightStatus: ${lightStatus}`); 4184} 4185 4186function handleLightStatusOn(mSession: camera.VideoSessionForSys): void { 4187 console.info('handleLightStatusOn'); 4188 try { 4189 mSession.on('lightStatusChange', handleLightStatusCallback); 4190 } catch (error) { 4191 let err = error as BusinessError; 4192 console.error(`handleLightStatusOn err:${err}`); 4193 } 4194} 4195``` 4196 4197### off('lightStatusChange')<sup>18+</sup> 4198 4199off(type: 'lightStatusChange', callback?: AsyncCallback\<LightStatus\>): void 4200 4201Unsubscribes from camera light status changes. 4202 4203**System API**: This is a system API. 4204 4205**System capability**: SystemCapability.Multimedia.Camera.Core 4206 4207**Parameters** 4208 4209| Name | Type | Mandatory| Description | 4210| -------- |------------------------------------------------|----|----------------------------------------------------------------------------------| 4211| type | string | Yes | Event type. The value is fixed at **'lightStatusChange'**.<br>The event can be listened for when a VideoSessionForSys object is created.| 4212| callback | AsyncCallback\<[LightStatus](#lightstatus18)\> | No | Callback used to return the result. This parameter is optional. If this parameter is specified, the subscription to the specified event **on('lightStatusChange')** with the specified callback is canceled. (The callback object cannot be an anonymous function.) | 4213 4214**Error codes** 4215 4216For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 4217 4218| ID| Error Message | 4219| -------- | ----------------------- | 4220| 202 | Not System Application. | 4221 4222**Example** 4223 4224```ts 4225import { BusinessError } from '@kit.BasicServicesKit'; 4226 4227function LightStatusCallback(err: BusinessError, lightStatus: camera.LightStatus) : void { 4228 if (err !== undefined && err.code !== 0) { 4229 console.error(`Callback Error, errorCode: ${err.code}`); 4230 return; 4231 } 4232 console.info(`lightStatus: ${lightStatus}`); 4233} 4234 4235function handleLightStatusOff(mSession: camera.VideoSessionForSys): void { 4236 console.info('handleLightStatusOff'); 4237 try { 4238 mSession.on('lightStatusChange', LightStatusCallback); 4239 } catch (error) { 4240 let err = error as BusinessError; 4241 console.error(`handleLightStatusOff err:${err}`); 4242 } 4243} 4244``` 4245 4246## PortraitPhotoSession<sup>11+</sup> 4247 4248PortraitPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, Beauty, ColorEffect, ColorManagement, Portrait, Aperture 4249 4250Implements a portrait photo session, which sets the parameters of the portrait photo mode and saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera. It inherits from [Session](arkts-apis-camera-Session.md). 4251 4252### on('error')<sup>11+</sup> 4253 4254on(type: 'error', callback: ErrorCallback): void 4255 4256Subscribes to PortraitSession error events. This API uses an asynchronous callback to return the result. 4257 4258**System API**: This is a system API. 4259 4260**System capability**: SystemCapability.Multimedia.Camera.Core 4261 4262**Parameters** 4263 4264| Name | Type | Mandatory| Description | 4265| -------- | --------------------------------- | ---- | ------------------------------ | 4266| 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](arkts-apis-camera-Session.md#beginconfig11), [commitConfig](arkts-apis-camera-Session.md#commitconfig11-1), and [addInput](arkts-apis-camera-Session.md#addinput11).| 4267| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode). | 4268 4269**Example** 4270 4271```ts 4272import { BusinessError } from '@kit.BasicServicesKit'; 4273 4274function callback(err: BusinessError): void { 4275 console.error(`Portrait photo session error code: ${err.code}`); 4276} 4277 4278function registerSessionError(portraitPhotoSession: camera.PortraitPhotoSession): void { 4279 portraitPhotoSession.on('error', callback); 4280} 4281``` 4282 4283### off('error')<sup>11+</sup> 4284 4285off(type: 'error', callback?: ErrorCallback): void 4286 4287Unsubscribes from PortraitSession error events. 4288 4289**System API**: This is a system API. 4290 4291**System capability**: SystemCapability.Multimedia.Camera.Core 4292 4293**Parameters** 4294 4295| Name | Type | Mandatory| Description | 4296| -------- | -------------------------- | ---- | ------------------------------ | 4297| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 4298| 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.) | 4299 4300**Example** 4301 4302```ts 4303function unregisterSessionError(portraitPhotoSession: camera.PortraitPhotoSession): void { 4304 portraitPhotoSession.off('error'); 4305} 4306``` 4307 4308### on('focusStateChange')<sup>11+</sup> 4309 4310on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4311 4312Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 4313 4314**System API**: This is a system API. 4315 4316**System capability**: SystemCapability.Multimedia.Camera.Core 4317 4318**Parameters** 4319 4320| Name | Type | Mandatory| Description | 4321| -------- | ---------------- | ---- | ------------------------ | 4322| 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.| 4323| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | Yes | Callback used to return the focus state change. | 4324 4325**Example** 4326 4327```ts 4328import { BusinessError } from '@kit.BasicServicesKit'; 4329 4330function callback(err: BusinessError, focusState: camera.FocusState): void { 4331 if (err !== undefined && err.code !== 0) { 4332 console.error(`Callback Error, errorCode: ${err.code}`); 4333 return; 4334 } 4335 console.info(`Focus state: ${focusState}`); 4336} 4337 4338function registerFocusStateChange(portraitPhotoSession: camera.PortraitPhotoSession): void { 4339 portraitPhotoSession.on('focusStateChange', callback); 4340} 4341``` 4342 4343### off('focusStateChange')<sup>11+</sup> 4344 4345off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4346 4347Unsubscribes from focus state change events. 4348 4349**System API**: This is a system API. 4350 4351**System capability**: SystemCapability.Multimedia.Camera.Core 4352 4353**Parameters** 4354 4355| Name | Type | Mandatory| Description | 4356| -------- | ----------------------------------------- | ---- | ------------------------ | 4357| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 4358| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.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.) | 4359 4360**Example** 4361 4362```ts 4363function unregisterFocusStateChange(portraitPhotoSession: camera.PortraitPhotoSession): void { 4364 portraitPhotoSession.off('focusStateChange'); 4365} 4366``` 4367 4368### on('smoothZoomInfoAvailable')<sup>11+</sup> 4369 4370on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 4371 4372Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 4373 4374**System API**: This is a system API. 4375 4376**System capability**: SystemCapability.Multimedia.Camera.Core 4377 4378**Parameters** 4379 4380| Name | Type | Mandatory| Description | 4381| -------- | ----------------------- | ---- | ------------------------ | 4382| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 4383| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 4384 4385**Example** 4386 4387```ts 4388import { BusinessError } from '@kit.BasicServicesKit'; 4389 4390function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 4391 if (err !== undefined && err.code !== 0) { 4392 console.error(`Callback Error, errorCode: ${err.code}`); 4393 return; 4394 } 4395 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 4396} 4397 4398function registerSmoothZoomInfo(portraitPhotoSession: camera.PortraitPhotoSession): void { 4399 portraitPhotoSession.on('smoothZoomInfoAvailable', callback); 4400} 4401``` 4402 4403### off('smoothZoomInfoAvailable')<sup>11+</sup> 4404 4405off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 4406 4407Unsubscribes from smooth zoom state change events. 4408 4409**System API**: This is a system API. 4410 4411**System capability**: SystemCapability.Multimedia.Camera.Core 4412 4413**Parameters** 4414 4415| Name | Type | Mandatory| Description | 4416| -------- | ----------------------------------------- | ---- | ------------------------ | 4417| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 4418| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.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.) | 4419 4420**Example** 4421 4422```ts 4423function unregisterSmoothZoomInfo(portraitPhotoSession: camera.PortraitPhotoSession): void { 4424 portraitPhotoSession.off('smoothZoomInfoAvailable'); 4425} 4426``` 4427 4428### on('lcdFlashStatus')<sup>13+</sup> 4429 4430on(type: 'lcdFlashStatus', callback: AsyncCallback\<LcdFlashStatus\>): void 4431 4432Subscribes to LCD flash status change events. This API uses an asynchronous callback to return the result. 4433 4434**System API**: This is a system API. 4435 4436**System capability**: SystemCapability.Multimedia.Camera.Core 4437 4438**Parameters** 4439 4440| Name | Type | Mandatory| Description | 4441| -------- | ----------------------------------------- | ---- |------------------------------------------| 4442| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created.| 4443| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | Yes | Callback used to return the LCD flash status change. | 4444 4445**Error codes** 4446 4447For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4448 4449| ID| Error Message | 4450|-------|---------------------------| 4451| 202 | Not System Application. | 4452 4453**Example** 4454 4455```ts 4456import { BusinessError } from '@kit.BasicServicesKit'; 4457 4458function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 4459 if (err !== undefined && err.code !== 0) { 4460 console.error(`Callback Error, errorCode: ${err.code}`); 4461 return; 4462 } 4463 console.info(`isLcdFlashNeeded: ${lcdFlashStatus.isLcdFlashNeeded}`); 4464 console.info(`lcdCompensation: ${lcdFlashStatus.lcdCompensation}`); 4465} 4466 4467function registerLcdFlashStatus(portraitPhotoSession: camera.PortraitPhotoSession): void { 4468 portraitPhotoSession.on('lcdFlashStatus', callback); 4469} 4470``` 4471 4472### off('lcdFlashStatus')<sup>13+</sup> 4473 4474off(type: 'lcdFlashStatus', callback?: AsyncCallback\<LcdFlashStatus\>): void 4475 4476Unsubscribes from LCD flash status change events. 4477 4478**System API**: This is a system API. 4479 4480**System capability**: SystemCapability.Multimedia.Camera.Core 4481 4482**Parameters** 4483 4484| Name | Type | Mandatory| Description | 4485| -------- | ------------------------ | ---- |------------------------------------------------------------------| 4486| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created. | 4487| 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.)| 4488 4489**Error codes** 4490 4491For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4492 4493| ID| Error Message | 4494|-------|---------------------------| 4495| 202 | Not System Application. | 4496 4497**Example** 4498 4499```ts 4500function unregisterLcdFlashStatus(portraitPhotoSession: camera.PortraitPhotoSession): void { 4501 portraitPhotoSession.off('lcdFlashStatus'); 4502} 4503``` 4504 4505## NightPhotoSession<sup>11+</sup> 4506 4507NightPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ColorManagement, ManualExposure 4508 4509Implements a night photo session, which sets the parameters of the night photo mode and saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera. It inherits from [Session](arkts-apis-camera-Session.md). 4510 4511### on('error')<sup>11+</sup> 4512 4513on(type: 'error', callback: ErrorCallback): void 4514 4515Subscribes to NightSession error events. This API uses an asynchronous callback to return the result. 4516 4517**System API**: This is a system API. 4518 4519**System capability**: SystemCapability.Multimedia.Camera.Core 4520 4521**Parameters** 4522 4523| Name | Type | Mandatory| Description | 4524| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 4525| 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](arkts-apis-camera-Session.md#beginconfig11), [commitConfig](arkts-apis-camera-Session.md#commitconfig11-1), and [addInput](arkts-apis-camera-Session.md#addinput11).| 4526| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode).| 4527 4528**Example** 4529 4530```ts 4531import { BusinessError } from '@kit.BasicServicesKit'; 4532 4533function callback(err: BusinessError): void { 4534 console.error(`Night photo session error code: ${err.code}`); 4535} 4536 4537function registerSessionError(nightPhotoSession: camera.NightPhotoSession): void { 4538 nightPhotoSession.on('error', callback); 4539} 4540``` 4541 4542### off('error')<sup>11+</sup> 4543 4544off(type: 'error', callback?: ErrorCallback): void 4545 4546Unsubscribes from NightSession error events. 4547 4548**System API**: This is a system API. 4549 4550**System capability**: SystemCapability.Multimedia.Camera.Core 4551 4552**Parameters** 4553 4554| Name | Type | Mandatory| Description | 4555| -------- | ------------------------ | ---- | ------------------------------ | 4556| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 4557| 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.) | 4558 4559**Example** 4560 4561```ts 4562function unregisterSessionError(nightPhotoSession: camera.NightPhotoSession): void { 4563 nightPhotoSession.off('error'); 4564} 4565``` 4566 4567### on('focusStateChange')<sup>11+</sup> 4568 4569on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4570 4571Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 4572 4573**System API**: This is a system API. 4574 4575**System capability**: SystemCapability.Multimedia.Camera.Core 4576 4577**Parameters** 4578 4579| Name | Type | Mandatory| Description | 4580| -------- | ---------------- | ---- | ------------------------ | 4581| 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.| 4582| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | Yes | Callback used to return the focus state change. | 4583 4584**Example** 4585 4586```ts 4587import { BusinessError } from '@kit.BasicServicesKit'; 4588 4589function callback(err: BusinessError, focusState: camera.FocusState): void { 4590 if (err !== undefined && err.code !== 0) { 4591 console.error(`Callback Error, errorCode: ${err.code}`); 4592 return; 4593 } 4594 console.info(`Focus state: ${focusState}`); 4595} 4596 4597function registerFocusStateChange(nightPhotoSession: camera.NightPhotoSession): void { 4598 nightPhotoSession.on('focusStateChange', callback); 4599} 4600``` 4601 4602### off('focusStateChange')<sup>11+</sup> 4603 4604off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4605 4606Unsubscribes from focus state change events. 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.| 4617| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.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.) | 4618 4619**Example** 4620 4621```ts 4622function unregisterFocusStateChange(nightPhotoSession: camera.NightPhotoSession): void { 4623 nightPhotoSession.off('focusStateChange'); 4624} 4625``` 4626 4627### on('smoothZoomInfoAvailable')<sup>11+</sup> 4628 4629on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 4630 4631Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 4632 4633**System API**: This is a system API. 4634 4635**System capability**: SystemCapability.Multimedia.Camera.Core 4636 4637**Parameters** 4638 4639| Name | Type | Mandatory| Description | 4640| -------- | ----------------------- | ---- | ------------------------ | 4641| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 4642| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 4643 4644**Example** 4645 4646```ts 4647import { BusinessError } from '@kit.BasicServicesKit'; 4648 4649function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 4650 if (err !== undefined && err.code !== 0) { 4651 console.error(`Callback Error, errorCode: ${err.code}`); 4652 return; 4653 } 4654 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 4655} 4656 4657function registerSmoothZoomInfo(nightPhotoSession: camera.NightPhotoSession): void { 4658 nightPhotoSession.on('smoothZoomInfoAvailable', callback); 4659} 4660``` 4661 4662### off('smoothZoomInfoAvailable')<sup>11+</sup> 4663 4664off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 4665 4666Unsubscribes from smooth zoom state change events. 4667 4668**System API**: This is a system API. 4669 4670**System capability**: SystemCapability.Multimedia.Camera.Core 4671 4672**Parameters** 4673 4674| Name | Type | Mandatory| Description | 4675| -------- | ----------------------------------------- | ---- | ------------------------ | 4676| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 4677| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.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.) | 4678 4679**Example** 4680 4681```ts 4682function unregisterSmoothZoomInfo(nightPhotoSession: camera.NightPhotoSession): void { 4683 nightPhotoSession.off('smoothZoomInfoAvailable'); 4684} 4685``` 4686 4687### on('lcdFlashStatus')<sup>12+</sup> 4688 4689on(type: 'lcdFlashStatus', callback: AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\>): void 4690 4691Subscribes to LCD flash status change events. This API uses an asynchronous callback to return the result. 4692 4693**System API**: This is a system API. 4694 4695**System capability**: SystemCapability.Multimedia.Camera.Core 4696 4697**Parameters** 4698 4699| Name | Type | Mandatory| Description | 4700| -------- | ----------------------- | ---- | ------------------------ | 4701| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created.| 4702| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | Yes | Callback used to return the LCD flash status change. | 4703 4704**Error codes** 4705 4706For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4707 4708| ID| Error Message | 4709|-------|---------------------------| 4710| 202 | Not System Application. | 4711 4712**Example** 4713 4714```ts 4715import { BusinessError } from '@kit.BasicServicesKit'; 4716 4717function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 4718 if (err !== undefined && err.code !== 0) { 4719 console.error(`Callback Error, errorCode: ${err.code}`); 4720 return; 4721 } 4722 console.info(`lcdFlashStatus: ${lcdFlashStatus}`); 4723} 4724 4725function registerLcdFlashStatus(nightPhotoSession: camera.NightPhotoSession): void { 4726 nightPhotoSession.on('lcdFlashStatus', callback); 4727} 4728``` 4729 4730### off('lcdFlashStatus')<sup>12+</sup> 4731 4732off(type: 'lcdFlashStatus', callback?: AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\>): void 4733 4734Unsubscribes from LCD flash status change events. 4735 4736**System API**: This is a system API. 4737 4738**System capability**: SystemCapability.Multimedia.Camera.Core 4739 4740**Parameters** 4741 4742| Name | Type | Mandatory| Description | 4743| -------- | ----------------------------------------- | ---- | ------------------------ | 4744| type | string | Yes | Event type. The value is fixed at **'lcdFlashStatus'**. The event can be listened for when a session is created.| 4745| 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.) | 4746 4747**Error codes** 4748 4749For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4750 4751| ID| Error Message | 4752|-------|---------------------------| 4753| 202 | Not System Application. | 4754 4755**Example** 4756 4757```ts 4758function unregisterLcdFlashStatus(nightPhotoSession: camera.NightPhotoSession): void { 4759 nightPhotoSession.off('lcdFlashStatus'); 4760} 4761``` 4762 4763## HighResolutionPhotoSession<sup>12+</sup> 4764 4765HighResolutionPhotoSession extends Session, AutoExposure, Focus 4766 4767Implements a high-resolution photo session, which sets the parameters of the high-resolution photo mode and saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera. It inherits from [Session](arkts-apis-camera-Session.md). 4768 4769### on('error')<sup>12+</sup> 4770 4771on(type: 'error', callback: ErrorCallback): void 4772 4773Subscribes to HighResolutionPhotoSession error events. This API uses an asynchronous callback to return the result. 4774 4775**System API**: This is a system API. 4776 4777**System capability**: SystemCapability.Multimedia.Camera.Core 4778 4779**Parameters** 4780 4781| Name | Type | Mandatory| Description | 4782| -------- | --------------------------------- | ---- | ------------------------------ | 4783| 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](arkts-apis-camera-Session.md#beginconfig11), [commitConfig](arkts-apis-camera-Session.md#commitconfig11-1), and [addInput](arkts-apis-camera-Session.md#addinput11).| 4784| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode). | 4785 4786**Error codes** 4787 4788For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4789 4790| ID | Error Message | 4791| --------------- | --------------- | 4792| 202 | Not System Application. | 4793 4794**Example** 4795 4796```ts 4797import { BusinessError } from '@kit.BasicServicesKit'; 4798 4799function callback(err: BusinessError): void { 4800 console.error(`High resolution photo session error code: ${err.code}`); 4801} 4802 4803function registerSessionError(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4804 highResolutionPhotoSession.on('error', callback); 4805} 4806``` 4807### off('error')<sup>12+</sup> 4808 4809off(type: 'error', callback?: ErrorCallback): void 4810 4811Unsubscribes from HighResolutionPhotoSession error events. 4812 4813**System API**: This is a system API. 4814 4815**System capability**: SystemCapability.Multimedia.Camera.Core 4816 4817**Parameters** 4818 4819| Name | Type | Mandatory| Description | 4820| -------- | ------------------------ | ---- | ------------------------------ | 4821| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 4822| 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.) | 4823 4824**Error codes** 4825 4826For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4827 4828| ID | Error Message | 4829| --------------- | --------------- | 4830| 202 | Not System Application. | 4831 4832**Example** 4833 4834```ts 4835function unregisterSessionError(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4836 highResolutionPhotoSession.off('error'); 4837} 4838``` 4839 4840### on('focusStateChange')<sup>12+</sup> 4841 4842on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4843 4844Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 4845 4846**System API**: This is a system API. 4847 4848**System capability**: SystemCapability.Multimedia.Camera.Core 4849 4850**Parameters** 4851 4852| Name | Type | Mandatory| Description | 4853| -------- | ---------------- | ---- | ------------------------ | 4854| 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.| 4855| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | Yes | Callback used to return the focus state change. | 4856 4857**Error codes** 4858 4859For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4860 4861| ID | Error Message | 4862| --------------- | --------------- | 4863| 202 | Not System Application. | 4864 4865**Example** 4866 4867```ts 4868import { BusinessError } from '@kit.BasicServicesKit'; 4869 4870function callback(err: BusinessError, focusState: camera.FocusState): void { 4871 if (err !== undefined && err.code !== 0) { 4872 console.error(`Callback Error, errorCode: ${err.code}`); 4873 return; 4874 } 4875 console.info(`Focus state: ${focusState}`); 4876} 4877 4878function registerFocusStateChange(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4879 highResolutionPhotoSession.on('focusStateChange', callback); 4880} 4881``` 4882 4883### off('focusStateChange')<sup>12+</sup> 4884 4885off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4886 4887Unsubscribes from focus state change events. 4888 4889**System API**: This is a system API. 4890 4891**System capability**: SystemCapability.Multimedia.Camera.Core 4892 4893**Error codes** 4894 4895For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4896 4897| ID | Error Message | 4898| --------------- | --------------- | 4899| 202 | Not System Application. | 4900 4901**Parameters** 4902 4903| Name | Type | Mandatory| Description | 4904| -------- | ----------------------------------------- | ---- | ------------------------ | 4905| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 4906| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.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.) | 4907 4908**Example** 4909 4910```ts 4911function unregisterFocusStateChange(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4912 highResolutionPhotoSession.off('focusStateChange'); 4913} 4914``` 4915 4916## SketchStatusData<sup>11+</sup> 4917 4918Defines the PiP status data. 4919 4920**System API**: This is a system API. 4921 4922**System capability**: SystemCapability.Multimedia.Camera.Core 4923 4924| Name | Type | Read-only| Mandatory| Description | 4925| ------------- | -------- | ---- | ---- | ---------- | 4926| status | number | No | Yes | Status of PiP. The options are 0 (stopped), 1 (started), 2 (stopping), and 3 (starting).| 4927| sketchRatio | number | No | Yes | Zoom ratio of PiP.| 4928 4929## SlowMotionVideoSession<sup>12+</sup> 4930 4931SlowMotionVideoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect 4932 4933Implements a slow-motion video session, which sets the parameters of the slow-motion video mode and saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera. It inherits from [Session](arkts-apis-camera-Session.md). 4934 4935> **NOTE** 4936> 4937> In slow-motion video mode, only preview streams and video streams can be added. 4938### on('error')<sup>12+</sup> 4939 4940on(type: 'error', callback: ErrorCallback): void 4941 4942Subscribes to SlowMotionVideoSession error events. This API uses an asynchronous callback to return the result. 4943 4944**System API**: This is a system API. 4945 4946**System capability**: SystemCapability.Multimedia.Camera.Core 4947 4948**Parameters** 4949 4950| Name | Type | Mandatory| Description | 4951| -------- | --------------------------------- | ---- | ------------------------------ | 4952| 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](arkts-apis-camera-Session.md#beginconfig11), [commitConfig](arkts-apis-camera-Session.md#commitconfig11-1), and [addInput](arkts-apis-camera-Session.md#addinput11).| 4953| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode). | 4954 4955**Error codes** 4956 4957For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4958 4959| ID | Error Message | 4960|---------| --------------- | 4961| 202 | Not System Application. | 4962 4963**Example** 4964 4965```ts 4966import { BusinessError } from '@kit.BasicServicesKit'; 4967 4968function callback(err: BusinessError): void { 4969 console.error(`Portrait photo session error code: ${err.code}`); 4970} 4971 4972function registerSessionError(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4973 slowMotionVideoSession.on('error', callback); 4974} 4975``` 4976 4977### off('error')<sup>12+</sup> 4978 4979off(type: 'error', callback?: ErrorCallback): void 4980 4981Unsubscribes from SlowMotionVideoSession error events. 4982 4983**System API**: This is a system API. 4984 4985**System capability**: SystemCapability.Multimedia.Camera.Core 4986 4987**Parameters** 4988 4989| Name | Type | Mandatory| Description | 4990| -------- | -------------------------- | ---- | ------------------------------ | 4991| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 4992| 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.) | 4993 4994**Error codes** 4995 4996For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 4997 4998| ID | Error Message | 4999|---------| --------------- | 5000| 202 | Not System Application. | 5001 5002**Example** 5003 5004```ts 5005function unregisterSessionError(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 5006 slowMotionVideoSession.off('error'); 5007} 5008``` 5009 5010### on('focusStateChange')<sup>12+</sup> 5011 5012on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 5013 5014Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 5015 5016**System API**: This is a system API. 5017 5018**System capability**: SystemCapability.Multimedia.Camera.Core 5019 5020**Parameters** 5021 5022| Name | Type | Mandatory| Description | 5023| -------- | ---------------- | ---- | ------------------------ | 5024| 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.| 5025| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | Yes | Callback used to return the focus state change. | 5026 5027**Error codes** 5028 5029For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5030 5031| ID | Error Message | 5032|---------| --------------- | 5033| 202 | Not System Application. | 5034 5035**Example** 5036 5037```ts 5038import { BusinessError } from '@kit.BasicServicesKit'; 5039 5040function callback(err: BusinessError, focusState: camera.FocusState): void { 5041 if (err !== undefined && err.code !== 0) { 5042 console.error(`Callback Error, errorCode: ${err.code}`); 5043 return; 5044 } 5045 console.info(`Focus state: ${focusState}`); 5046} 5047 5048function registerFocusStateChange(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 5049 slowMotionVideoSession.on('focusStateChange', callback); 5050} 5051``` 5052 5053### off('focusStateChange')<sup>12+</sup> 5054 5055off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 5056 5057Unsubscribes from focus state change events. 5058 5059**System API**: This is a system API. 5060 5061**System capability**: SystemCapability.Multimedia.Camera.Core 5062 5063**Parameters** 5064 5065| Name | Type | Mandatory| Description | 5066| -------- | ----------------------------------------- | ---- | ------------------------ | 5067| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 5068| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.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.) | 5069 5070**Error codes** 5071 5072For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5073 5074| ID | Error Message | 5075|---------| --------------- | 5076| 202 | Not System Application. | 5077 5078**Example** 5079 5080```ts 5081function unregisterFocusStateChange(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 5082 slowMotionVideoSession.off('focusStateChange'); 5083} 5084``` 5085 5086### on('smoothZoomInfoAvailable')<sup>12+</sup> 5087 5088on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 5089 5090Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 5091 5092**System API**: This is a system API. 5093 5094**System capability**: SystemCapability.Multimedia.Camera.Core 5095 5096**Parameters** 5097 5098| Name | Type | Mandatory| Description | 5099| -------- | ----------------------- | ---- | ------------------------ | 5100| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 5101| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 5102 5103**Error codes** 5104 5105For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5106 5107| ID | Error Message | 5108|---------| --------------- | 5109| 202 | Not System Application. | 5110 5111**Example** 5112 5113```ts 5114import { BusinessError } from '@kit.BasicServicesKit'; 5115 5116function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 5117 if (err !== undefined && err.code !== 0) { 5118 console.error(`Callback Error, errorCode: ${err.code}`); 5119 return; 5120 } 5121 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 5122} 5123 5124function registerSmoothZoomInfo(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 5125 slowMotionVideoSession.on('smoothZoomInfoAvailable', callback); 5126} 5127``` 5128 5129### off('smoothZoomInfoAvailable')<sup>12+</sup> 5130 5131off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 5132 5133Unsubscribes from smooth zoom state change events. 5134 5135**System API**: This is a system API. 5136 5137**System capability**: SystemCapability.Multimedia.Camera.Core 5138 5139**Parameters** 5140 5141| Name | Type | Mandatory| Description | 5142| -------- | ----------------------------------------- | ---- | ------------------------ | 5143| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 5144| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.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.) | 5145 5146**Error codes** 5147 5148For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5149 5150| ID | Error Message | 5151|---------| --------------- | 5152| 202 | Not System Application. | 5153 5154**Example** 5155 5156```ts 5157function unregisterSmoothZoomInfo(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 5158 slowMotionVideoSession.off('smoothZoomInfoAvailable'); 5159} 5160``` 5161 5162### on('slowMotionStatus')<sup>12+</sup> 5163 5164on(type: 'slowMotionStatus', callback: AsyncCallback\<SlowMotionStatus\>): void 5165 5166Subscribes to slow-motion status change events. This API uses an asynchronous callback to return the result. 5167 5168**System API**: This is a system API. 5169 5170**System capability**: SystemCapability.Multimedia.Camera.Core 5171 5172**Parameters** 5173 5174| Name | Type | Mandatory| Description | 5175| -------- |---------------------------------------------------------------------------| ---- |--------------------------------------------| 5176| type | string | Yes | Event type. The value is fixed at **'slowMotionStatus'**. The event can be listened for when a session is created.| 5177| callback | AsyncCallback\<[SlowMotionStatus](#slowmotionstatus12)\> | Yes | Callback used to return the slow-motion status change. | 5178 5179**Error codes** 5180 5181For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5182 5183| ID | Error Message | 5184|---------| --------------- | 5185| 202 | Not System Application. | 5186 5187**Example** 5188 5189```ts 5190import { BusinessError } from '@kit.BasicServicesKit'; 5191 5192function callback(err: BusinessError, slowMotionStatus: camera.SlowMotionStatus): void { 5193 if (err !== undefined && err.code !== 0) { 5194 console.error(`Callback Error, errorCode: ${err.code}`); 5195 return; 5196 } 5197 console.info(`The slow motion status: ${slowMotionStatus}`); 5198} 5199 5200function registerSlowMotionStatus(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 5201 slowMotionVideoSession.on('slowMotionStatus', callback); 5202} 5203``` 5204 5205### off('slowMotionStatus')<sup>12+</sup> 5206 5207off(type: 'slowMotionStatus', callback?: AsyncCallback\<SlowMotionStatus\>): void 5208 5209Unsubscribes from slow-motion status change events. 5210 5211**System API**: This is a system API. 5212 5213**System capability**: SystemCapability.Multimedia.Camera.Core 5214 5215**Parameters** 5216 5217| Name | Type | Mandatory| Description | 5218| -------- | ----------------------------------------- | ---- | ------------------------ | 5219| type | string | Yes | Event type. The value is fixed at **'slowMotionStatus'**. The event can be listened for when a session is created.| 5220| 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](arkts-apis-camera-e.md#cameraerrorcode) is returned. | 5221 5222**Error codes** 5223 5224For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5225 5226| ID | Error Message | 5227|---------| --------------- | 5228| 202 | Not System Application. | 5229 5230**Example** 5231 5232```ts 5233function unregisterSlowMotionStatus(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 5234 slowMotionVideoSession.off('slowMotionStatus'); 5235} 5236``` 5237### isSlowMotionDetectionSupported<sup>12+</sup> 5238 5239isSlowMotionDetectionSupported(): boolean 5240 5241Checks whether the device supports slow-motion detection. 5242 5243> **NOTE** 5244> 5245> This API must be called after [commitConfig](arkts-apis-camera-Session.md#commitconfig11-1) is called. 5246 5247**System API**: This is a system API. 5248 5249**System capability**: SystemCapability.Multimedia.Camera.Core 5250 5251**Return value** 5252 5253| Type | Description | 5254| ---------- |----------------------------------------------------------------------------------------| 5255| boolean | Check result for the support of slow-motion detection. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 5256 5257**Error codes** 5258 5259For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5260 5261| ID | Error Message | 5262|---------| --------------- | 5263| 202 | Not System Application. | 5264 5265**Example** 5266 5267```ts 5268import { BusinessError } from '@kit.BasicServicesKit'; 5269 5270function isSlowMotionDetectionSupported(slowMotionVideoSession: camera.SlowMotionVideoSession): boolean { 5271 let isSupported: boolean = false; 5272 try { 5273 isSupported = slowMotionVideoSession.isSlowMotionDetectionSupported(); 5274 } catch (error) { 5275 // If the operation fails, error.code is returned and processed. 5276 let err = error as BusinessError; 5277 console.error(`The isFocusModeSupported call failed. error code: ${err.code}`); 5278 } 5279 return isSupported; 5280} 5281``` 5282 5283### setSlowMotionDetectionArea<sup>12+</sup> 5284 5285setSlowMotionDetectionArea(area: Rect): void 5286 5287Sets an area for slow-motion detection. 5288 5289> **NOTE** 5290> 5291> Before the setting, call [isSlowMotionDetectionSupported](#isslowmotiondetectionsupported12) to check whether the device supports slow-motion detection. 5292This API must be called after [commitConfig](arkts-apis-camera-Session.md#commitconfig11-1) is called. 5293 5294**System API**: This is a system API. 5295 5296**System capability**: SystemCapability.Multimedia.Camera.Core 5297 5298**Parameters** 5299 5300| Name | Type | Mandatory| Description | 5301| -------- | ---------------------------------------------- | ---- | --------------------------- | 5302| area | [Rect](arkts-apis-camera-i.md#rect) | Yes | Area. | 5303 5304**Error codes** 5305 5306For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5307 5308| ID | Error Message | 5309|---------| --------------- | 5310| 202 | Not System Application. | 5311 5312**Example** 5313 5314```ts 5315import { BusinessError } from '@kit.BasicServicesKit'; 5316 5317function setSlowMotionDetectionArea(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 5318 try { 5319 slowMotionVideoSession.setSlowMotionDetectionArea({topLeftX: 0.1, topLeftY: 0.1, width: 0.8, height: 0.8}); 5320 } catch (error) { 5321 // If the operation fails, error.code is returned and processed. 5322 let err = error as BusinessError; 5323 console.error(`The setSlowMotionDetectionArea call failed. error code: ${err.code}`); 5324 } 5325} 5326``` 5327 5328## PanoramaPhotoSession<sup>12+</sup> 5329 5330PanoramaPhotoSession extends Session, Focus, AutoExposure, WhiteBalance, ColorEffect 5331 5332Implements a panoramic photo session, which sets the parameters of the panoramic photo mode and saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera. It inherits from [Session](arkts-apis-camera-Session.md). 5333 5334### on('error')<sup>12+</sup> 5335 5336on(type: 'error', callback: ErrorCallback): void 5337 5338Subscribes to PanoramaPhotoSession error events. This API uses an asynchronous callback to return the result. 5339 5340**System API**: This is a system API. 5341 5342**System capability**: SystemCapability.Multimedia.Camera.Core 5343 5344**Parameters** 5345 5346| Name | Type | Mandatory| Description | 5347| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 5348| 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](arkts-apis-camera-Session.md#beginconfig11), [commitConfig](arkts-apis-camera-Session.md#commitconfig11-1), and [addInput](arkts-apis-camera-Session.md#addinput11).| 5349| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode).| 5350 5351**Example** 5352 5353```ts 5354import { BusinessError } from '@kit.BasicServicesKit'; 5355 5356function callback(err: BusinessError): void { 5357 console.error(`Panorama photo session error code: ${err.code}`); 5358} 5359 5360function registerSessionError(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5361 panoramaPhotoSession.on('error', callback); 5362} 5363``` 5364 5365### off('error')<sup>12+</sup> 5366 5367off(type: 'error', callback?: ErrorCallback): void 5368 5369Unsubscribes from PanoramaPhotoSession error events. 5370 5371**System API**: This is a system API. 5372 5373**System capability**: SystemCapability.Multimedia.Camera.Core 5374 5375**Parameters** 5376 5377| Name | Type | Mandatory| Description | 5378| -------- | ------------------------ | ---- | ------------------------------ | 5379| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 5380| 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.) | 5381 5382**Example** 5383 5384```ts 5385function unregisterSessionError(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5386 panoramaPhotoSession.off('error'); 5387} 5388``` 5389 5390### on('focusStateChange')<sup>12+</sup> 5391 5392on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 5393 5394Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 5395 5396**System API**: This is a system API. 5397 5398**System capability**: SystemCapability.Multimedia.Camera.Core 5399 5400**Parameters** 5401 5402| Name | Type | Mandatory| Description | 5403| -------- | ---------------- | ---- | ------------------------ | 5404| 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.| 5405| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | Yes | Callback used to return the focus state change. | 5406 5407**Example** 5408 5409```ts 5410import { BusinessError } from '@kit.BasicServicesKit'; 5411 5412function callback(err: BusinessError, focusState: camera.FocusState): void { 5413 if (err !== undefined && err.code !== 0) { 5414 console.error(`Callback Error, errorCode: ${err.code}`); 5415 return; 5416 } 5417 console.info(`Focus state: ${focusState}`); 5418} 5419 5420function registerFocusStateChange(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5421 panoramaPhotoSession.on('focusStateChange', callback); 5422} 5423``` 5424 5425### off('focusStateChange')<sup>12+</sup> 5426 5427off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 5428 5429Unsubscribes from focus state change events. 5430 5431**System API**: This is a system API. 5432 5433**System capability**: SystemCapability.Multimedia.Camera.Core 5434 5435**Parameters** 5436 5437| Name | Type | Mandatory| Description | 5438| -------- | ----------------------------------------- | ---- | ------------------------ | 5439| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 5440| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.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.) | 5441 5442**Example** 5443 5444```ts 5445function unregisterFocusStateChange(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5446 panoramaPhotoSession.off('focusStateChange'); 5447} 5448``` 5449 5450## IsoInfo<sup>12+</sup> 5451 5452Describes the ISO information. 5453 5454**System API**: This is a system API. 5455 5456**System capability**: SystemCapability.Multimedia.Camera.Core 5457 5458| Name| Type | Read-only| Optional| Description | 5459| ---- | ------- | ---- |--| -------------- | 5460| iso | number | Yes | Yes| ISO. | 5461 5462--- 5463 5464## ExposureInfo<sup>12+</sup> 5465 5466Describes the exposure information. 5467 5468**System API**: This is a system API. 5469 5470**System capability**: SystemCapability.Multimedia.Camera.Core 5471 5472| Name | Type | Read-only| Optional | Description | 5473| ----------------- | ------- | ---- |-----| ------------------ | 5474| exposureTime | number | Yes | Yes | Exposure time, in ms.| 5475 5476--- 5477 5478## ApertureInfo<sup>12+</sup> 5479 5480Describes the aperture information. 5481 5482**System API**: This is a system API. 5483 5484**System capability**: SystemCapability.Multimedia.Camera.Core 5485 5486| Name | Type | Read-only| Optional | Description | 5487| --------- | ------- | ---- |-----| ---------- | 5488| aperture | number | Yes | Yes | Aperture. | 5489 5490--- 5491 5492## LuminationInfo<sup>12+</sup> 5493 5494Describes the illumination information. 5495 5496**System API**: This is a system API. 5497 5498**System capability**: SystemCapability.Multimedia.Camera.Core 5499 5500| Name | Type | Read-only| Optional | Description | 5501| ----------- | ------- | ---- |-----| ---------- | 5502| lumination | number | Yes | Yes | Illumination. The value range is [0,1].| 5503 5504## CameraFormat 5505 5506Enumerates the camera output formats. 5507 5508**System capability**: SystemCapability.Multimedia.Camera.Core 5509 5510| Name | Value | Description | 5511| ----------------------- | --------- | ------------ | 5512| CAMERA_FORMAT_DNG<sup>12+</sup> | 4 | Raw image in DNG format. **System API**: This is a system API. | 5513| CAMERA_FORMAT_DNG_XDRAW<sup>18+</sup> | 5 | Enhanced raw image in DNG format, where JPG and raw images are packaged in the same file, and up to 16-bit raw data is supported. **System API**: This is a system API. | 5514## ExposureMeteringMode<sup>12+</sup> 5515 5516Enumerates the exposure metering modes. 5517 5518**System API**: This is a system API. 5519 5520**System capability**: SystemCapability.Multimedia.Camera.Core 5521 5522| Name | Value | Description | 5523| ----------------------------- | ---- | ----------- | 5524| MATRIX | 0 | Performs metering on a wide area of the image.| 5525| CENTER | 1 | Performs metering on the entire image, with the center allocated with the maximum weight.| 5526| SPOT | 2 | Performs metering around 2.5% of the metering points.| 5527 5528## AutoExposureQuery<sup>12+</sup> 5529 5530Provides APIs to check whether a device supports an exposure mode or exposure metering mode and obtain the exposure compensation range. 5531 5532### isExposureMeteringModeSupported<sup>12+</sup> 5533 5534isExposureMeteringModeSupported(aeMeteringMode: ExposureMeteringMode): boolean 5535 5536Checks whether an exposure metering mode is supported. 5537 5538**System API**: This is a system API. 5539 5540**System capability**: SystemCapability.Multimedia.Camera.Core 5541 5542**Parameters** 5543 5544| Name | Type | Mandatory | Description | 5545| -------- | -------------------------------| ---- | ----------------------------- | 5546| aeMeteringMode | [ExposureMeteringMode](#exposuremeteringmode12) | Yes | Metering mode. | 5547 5548**Return value** 5549 5550| Type | Description | 5551| ---------- | ----------------------------- | 5552| boolean | Check result for the support of the exposure metering mode. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 5553 5554**Error codes** 5555 5556For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5557 5558| ID | Error Message | 5559| --------------- | --------------- | 5560| 202 | Not System Application. | 5561| 7400101 | Parameter missing or parameter type incorrect. | 5562| 7400103 | Session not config. | 5563 5564 5565**Example** 5566 5567```ts 5568import { BusinessError } from '@kit.BasicServicesKit'; 5569 5570function isExposureMeteringModeSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5571 let isSupported: boolean = false; 5572 try { 5573 isSupported = professionalPhotoSession.isExposureMeteringModeSupported(camera.ExposureMeteringMode.CENTER); 5574 } catch (error) { 5575 // If the operation fails, error.code is returned and processed. 5576 let err = error as BusinessError; 5577 console.error(`The isExposureMeteringModeSupported call failed. error code: ${err.code}`); 5578 } 5579 return isSupported; 5580} 5581``` 5582 5583## AutoExposure 5584 5585AutoExposure extends [AutoExposureQuery](#autoexposurequery12) 5586 5587Provides 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. 5588 5589### getExposureMeteringMode<sup>12+</sup> 5590 5591getExposureMeteringMode(): ExposureMeteringMode 5592 5593Obtains the exposure metering mode in use. 5594 5595**System API**: This is a system API. 5596 5597**System capability**: SystemCapability.Multimedia.Camera.Core 5598 5599**Return value** 5600 5601| Type | Description | 5602| ---------- | ----------------------------- | 5603| [ExposureMeteringMode](#exposuremeteringmode12) | Exposure metering mode obtained. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 5604 5605**Error codes** 5606 5607For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5608 5609| ID | Error Message | 5610| --------------- | --------------- | 5611| 7400103 | Session not config. | 5612| 202 | Not System Application. | 5613 5614**Example** 5615 5616```ts 5617import { BusinessError } from '@kit.BasicServicesKit'; 5618 5619function getExposureMeteringMode(professionalPhotoSession: camera.ProfessionalPhotoSession): camera.ExposureMeteringMode | undefined { 5620 let exposureMeteringMode: camera.ExposureMeteringMode | undefined = undefined; 5621 try { 5622 exposureMeteringMode = professionalPhotoSession.getExposureMeteringMode(); 5623 } catch (error) { 5624 // If the operation fails, error.code is returned and processed. 5625 let err = error as BusinessError; 5626 console.error(`The getExposureMeteringMode call failed. error code: ${err.code}`); 5627 } 5628 return exposureMeteringMode; 5629} 5630``` 5631 5632### setExposureMeteringMode<sup>12+</sup> 5633 5634setExposureMeteringMode(aeMeteringMode: ExposureMeteringMode): void 5635 5636Sets an exposure metering mode. 5637 5638Before the setting, call [isExposureMeteringModeSupported](#isexposuremeteringmodesupported12) to check whether the target exposure metering mode is supported. 5639 5640**System API**: This is a system API. 5641 5642**System capability**: SystemCapability.Multimedia.Camera.Core 5643 5644**Parameters** 5645 5646| Name | Type | Mandatory| Description | 5647| -------- | -------------------------------| ---- | ----------------------- | 5648| aeMeteringMode | [ExposureMeteringMode](#exposuremeteringmode12) | Yes | Metering mode. | 5649 5650**Error codes** 5651 5652For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5653 5654| ID | Error Message | 5655| --------------- | --------------- | 5656| 202 | Not System Application. | 5657| 7400101 | Parameter missing or parameter type incorrect. | 5658| 7400103 | Session not config. | 5659 5660**Example** 5661 5662```ts 5663import { BusinessError } from '@kit.BasicServicesKit'; 5664 5665function setExposureMeteringMode(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5666 try { 5667 professionalPhotoSession.setExposureMeteringMode(camera.ExposureMeteringMode.CENTER); 5668 } catch (error) { 5669 // If the operation fails, error.code is returned and processed. 5670 let err = error as BusinessError; 5671 console.error(`The setExposureMeteringMode call failed. error code: ${err.code}`); 5672 } 5673} 5674``` 5675 5676## FocusRangeType<sup>15+</sup> 5677 5678Enumerates the focus range types. 5679 5680**System capability**: SystemCapability.Multimedia.Camera.Core 5681 5682| Name| Value | Description | 5683| ---- | ---- | ---------- | 5684| AUTO | 0 | Auto focus. | 5685| NEAR | 1 | Focus on near objects.| 5686 5687## FocusDrivenType<sup>15+</sup> 5688 5689Enumerates the focus drive types. 5690 5691**System capability**: SystemCapability.Multimedia.Camera.Core 5692 5693| Name| Value | Description | 5694| ---- | ---- | ---------- | 5695| AUTO | 0 | Automatic. | 5696| FACE | 1 | Face-driven.| 5697 5698## FocusQuery<sup>12+</sup> 5699 5700Provides the API to check whether the focus assist is supported. 5701 5702### isFocusAssistSupported<sup>12+</sup> 5703 5704isFocusAssistSupported(): boolean 5705 5706Checks whether the focus assist is supported. 5707 5708**System API**: This is a system API. 5709 5710**System capability**: SystemCapability.Multimedia.Camera.Core 5711 5712**Return value** 5713 5714| Type | Description | 5715| ---------- | ----------------------------- | 5716| boolean | Check result for the support of the focus assist. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 5717 5718**Error codes** 5719 5720For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5721 5722| ID | Error Message | 5723| --------------- | --------------- | 5724| 7400103 | Session not config. | 5725| 202 | Not System Application. | 5726 5727**Example** 5728 5729```ts 5730import { BusinessError } from '@kit.BasicServicesKit'; 5731 5732function isFocusAssistSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5733 let status: boolean = false; 5734 try { 5735 status = professionalPhotoSession.isFocusAssistSupported(); 5736 } catch (error) { 5737 // If the operation fails, error.code is returned and processed. 5738 let err = error as BusinessError; 5739 console.error(`The isFocusAssistSupported call failed. error code: ${err.code}`); 5740 } 5741 return status; 5742} 5743``` 5744 5745### isFocusRangeTypeSupported<sup>15+</sup> 5746 5747isFocusRangeTypeSupported(type: FocusRangeType): boolean 5748 5749Checks whether a focus range type is supported. 5750 5751**System API**: This is a system API. 5752 5753**System capability**: SystemCapability.Multimedia.Camera.Core 5754 5755**Parameters** 5756 5757| Name| Type | Mandatory| Description | 5758| ------ | ----------------------------------- | ---- | ------------------------ | 5759| type | [FocusRangeType](#focusrangetype15) | Yes | Focus range type.| 5760 5761**Return value** 5762 5763| Type | Description | 5764| ------- | ------------------------------------------------------------ | 5765| boolean | Check result for the support of the focus range type. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 5766 5767**Error codes** 5768 5769For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5770 5771| ID| Error Message | 5772| -------- | ------------------------------------------------------------ | 5773| 202 | Not System Application. | 5774| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5775| 7400103 | Session not config. | 5776 5777**Example** 5778 5779```ts 5780import { BusinessError } from '@kit.BasicServicesKit'; 5781 5782function isFocusRangeTypeSupported(session: camera.VideoSessionForSys, type: camera.FocusRangeType): boolean { 5783 let status: boolean = false; 5784 try { 5785 status = session.isFocusRangeTypeSupported(type); 5786 } catch (error) { 5787 // If the operation fails, error.code is returned and processed. 5788 let err = error as BusinessError; 5789 console.error(`The isFocusRangeTypeSupported call failed. error code: ${err.code}`); 5790 } 5791 return status; 5792} 5793``` 5794 5795### isFocusDrivenTypeSupported<sup>15+</sup> 5796 5797isFocusDrivenTypeSupported(type: FocusDrivenType): boolean 5798 5799Checks whether a focus drive type is supported. 5800 5801**System API**: This is a system API. 5802 5803**System capability**: SystemCapability.Multimedia.Camera.Core 5804 5805**Parameters** 5806 5807| Name| Type | Mandatory| Description | 5808| ------ | ------------------------------------- | ---- | ------------------------ | 5809| type | [FocusDrivenType](#focusdriventype15) | Yes | Focus drive type.| 5810 5811**Return value** 5812 5813| Type | Description | 5814| ------- | ------------------------------------------------------------ | 5815| boolean | Check result for the support of the focus drive type. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 5816 5817**Error codes** 5818 5819For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5820 5821| ID| Error Message | 5822| -------- | ------------------------------------------------------------ | 5823| 202 | Not System Application. | 5824| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5825| 7400103 | Session not config. | 5826 5827**Example** 5828 5829```ts 5830import { BusinessError } from '@kit.BasicServicesKit'; 5831 5832function isFocusDrivenTypeSupported(session: camera.VideoSessionForSys, type: camera.FocusDrivenType): boolean { 5833 let status: boolean = false; 5834 try { 5835 status = session.isFocusDrivenTypeSupported(type); 5836 } catch (error) { 5837 // If the operation fails, error.code is returned and processed. 5838 let err = error as BusinessError; 5839 console.error(`The isFocusDrivenTypeSupported call failed. error code: ${err.code}`); 5840 } 5841 return status; 5842} 5843``` 5844 5845## Focus 5846 5847Focus extends [FocusQuery](#focusquery12) 5848 5849Provides APIs to obtain and set the camera focus mode and focus position. 5850 5851### setFocusAssist<sup>12+</sup> 5852 5853setFocusAssist(enabled: boolean): void 5854 5855Sets the focus assist. 5856 5857Before the setting, call [isFocusAssistSupported](#isfocusassistsupported12) to check whether the device supports the focus assist. 5858 5859**System API**: This is a system API. 5860 5861**System capability**: SystemCapability.Multimedia.Camera.Core 5862 5863**Parameters** 5864 5865| Name | Type | Mandatory| Description | 5866| -------- | ----------------------- | ---- | ------------------- | 5867| enabled | boolean | Yes | Whether to enable or disable focus assist. **true** to enable, **false** otherwise.| 5868 5869**Error codes** 5870 5871For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5872 5873| ID | Error Message | 5874| --------------- | --------------- | 5875| 202 | Not System Application. | 5876| 7400101 | Parameter missing or parameter type incorrect. | 5877| 7400103 | Session not config. | 5878 5879 5880**Example** 5881 5882```ts 5883import { BusinessError } from '@kit.BasicServicesKit'; 5884 5885function setFocusAssist(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5886 try { 5887 professionalPhotoSession.setFocusAssist(false); 5888 } catch (error) { 5889 // If the operation fails, error.code is returned and processed. 5890 let err = error as BusinessError; 5891 console.error(`The setFocusAssist call failed. error code: ${err.code}`); 5892 } 5893} 5894``` 5895 5896### getFocusAssist<sup>12+</sup> 5897 5898getFocusAssist(): boolean 5899 5900Checks whether the focus assist is enabled. 5901 5902**System API**: This is a system API. 5903 5904**System capability**: SystemCapability.Multimedia.Camera.Core 5905 5906**Return value** 5907 5908| Type | Description | 5909| ---------- | ----------------------------- | 5910| boolean | Check result for whether the focus assist is enabled. **true** if enabled, **false** otherwise.| 5911 5912**Error codes** 5913 5914For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5915 5916| ID | Error Message | 5917| --------------- | --------------- | 5918| 7400103 | Session not config. | 5919| 202 | Not System Application. | 5920 5921**Example** 5922 5923```ts 5924import { BusinessError } from '@kit.BasicServicesKit'; 5925 5926function getFocusAssist(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5927 let isFocusAssistOpened: boolean; 5928 try { 5929 isFocusAssistOpened = professionalPhotoSession.getFocusAssist(); 5930 } catch (error) { 5931 // If the operation fails, error.code is returned and processed. 5932 let err = error as BusinessError; 5933 console.error(`The getFocusAssist call failed. error code: ${err.code}`); 5934 } 5935 return isFocusAssistOpened; 5936} 5937``` 5938 5939### setFocusRange<sup>15+</sup> 5940 5941setFocusRange(type: FocusRangeType): void 5942 5943Sets a focus range type. Before the setting, call [isFocusRangeTypeSupported](#isfocusrangetypesupported15) to check whether the focus range type is supported. 5944 5945**System API**: This is a system API. 5946 5947**System capability**: SystemCapability.Multimedia.Camera.Core 5948 5949**Parameters** 5950 5951| Name| Type | Mandatory| Description | 5952| ------ | ----------------------------------- | ---- | -------------- | 5953| type | [FocusRangeType](#focusrangetype15) | Yes | Focus range type.| 5954 5955**Error codes** 5956 5957For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 5958 5959| ID| Error Message | 5960| -------- | ------------------------------------------------------------ | 5961| 202 | Not System Application. | 5962| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3.Parameter verification failed. | 5963| 7400102 | Operation not allowed. | 5964| 7400103 | Session not config. | 5965| 7400201 | Camera service fatal error. | 5966 5967**Example** 5968 5969```ts 5970import { BusinessError } from '@kit.BasicServicesKit'; 5971 5972function setFocusRange(session: camera.VideoSessionForSys, type: camera.FocusRangeType): void { 5973 try { 5974 session.setFocusRange(type); 5975 } catch (error) { 5976 // If the operation fails, error.code is returned and processed. 5977 let err = error as BusinessError; 5978 console.error(`The setFocusRange call failed. error code: ${err.code}`); 5979 } 5980} 5981``` 5982 5983### getFocusRange<sup>15+</sup> 5984 5985getFocusRange(): FocusRangeType 5986 5987Obtains the focus range type in use. 5988 5989**System API**: This is a system API. 5990 5991**System capability**: SystemCapability.Multimedia.Camera.Core 5992 5993**Return value** 5994 5995| Type | Description | 5996| ----------------------------------- | ------------------------ | 5997| [FocusRangeType](#focusrangetype15) | Focus range type.| 5998 5999**Error codes** 6000 6001For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6002 6003| ID| Error Message | 6004| -------- | ----------------------- | 6005| 202 | Not System Application. | 6006| 7400103 | Session not config. | 6007 6008**Example** 6009 6010```ts 6011import { BusinessError } from '@kit.BasicServicesKit'; 6012 6013function getFocusRange(session: camera.VideoSessionForSys): camera.FocusRangeType | undefined { 6014 let focusRangeType: camera.FocusRangeType | undefined = undefined; 6015 try { 6016 focusRangeType = session.getFocusRange(); 6017 } catch (error) { 6018 // If the operation fails, error.code is returned and processed. 6019 let err = error as BusinessError; 6020 console.error(`The getFocusRange call failed. error code: ${err.code}`); 6021 } 6022 return focusRangeType; 6023} 6024``` 6025 6026### setFocusDriven<sup>15+</sup> 6027 6028setFocusDriven(type: FocusDrivenType): void 6029 6030Sets a focus drive type. Before the setting, call [isFocusDrivenTypeSupported](#isfocusdriventypesupported15) to check whether the focus drive type is supported. 6031 6032**System API**: This is a system API. 6033 6034**System capability**: SystemCapability.Multimedia.Camera.Core 6035 6036**Parameters** 6037 6038| Name| Type | Mandatory| Description | 6039| ------ | ------------------------------------- | ---- | -------------- | 6040| type | [FocusDrivenType](#focusdriventype15) | Yes | Focus drive type.| 6041 6042**Error codes** 6043 6044For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6045 6046| ID| Error Message | 6047| -------- | ------------------------------------------------------------ | 6048| 202 | Not System Application. | 6049| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3.Parameter verification failed. | 6050| 7400102 | Operation not allowed. | 6051| 7400103 | Session not config. | 6052| 7400201 | Camera service fatal error. | 6053 6054**Example** 6055 6056```ts 6057import { BusinessError } from '@kit.BasicServicesKit'; 6058 6059function setFocusDriven(session: camera.VideoSessionForSys, type: camera.FocusDrivenType): void { 6060 try { 6061 session.setFocusDriven(type); 6062 } catch (error) { 6063 // If the operation fails, error.code is returned and processed. 6064 let err = error as BusinessError; 6065 console.error(`The setFocusDriven call failed. error code: ${err.code}`); 6066 } 6067} 6068``` 6069 6070### getFocusDriven<sup>15+</sup> 6071 6072getFocusDriven(): FocusDrivenType 6073 6074Obtains the focus drive type in use. 6075 6076**System API**: This is a system API. 6077 6078**System capability**: SystemCapability.Multimedia.Camera.Core 6079 6080**Return value** 6081 6082| Type | Description | 6083| ------------------------------------- | ------------------------ | 6084| [FocusDrivenType](#focusdriventype15) | Focus drive type.| 6085 6086**Error codes** 6087 6088For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6089 6090| ID| Error Message | 6091| -------- | ----------------------- | 6092| 202 | Not System Application. | 6093| 7400103 | Session not config. | 6094 6095**Example** 6096 6097```ts 6098import { BusinessError } from '@kit.BasicServicesKit'; 6099 6100function getFocusDriven(session: camera.VideoSessionForSys): camera.FocusDrivenType | undefined { 6101 let focusDrivenType: camera.FocusDrivenType | undefined = undefined; 6102 try { 6103 focusDrivenType = session.getFocusDriven(); 6104 } catch (error) { 6105 // If the operation fails, error.code is returned and processed. 6106 let err = error as BusinessError; 6107 console.error(`The getFocusDriven call failed. error code: ${err.code}`); 6108 } 6109 return focusDrivenType; 6110} 6111``` 6112 6113## ManualFocus<sup>12+</sup> 6114 6115Provides APIs related to manual focus operations. 6116 6117### setFocusDistance<sup>12+</sup> 6118 6119setFocusDistance(distance: number): void 6120 6121Sets the manual focus distance. 6122 6123**System API**: This is a system API. 6124 6125**System capability**: SystemCapability.Multimedia.Camera.Core 6126 6127**Parameters** 6128 6129| Name | Type | Mandatory| Description | 6130| -------- | ----------------------- | ---- | ------------------- | 6131| 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.| 6132 6133**Error codes** 6134 6135For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6136 6137| ID | Error Message | 6138| --------------- | --------------- | 6139| 202 | Not System Application. | 6140| 7400101 | Parameter missing or parameter type incorrect. | 6141| 7400103 | Session not config. | 6142 6143**Example** 6144 6145```ts 6146import { BusinessError } from '@kit.BasicServicesKit'; 6147 6148function setFocusDistance(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6149 try { 6150 let distance: number = 0.5; 6151 professionalPhotoSession.setFocusDistance(distance); 6152 } catch (error) { 6153 // If the operation fails, error.code is returned and processed. 6154 let err = error as BusinessError; 6155 console.error(`The setFocusDistance call failed. error code: ${err.code}`); 6156 } 6157} 6158``` 6159 6160### getFocusDistance<sup>12+</sup> 6161 6162getFocusDistance(): number 6163 6164Obtains the focus distance in use. 6165 6166**System API**: This is a system API. 6167 6168**System capability**: SystemCapability.Multimedia.Camera.Core 6169 6170**Return value** 6171 6172| Type | Description | 6173| ---------- | ----------------------------- | 6174| number | Normalized value of the focus distance.| 6175 6176**Error codes** 6177 6178For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6179 6180| ID | Error Message | 6181| --------------- | --------------- | 6182| 7400103 | Session not config. | 6183| 202 | Not System Application. | 6184 6185**Example** 6186 6187```ts 6188import { BusinessError } from '@kit.BasicServicesKit'; 6189 6190function getFocusDistance(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 6191 let distance: number = 0; 6192 try { 6193 distance = professionalPhotoSession.getFocusDistance(); 6194 } catch (error) { 6195 // If the operation fails, error.code is returned and processed. 6196 let err = error as BusinessError; 6197 console.error(`The getFocusDistance call failed. error code: ${err.code}`); 6198 } 6199 return distance; 6200} 6201``` 6202 6203## ManualIsoQuery<sup>12+</sup> 6204 6205Provides APIs to check whether a camera device supports manual ISO setting and obtain the ISO range supported by the device. 6206 6207### isManualIsoSupported<sup>12+</sup> 6208 6209isManualIsoSupported(): boolean 6210 6211Checks whether manual ISO setting is supported. 6212 6213**System API**: This is a system API. 6214 6215**System capability**: SystemCapability.Multimedia.Camera.Core 6216 6217**Return value** 6218 6219| Type | Description | 6220| ---------- | ----------------------------- | 6221| boolean | Check result for the support of manual ISO setting. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 6222 6223**Error codes** 6224 6225For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6226 6227| ID | Error Message | 6228| --------------- | --------------- | 6229| 7400103 | Session not config. | 6230| 202 | Not System Application. | 6231 6232**Example** 6233 6234```ts 6235import { BusinessError } from '@kit.BasicServicesKit'; 6236 6237function isManualIsoSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 6238 let status: boolean = false; 6239 try { 6240 status = professionalPhotoSession.isManualIsoSupported(); 6241 } catch (error) { 6242 // If the operation fails, error.code is returned and processed. 6243 let err = error as BusinessError; 6244 console.error(`The isManualIsoSupported call failed. error code: ${err.code}`); 6245 } 6246 return status; 6247} 6248``` 6249 6250### getIsoRange<sup>12+</sup> 6251 6252getIsoRange(): Array\<number\> 6253 6254Obtains the supported ISO range. 6255 6256**System API**: This is a system API. 6257 6258**System capability**: SystemCapability.Multimedia.Camera.Core 6259 6260**Return value** 6261 6262| Type | Description | 6263| ---------- | ----------------------------- | 6264| 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](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 6265 6266**Error codes** 6267 6268For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6269 6270| ID | Error Message | 6271| --------------- | --------------- | 6272| 202 | Not System Application. | 6273| 7400103 | Session not config. | 6274 6275**Example** 6276 6277```ts 6278import { BusinessError } from '@kit.BasicServicesKit'; 6279 6280function getIsoRange(professionalPhotoSession: camera.ProfessionalPhotoSession): Array<number> { 6281 let isoRange: Array<number> = []; 6282 try { 6283 isoRange = professionalPhotoSession.getIsoRange(); 6284 } catch (error) { 6285 // If the operation fails, error.code is returned and processed. 6286 let err = error as BusinessError; 6287 console.error(`The getIsoRange call failed. error code: ${err.code}`); 6288 } 6289 return isoRange; 6290} 6291``` 6292 6293## ManualIso<sup>12+</sup> 6294 6295ManualIso extends [ManualIsoQuery](#manualisoquery12) 6296 6297Provides APIs for obtaining and setting the manual ISO (sensitivity) of a camera device. 6298 6299### setIso<sup>12+</sup> 6300setIso(iso: number): void 6301 6302Sets the ISO. 6303 6304**NOTE**: When the ISO is set to 0, automatic ISO is used. 6305 6306**System API**: This is a system API. 6307 6308**System capability**: SystemCapability.Multimedia.Camera.Core 6309 6310**Parameters** 6311 6312| Name | Type | Mandatory| Description | 6313| -------- | ----------------------- | ---- | ------------------- | 6314| iso | number | Yes | ISO.| 6315 6316**Error codes** 6317 6318For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6319 6320| ID | Error Message | 6321| --------------- | --------------- | 6322| 202 | Not System Application. | 6323| 7400101 | Parameter missing or parameter type incorrect. | 6324| 7400103 | Session not config. | 6325 6326**Example** 6327 6328```ts 6329import { BusinessError } from '@kit.BasicServicesKit'; 6330 6331function setIso(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6332 try { 6333 let iso: number = 200; 6334 professionalPhotoSession.setIso(iso); 6335 } catch (error) { 6336 // If the operation fails, error.code is returned and processed. 6337 let err = error as BusinessError; 6338 console.error(`The setIso call failed. error code: ${err.code}`); 6339 } 6340} 6341``` 6342 6343### getIso<sup>12+</sup> 6344 6345getIso(): number 6346 6347Obtains the ISO in use. 6348 6349**System API**: This is a system API. 6350 6351**System capability**: SystemCapability.Multimedia.Camera.Core 6352 6353**Return value** 6354 6355| Type | Description | 6356| ---------- | ----------------------------- | 6357| number | ISO.| 6358 6359**Error codes** 6360 6361For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6362 6363| ID | Error Message | 6364| --------------- | --------------- | 6365| 202 | Not System Application. | 6366| 7400103 | Session not config. | 6367 6368**Example** 6369 6370```ts 6371import { BusinessError } from '@kit.BasicServicesKit'; 6372 6373function getIso(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 6374 let iso: number = 0; 6375 try { 6376 iso = professionalPhotoSession.getIso(); 6377 } catch (error) { 6378 // If the operation fails, error.code is returned and processed. 6379 let err = error as BusinessError; 6380 console.error(`The getIso call failed. error code: ${err.code}`); 6381 } 6382 return iso; 6383} 6384``` 6385 6386## ProfessionalPhotoSession<sup>12+</sup> 6387 6388ProfessionalPhotoSession extends Session, AutoExposure, ManualExposure, Focus, ManualFocus, WhiteBalance, ManualIso, Flash, Zoom, ColorEffect, Aperture 6389 6390Implements a professional photo session, which sets the parameters of the professional photo mode and saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera. It inherits from [Session](arkts-apis-camera-Session.md). 6391 6392### on('error')<sup>12+</sup> 6393 6394on(type: 'error', callback: ErrorCallback): void 6395 6396Subscribes to ProfessionalPhotoSession error events. This API uses an asynchronous callback to return the result. 6397 6398**System API**: This is a system API. 6399 6400**System capability**: SystemCapability.Multimedia.Camera.Core 6401 6402**Parameters** 6403 6404| Name | Type | Mandatory| Description | 6405| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 6406| 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](arkts-apis-camera-Session.md#beginconfig11), [commitConfig](arkts-apis-camera-Session.md#commitconfig11-1), and [addInput](arkts-apis-camera-Session.md#addinput11).| 6407| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode).| 6408 6409**Error codes** 6410 6411For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6412 6413| ID | Error Message | 6414|---------| --------------- | 6415| 202 | Not System Application. | 6416 6417**Example** 6418 6419```ts 6420import { BusinessError } from '@kit.BasicServicesKit'; 6421 6422function callback(err: BusinessError): void { 6423 console.error(`Professional photo session error code: ${err.code}`); 6424} 6425 6426function registerSessionError(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6427 professionalPhotoSession.on('error', callback); 6428} 6429``` 6430 6431### off('error')<sup>12+</sup> 6432 6433off(type: 'error', callback?: ErrorCallback): void 6434 6435Unsubscribes from ProfessionalPhotoSession error events. 6436 6437**System API**: This is a system API. 6438 6439**System capability**: SystemCapability.Multimedia.Camera.Core 6440 6441**Parameters** 6442 6443| Name | Type | Mandatory| Description | 6444| -------- | ------------------------ | ---- | ------------------------------ | 6445| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 6446| 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. | 6447 6448**Error codes** 6449 6450For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6451 6452| ID | Error Message | 6453|---------| --------------- | 6454| 202 | Not System Application. | 6455 6456**Example** 6457 6458```ts 6459function unregisterSessionError(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6460 professionalPhotoSession.off('error'); 6461} 6462``` 6463 6464### on('focusStateChange')<sup>12+</sup> 6465 6466on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 6467 6468Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 6469 6470**System API**: This is a system API. 6471 6472**System capability**: SystemCapability.Multimedia.Camera.Core 6473 6474**Parameters** 6475 6476| Name | Type | Mandatory| Description | 6477| -------- | ---------------- | ---- | ------------------------ | 6478| 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.| 6479| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | Yes | Callback used to return the focus state change. | 6480 6481**Error codes** 6482 6483For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6484 6485| ID | Error Message | 6486|---------| --------------- | 6487| 202 | Not System Application. | 6488 6489**Example** 6490 6491```ts 6492import { BusinessError } from '@kit.BasicServicesKit'; 6493 6494function callback(err: BusinessError, focusState: camera.FocusState): void { 6495 if (err !== undefined && err.code !== 0) { 6496 console.error(`Callback Error, errorCode: ${err.code}`); 6497 return; 6498 } 6499 console.info(`Focus state: ${focusState}`); 6500} 6501 6502function registerFocusStateChange(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6503 professionalPhotoSession.on('focusStateChange', callback); 6504} 6505``` 6506 6507### off('focusStateChange')<sup>12+</sup> 6508 6509off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 6510 6511Unsubscribes from focus state change events. 6512 6513**System API**: This is a system API. 6514 6515**System capability**: SystemCapability.Multimedia.Camera.Core 6516 6517**Parameters** 6518 6519| Name | Type | Mandatory| Description | 6520| -------- | ----------------------------------------- | ---- | ------------------------ | 6521| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 6522| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.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.) | 6523 6524**Error codes** 6525 6526For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6527 6528| ID | Error Message | 6529|---------| --------------- | 6530| 202 | Not System Application. | 6531 6532**Example** 6533 6534```ts 6535function unregisterFocusStateChange(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6536 professionalPhotoSession.off('focusStateChange'); 6537} 6538``` 6539 6540### on('smoothZoomInfoAvailable')<sup>12+</sup> 6541 6542on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 6543 6544Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 6545 6546**System API**: This is a system API. 6547 6548**System capability**: SystemCapability.Multimedia.Camera.Core 6549 6550**Parameters** 6551 6552| Name | Type | Mandatory| Description | 6553| -------- | ----------------------- | ---- | ------------------------ | 6554| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 6555| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 6556 6557**Error codes** 6558 6559For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6560 6561| ID | Error Message | 6562|---------| --------------- | 6563| 202 | Not System Application. | 6564 6565**Example** 6566 6567```ts 6568import { BusinessError } from '@kit.BasicServicesKit'; 6569 6570function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 6571 if (err !== undefined && err.code !== 0) { 6572 console.error(`Callback Error, errorCode: ${err.code}`); 6573 return; 6574 } 6575 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 6576} 6577 6578function registerSmoothZoomInfo(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6579 professionalPhotoSession.on('smoothZoomInfoAvailable', callback); 6580} 6581``` 6582 6583### off('smoothZoomInfoAvailable')<sup>12+</sup> 6584 6585off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 6586 6587Unsubscribes from smooth zoom state change events. 6588 6589**System API**: This is a system API. 6590 6591**System capability**: SystemCapability.Multimedia.Camera.Core 6592 6593**Parameters** 6594 6595| Name | Type | Mandatory| Description | 6596| -------- | ----------------------------------------- | ---- | ------------------------ | 6597| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 6598| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.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.) | 6599 6600**Error codes** 6601 6602For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6603 6604| ID | Error Message | 6605|---------| --------------- | 6606| 202 | Not System Application. | 6607 6608**Example** 6609 6610```ts 6611function unregisterSmoothZoomInfo(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6612 professionalPhotoSession.off('smoothZoomInfoAvailable'); 6613} 6614``` 6615 6616### on('isoInfoChange')<sup>12+</sup> 6617 6618on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 6619 6620Subscribes to automatic ISO change events to obtain real-time ISO information. This API uses an asynchronous callback to return the result. 6621 6622**System API**: This is a system API. 6623 6624**System capability**: SystemCapability.Multimedia.Camera.Core 6625 6626**Parameters** 6627 6628| Name | Type | Mandatory| Description | 6629| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6630| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 6631| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| Yes | Callback used to return the ISO information. | 6632 6633**Error codes** 6634 6635| ID| Error Message | 6636| ------- | ---------------------- | 6637| 202 | Not System Application. | 6638 6639**Example** 6640 6641```ts 6642import { BusinessError } from '@kit.BasicServicesKit'; 6643 6644function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 6645 if (err !== undefined && err.code !== 0) { 6646 console.error(`Callback Error, errorCode: ${err.code}`); 6647 return; 6648 } 6649 console.log(`ISO value: ${info.iso}`); 6650} 6651 6652function registerIsoInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6653 professionalPhotoSession.on('isoInfoChange', isoInfoCallback); 6654} 6655``` 6656 6657### off('isoInfoChange')<sup>12+</sup> 6658 6659off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 6660 6661Unsubscribes from automatic ISO change events. 6662 6663**System API**: This is a system API. 6664 6665**System capability**: SystemCapability.Multimedia.Camera.Core 6666 6667**Parameters** 6668 6669| Name | Type | Mandatory| Description | 6670| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6671| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 6672| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('isoInfoChange')**.| 6673 6674**Error codes** 6675 6676| ID| Error Message | 6677| ------- | ---------------------- | 6678| 202 | Not System Application. | 6679 6680**Example** 6681 6682```ts 6683function unregisterIsoInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6684 professionalPhotoSession.off('isoInfoChange'); 6685} 6686``` 6687 6688### on('exposureInfoChange')<sup>12+</sup> 6689 6690on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 6691 6692Subscribes to exposure information change events to obtain the exposure information. This API uses an asynchronous callback to return the result. 6693 6694**System API**: This is a system API. 6695 6696**System capability**: SystemCapability.Multimedia.Camera.Core 6697 6698**Parameters** 6699 6700| Name | Type | Mandatory| Description | 6701| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6702| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 6703| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| Yes | Callback used to return the exposure information. | 6704 6705**Error codes** 6706 6707| ID| Error Message | 6708| ------- | ---------------------- | 6709| 202 | Not System Application. | 6710 6711**Example** 6712 6713```ts 6714import { BusinessError } from '@kit.BasicServicesKit'; 6715 6716function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 6717 if (err !== undefined && err.code !== 0) { 6718 console.error(`Callback Error, errorCode: ${err.code}`); 6719 return; 6720 } 6721 console.log(`exposureTimeValue: ${info.exposureTime}`); 6722} 6723 6724function registerExposureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6725 professionalPhotoSession.on('exposureInfoChange', exposureInfoCallback); 6726} 6727``` 6728 6729### off('exposureInfoChange')<sup>12+</sup> 6730 6731off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 6732 6733Unsubscribes from exposure information change events. 6734 6735**System API**: This is a system API. 6736 6737**System capability**: SystemCapability.Multimedia.Camera.Core 6738 6739**Parameters** 6740 6741| Name | Type | Mandatory| Description | 6742| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6743| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 6744| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('exposureInfoChange')**.| 6745 6746**Error codes** 6747 6748| ID| Error Message | 6749| ------- | ---------------------- | 6750| 202 | Not System Application. | 6751 6752**Example** 6753 6754```ts 6755function unregisterExposureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6756 professionalPhotoSession.off('exposureInfoChange'); 6757} 6758``` 6759 6760### on('apertureInfoChange')<sup>12+</sup> 6761 6762on(type: 'apertureInfoChange', callback: AsyncCallback\<ApertureInfo\>): void 6763 6764Subscribes to aperture change events to obtain the real-time aperture information. This API uses an asynchronous callback to return the result. 6765 6766**System API**: This is a system API. 6767 6768**System capability**: SystemCapability.Multimedia.Camera.Core 6769 6770**Parameters** 6771 6772| Name | Type | Mandatory| Description | 6773| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6774| type | string | Yes | Event type. The value is fixed at **'apertureInfoChange'**. | 6775| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| Yes | Callback used to return the aperture information. | 6776 6777**Error codes** 6778 6779| ID| Error Message | 6780| ------- | ---------------------- | 6781| 202 | Not System Application. | 6782 6783**Example** 6784 6785```ts 6786import { BusinessError } from '@kit.BasicServicesKit'; 6787 6788function apertureInfoCallback(err: BusinessError, info: camera.ApertureInfo): void { 6789 if (err !== undefined && err.code !== 0) { 6790 console.error(`Callback Error, errorCode: ${err.code}`); 6791 return; 6792 } 6793 console.log(`Aperture value: ${info.aperture}`); 6794} 6795 6796function registerApertureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6797 professionalPhotoSession.on('apertureInfoChange', apertureInfoCallback); 6798} 6799``` 6800 6801### off('apertureInfoChange')<sup>12+</sup> 6802 6803off(type: 'apertureInfoChange', callback?: AsyncCallback\<ApertureInfo\>): void 6804 6805Unsubscribes from aperture change events. 6806 6807**System API**: This is a system API. 6808 6809**System capability**: SystemCapability.Multimedia.Camera.Core 6810 6811**Parameters** 6812 6813| Name | Type | Mandatory| Description | 6814| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6815| type | string | Yes | Event type. The value is fixed at **'apertureInfoChange'**. | 6816| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('apertureInfoChange')**.| 6817 6818**Error codes** 6819 6820| ID| Error Message | 6821| ------- | ---------------------- | 6822| 202 | Not System Application. | 6823 6824**Example** 6825 6826```ts 6827function unregisterApertureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6828 professionalPhotoSession.off('apertureInfoChange'); 6829} 6830``` 6831 6832### on('luminationInfoChange')<sup>12+</sup> 6833 6834on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 6835 6836Subscribes to illumination change events to obtain real-time illumination information. This API uses an asynchronous callback to return the result. 6837 6838**System API**: This is a system API. 6839 6840**System capability**: SystemCapability.Multimedia.Camera.Core 6841 6842**Parameters** 6843 6844| Name | Type | Mandatory| Description | 6845| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6846| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 6847| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| Yes | Callback used to return the illumination information. | 6848 6849**Error codes** 6850 6851| ID| Error Message | 6852| ------- | ---------------------- | 6853| 202 | Not System Application. | 6854 6855**Example** 6856 6857```ts 6858import { BusinessError } from '@kit.BasicServicesKit'; 6859 6860function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 6861 if (err !== undefined && err.code !== 0) { 6862 console.error(`Callback Error, errorCode: ${err.code}`); 6863 return; 6864 } 6865 console.log(`Lumination: ${info.lumination}`); 6866} 6867 6868function registerLuminationInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6869 professionalPhotoSession.on('luminationInfoChange', luminationInfoCallback); 6870} 6871``` 6872 6873### off('luminationInfoChange')<sup>12+</sup> 6874 6875off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 6876 6877Unsubscribes from illumination change events. 6878 6879**System API**: This is a system API. 6880 6881**System capability**: SystemCapability.Multimedia.Camera.Core 6882 6883**Parameters** 6884 6885| Name | Type | Mandatory| Description | 6886| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6887| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 6888| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('luminationInfoChange')**.| 6889 6890**Error codes** 6891 6892| ID| Error Message | 6893| ------- | ---------------------- | 6894| 202 | Not System Application. | 6895 6896**Example** 6897 6898```ts 6899function unregisterLuminationInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6900 professionalPhotoSession.off('luminationInfoChange'); 6901} 6902``` 6903 6904## ProfessionalVideoSession<sup>12+</sup> 6905 6906ProfessionalVideoSession extends Session, AutoExposure, ManualExposure, Focus, ManualFocus, WhiteBalance, ManualIso, Flash, Zoom, ColorEffect, Aperture 6907 6908Implements a professional video session, which sets the parameters of the professional video mode and saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera. It inherits from [Session](arkts-apis-camera-Session.md). 6909 6910### on('error')<sup>12+</sup> 6911 6912on(type: 'error', callback: ErrorCallback): void 6913 6914Subscribes to ProfessionalVideo error events. This API uses an asynchronous callback to return the result. 6915 6916**System API**: This is a system API. 6917 6918**System capability**: SystemCapability.Multimedia.Camera.Core 6919 6920**Parameters** 6921 6922| Name | Type | Mandatory| Description | 6923| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 6924| 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](arkts-apis-camera-Session.md#beginconfig11), [commitConfig](arkts-apis-camera-Session.md#commitconfig11-1), and [addInput](arkts-apis-camera-Session.md#addinput11).| 6925| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode).| 6926 6927**Error codes** 6928 6929For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6930 6931| ID | Error Message | 6932|---------| --------------- | 6933| 202 | Not System Application. | 6934 6935**Example** 6936 6937```ts 6938import { BusinessError } from '@kit.BasicServicesKit'; 6939 6940function callback(err: BusinessError): void { 6941 console.error(`Professional video session error code: ${err.code}`); 6942} 6943 6944function registerSessionError(professionalVideoSession: camera.ProfessionalVideoSession): void { 6945 professionalVideoSession.on('error', callback); 6946} 6947``` 6948 6949### off('error')<sup>12+</sup> 6950 6951off(type: 'error', callback?: ErrorCallback): void 6952 6953Unsubscribes from ProfessionalVideo error events. 6954 6955**System API**: This is a system API. 6956 6957**System capability**: SystemCapability.Multimedia.Camera.Core 6958 6959**Parameters** 6960 6961| Name | Type | Mandatory| Description | 6962| -------- | ------------------------ | ---- | ------------------------------ | 6963| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 6964| 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. | 6965 6966**Error codes** 6967 6968For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 6969 6970| ID | Error Message | 6971|---------| --------------- | 6972| 202 | Not System Application. | 6973 6974**Example** 6975 6976```ts 6977function unregisterSessionError(professionalVideoSession: camera.ProfessionalVideoSession): void { 6978 professionalVideoSession.off('error'); 6979} 6980``` 6981 6982### on('focusStateChange')<sup>12+</sup> 6983 6984on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 6985 6986Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 6987 6988**System API**: This is a system API. 6989 6990**System capability**: SystemCapability.Multimedia.Camera.Core 6991 6992**Parameters** 6993 6994| Name | Type | Mandatory| Description | 6995| -------- | ---------------- | ---- | ------------------------ | 6996| 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.| 6997| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | Yes | Callback used to return the focus state change. | 6998 6999**Error codes** 7000 7001For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7002 7003| ID | Error Message | 7004|---------| --------------- | 7005| 202 | Not System Application. | 7006 7007**Example** 7008 7009```ts 7010import { BusinessError } from '@kit.BasicServicesKit'; 7011 7012function callback(err: BusinessError, focusState: camera.FocusState): void { 7013 if (err !== undefined && err.code !== 0) { 7014 console.error(`Callback Error, errorCode: ${err.code}`); 7015 return; 7016 } 7017 console.info(`Focus state: ${focusState}`); 7018} 7019 7020function registerFocusStateChange(professionalVideoSession: camera.ProfessionalVideoSession): void { 7021 professionalVideoSession.on('focusStateChange', callback); 7022} 7023``` 7024 7025### off('focusStateChange')<sup>12+</sup> 7026 7027off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7028 7029Unsubscribes from focus state change events. 7030 7031**System API**: This is a system API. 7032 7033**System capability**: SystemCapability.Multimedia.Camera.Core 7034 7035**Parameters** 7036 7037| Name | Type | Mandatory| Description | 7038| -------- | ----------------------------------------- | ---- | ------------------------ | 7039| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 7040| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.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.) | 7041 7042**Error codes** 7043 7044For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7045 7046| ID | Error Message | 7047|---------| --------------- | 7048| 202 | Not System Application. | 7049 7050**Example** 7051 7052```ts 7053function unregisterFocusStateChange(professionalVideoSession: camera.ProfessionalVideoSession): void { 7054 professionalVideoSession.off('focusStateChange'); 7055} 7056``` 7057 7058### on('smoothZoomInfoAvailable')<sup>12+</sup> 7059 7060on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 7061 7062Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 7063 7064**System API**: This is a system API. 7065 7066**System capability**: SystemCapability.Multimedia.Camera.Core 7067 7068**Parameters** 7069 7070| Name | Type | Mandatory| Description | 7071| -------- | ----------------------- | ---- | ------------------------ | 7072| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 7073| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 7074 7075**Error codes** 7076 7077For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7078 7079| ID | Error Message | 7080|---------| --------------- | 7081| 202 | Not System Application. | 7082 7083**Example** 7084 7085```ts 7086import { BusinessError } from '@kit.BasicServicesKit'; 7087 7088function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 7089 if (err !== undefined && err.code !== 0) { 7090 console.error(`Callback Error, errorCode: ${err.code}`); 7091 return; 7092 } 7093 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 7094} 7095 7096function registerSmoothZoomInfo(professionalVideoSession: camera.ProfessionalVideoSession): void { 7097 professionalVideoSession.on('smoothZoomInfoAvailable', callback); 7098} 7099``` 7100 7101### off('smoothZoomInfoAvailable')<sup>12+</sup> 7102 7103off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 7104 7105Unsubscribes from smooth zoom state change events. 7106 7107**System API**: This is a system API. 7108 7109**System capability**: SystemCapability.Multimedia.Camera.Core 7110 7111**Parameters** 7112 7113| Name | Type | Mandatory| Description | 7114| -------- | ----------------------------------------- | ---- | ------------------------ | 7115| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 7116| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.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.) | 7117 7118**Error codes** 7119 7120For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7121 7122| ID | Error Message | 7123|---------| --------------- | 7124| 202 | Not System Application. | 7125 7126**Example** 7127 7128```ts 7129function unregisterSmoothZoomInfo(professionalVideoSession: camera.ProfessionalVideoSession): void { 7130 professionalVideoSession.off('smoothZoomInfoAvailable'); 7131} 7132``` 7133 7134### on('isoInfoChange')<sup>12+</sup> 7135 7136on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 7137 7138Subscribes to automatic ISO change events to obtain real-time ISO information. This API uses an asynchronous callback to return the result. 7139 7140**System API**: This is a system API. 7141 7142**System capability**: SystemCapability.Multimedia.Camera.Core 7143 7144**Parameters** 7145 7146| Name | Type | Mandatory| Description | 7147| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7148| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 7149| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| Yes | Callback used to return the ISO information. | 7150 7151**Error codes** 7152 7153| ID| Error Message | 7154| ------- | ---------------------- | 7155| 202 | Not System Application. | 7156 7157**Example** 7158 7159```ts 7160import { BusinessError } from '@kit.BasicServicesKit'; 7161 7162function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 7163 if (err !== undefined && err.code !== 0) { 7164 console.error(`Callback Error, errorCode: ${err.code}`); 7165 return; 7166 } 7167 console.log(`ISO value: ${info.iso}`); 7168} 7169 7170function registerIsoInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7171 professionalVideoSession.on('isoInfoChange', isoInfoCallback); 7172} 7173``` 7174 7175### off('isoInfoChange')<sup>12+</sup> 7176 7177off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 7178 7179Unsubscribes from automatic ISO change events. 7180 7181**System API**: This is a system API. 7182 7183**System capability**: SystemCapability.Multimedia.Camera.Core 7184 7185**Parameters** 7186 7187| Name | Type | Mandatory| Description | 7188| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7189| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 7190| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('isoInfoChange')**.| 7191 7192**Error codes** 7193 7194| ID| Error Message | 7195| ------- | ---------------------- | 7196| 202 | Not System Application. | 7197 7198**Example** 7199 7200```ts 7201function unregisterIsoInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7202 professionalVideoSession.off('isoInfoChange'); 7203} 7204``` 7205 7206### on('exposureInfoChange')<sup>12+</sup> 7207 7208on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 7209 7210Subscribes to exposure information change events to obtain the exposure information. This API uses an asynchronous callback to return the result. 7211 7212**System API**: This is a system API. 7213 7214**System capability**: SystemCapability.Multimedia.Camera.Core 7215 7216**Parameters** 7217 7218| Name | Type | Mandatory| Description | 7219| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7220| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 7221| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| Yes | Callback used to return the exposure information. | 7222 7223**Error codes** 7224 7225| ID| Error Message | 7226| ------- | ---------------------- | 7227| 202 | Not System Application. | 7228 7229**Example** 7230 7231```ts 7232import { BusinessError } from '@kit.BasicServicesKit'; 7233 7234function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 7235 if (err !== undefined && err.code !== 0) { 7236 console.error(`Callback Error, errorCode: ${err.code}`); 7237 return; 7238 } 7239 console.log(`exposureTimeValue: ${info.exposureTime}`); 7240} 7241 7242function registerExposureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7243 professionalVideoSession.on('exposureInfoChange', exposureInfoCallback); 7244} 7245``` 7246 7247### off('exposureInfoChange')<sup>12+</sup> 7248 7249off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 7250 7251Unsubscribes from exposure information change events. 7252 7253**System API**: This is a system API. 7254 7255**System capability**: SystemCapability.Multimedia.Camera.Core 7256 7257**Parameters** 7258 7259| Name | Type | Mandatory| Description | 7260| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7261| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 7262| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('exposureInfoChange')**.| 7263 7264**Error codes** 7265 7266| ID| Error Message | 7267| ------- | ---------------------- | 7268| 202 | Not System Application. | 7269 7270**Example** 7271 7272```ts 7273function unregisterExposureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7274 professionalVideoSession.off('exposureInfoChange'); 7275} 7276``` 7277 7278### on('apertureInfoChange')<sup>12+</sup> 7279 7280on(type: 'apertureInfoChange', callback: AsyncCallback\<ApertureInfo\>): void 7281 7282Subscribes to aperture change events to obtain the aperture information. This API uses an asynchronous callback to return the result. 7283 7284**System API**: This is a system API. 7285 7286**System capability**: SystemCapability.Multimedia.Camera.Core 7287 7288**Parameters** 7289 7290| Name | Type | Mandatory| Description | 7291| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7292| type | string | Yes | Event type. The value is fixed at **'apertureInfoChange'**. | 7293| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| Yes | Callback used to return the aperture information. | 7294 7295**Error codes** 7296 7297| ID| Error Message | 7298| ------- | ---------------------- | 7299| 202 | Not System Application. | 7300 7301**Example** 7302 7303```ts 7304import { BusinessError } from '@kit.BasicServicesKit'; 7305 7306function apertureInfoCallback(err: BusinessError, info: camera.ApertureInfo): void { 7307 if (err !== undefined && err.code !== 0) { 7308 console.error(`Callback Error, errorCode: ${err.code}`); 7309 return; 7310 } 7311 console.log(`Aperture value: ${info.aperture}`); 7312} 7313 7314function registerApertureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7315 professionalVideoSession.on('apertureInfoChange', apertureInfoCallback); 7316} 7317``` 7318 7319### off('apertureInfoChange')<sup>12+</sup> 7320 7321off(type: 'apertureInfoChange', callback?: AsyncCallback\<ApertureInfo\>): void 7322 7323Unsubscribes from aperture change events. 7324 7325**System API**: This is a system API. 7326 7327**System capability**: SystemCapability.Multimedia.Camera.Core 7328 7329**Parameters** 7330 7331| Name | Type | Mandatory| Description | 7332| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7333| type | string | Yes | Event type. The value is fixed at **'apertureInfoChange'**. | 7334| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('apertureInfoChange')**.| 7335 7336**Error codes** 7337 7338| ID| Error Message | 7339| ------- | ---------------------- | 7340| 202 | Not System Application. | 7341 7342**Example** 7343 7344```ts 7345function unregisterApertureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7346 professionalVideoSession.off('apertureInfoChange'); 7347} 7348``` 7349 7350### on('luminationInfoChange')<sup>12+</sup> 7351 7352on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 7353 7354Subscribes to illumination change events to obtain illumination information. This API uses an asynchronous callback to return the result. 7355 7356**System API**: This is a system API. 7357 7358**System capability**: SystemCapability.Multimedia.Camera.Core 7359 7360**Parameters** 7361 7362| Name | Type | Mandatory| Description | 7363| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7364| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 7365| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| Yes | Callback used to return the illumination information. | 7366 7367**Error codes** 7368 7369| ID| Error Message | 7370| ------- | ---------------------- | 7371| 202 | Not System Application. | 7372 7373**Example** 7374 7375```ts 7376import { BusinessError } from '@kit.BasicServicesKit'; 7377 7378function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 7379 if (err !== undefined && err.code !== 0) { 7380 console.error(`Callback Error, errorCode: ${err.code}`); 7381 return; 7382 } 7383 console.log(`Lumination: ${info.lumination}`); 7384} 7385 7386function registerLuminationInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7387 professionalVideoSession.on('luminationInfoChange', luminationInfoCallback); 7388} 7389``` 7390 7391### off('luminationInfoChange')<sup>12+</sup> 7392 7393off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 7394 7395Unsubscribes from illumination change events. 7396 7397**System API**: This is a system API. 7398 7399**System capability**: SystemCapability.Multimedia.Camera.Core 7400 7401**Parameters** 7402 7403| Name | Type | Mandatory| Description | 7404| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7405| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 7406| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('luminationInfoChange')**.| 7407 7408**Error codes** 7409 7410| ID| Error Message | 7411| ------- | ---------------------- | 7412| 202 | Not System Application. | 7413 7414**Example** 7415 7416```ts 7417function unregisterLuminationInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7418 professionalVideoSession.off('luminationInfoChange'); 7419} 7420``` 7421 7422## MacroPhotoSession<sup>12+</sup> 7423 7424MacroPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ManualFocus 7425 7426Implements a macro photo session, which sets the parameters of the macro photo mode and saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera. It inherits from [Session](arkts-apis-camera-Session.md). 7427 7428### on('error')<sup>12+</sup> 7429 7430on(type: 'error', callback: ErrorCallback): void 7431 7432Subscribes to MacroPhotoSession error events. This API uses an asynchronous callback to return the result. 7433 7434**System API**: This is a system API. 7435 7436**System capability**: SystemCapability.Multimedia.Camera.Core 7437 7438**Parameters** 7439 7440| Name | Type | Mandatory | Description | 7441|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 7442| 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](arkts-apis-camera-Session.md#beginconfig11), [commitConfig](arkts-apis-camera-Session.md#commitconfig11-1), and [addInput](arkts-apis-camera-Session.md#addinput11).| 7443| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes | Callback used to return an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode). | 7444 7445**Error codes** 7446 7447For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7448 7449| ID| Error Message | 7450|-------|----------------------------| 7451| 202 | Not System Application. | 7452 7453**Example** 7454 7455```ts 7456import { BusinessError } from '@kit.BasicServicesKit'; 7457 7458function callback(err: BusinessError): void { 7459 console.error(`MacroPhotoSession error code: ${err.code}`); 7460} 7461 7462function registerSessionError(macroPhotoSession: camera.MacroPhotoSession): void { 7463 macroPhotoSession.on('error', callback); 7464} 7465``` 7466 7467### off('error')<sup>12+</sup> 7468 7469off(type: 'error', callback?: ErrorCallback): void 7470 7471Unsubscribes from MacroPhotoSession error events. 7472 7473**System API**: This is a system API. 7474 7475**System capability**: SystemCapability.Multimedia.Camera.Core 7476 7477**Parameters** 7478 7479| Name | Type | Mandatory| Description | 7480|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 7481| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. | 7482| 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.| 7483 7484**Error codes** 7485 7486For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7487 7488| ID| Error Message | 7489|-------|----------------------------| 7490| 202 | Not System Application. | 7491 7492**Example** 7493 7494```ts 7495function unregisterSessionError(macroPhotoSession: camera.MacroPhotoSession): void { 7496 macroPhotoSession.off('error'); 7497} 7498``` 7499 7500### on('focusStateChange')<sup>12+</sup> 7501 7502on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7503 7504Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 7505 7506**System API**: This is a system API. 7507 7508**System capability**: SystemCapability.Multimedia.Camera.Core 7509 7510**Parameters** 7511 7512| Name | Type | Mandatory| Description | 7513|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 7514| 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.| 7515| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | Yes | Callback used to return the focus state change. | 7516 7517**Error codes** 7518 7519For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7520 7521| ID| Error Message | 7522|-------|----------------------------| 7523| 202 | Not System Application. | 7524 7525**Example** 7526 7527```ts 7528import { BusinessError } from '@kit.BasicServicesKit'; 7529 7530function callback(err: BusinessError, focusState: camera.FocusState): void { 7531 if (err !== undefined && err.code !== 0) { 7532 console.error(`Callback Error, errorCode: ${err.code}`); 7533 return; 7534 } 7535 console.info(`Focus state: ${focusState}`); 7536} 7537 7538function registerFocusStateChange(macroPhotoSession: camera.MacroPhotoSession): void { 7539 macroPhotoSession.on('focusStateChange', callback); 7540} 7541``` 7542 7543### off('focusStateChange')<sup>12+</sup> 7544 7545off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7546 7547Unsubscribes from focus state change events. 7548 7549**System API**: This is a system API. 7550 7551**System capability**: SystemCapability.Multimedia.Camera.Core 7552 7553**Parameters** 7554 7555| Name | Type | Mandatory| Description | 7556|-----------|---------------------------------------------|----|--------------------------------------------------------------| 7557| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. | 7558| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.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. | 7559 7560**Error codes** 7561 7562For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7563 7564| ID| Error Message | 7565|-------|----------------------------| 7566| 202 | Not System Application. | 7567 7568**Example** 7569 7570```ts 7571function unregisterFocusStateChange(macroPhotoSession: camera.MacroPhotoSession): void { 7572 macroPhotoSession.off('focusStateChange'); 7573} 7574``` 7575 7576### on('smoothZoomInfoAvailable')<sup>12+</sup> 7577 7578on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 7579 7580Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 7581 7582**System API**: This is a system API. 7583 7584**System capability**: SystemCapability.Multimedia.Camera.Core 7585 7586**Parameters** 7587 7588| Name | Type | Mandatory| Description | 7589| -------- | ----------------------- | ---- | ------------------------ | 7590| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 7591| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 7592 7593**Error codes** 7594 7595For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7596 7597| ID| Error Message | 7598|-------|----------------------------| 7599| 202 | Not System Application. | 7600 7601**Example** 7602 7603```ts 7604import { BusinessError } from '@kit.BasicServicesKit'; 7605 7606function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 7607 if (err !== undefined && err.code !== 0) { 7608 console.error(`Callback Error, errorCode: ${err.code}`); 7609 return; 7610 } 7611 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 7612} 7613 7614function registerSmoothZoomInfo(macroPhotoSession: camera.MacroPhotoSession): void { 7615 macroPhotoSession.on('smoothZoomInfoAvailable', callback); 7616} 7617``` 7618 7619### off('smoothZoomInfoAvailable')<sup>12+</sup> 7620 7621off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 7622 7623Unsubscribes from smooth zoom state change events. 7624 7625**System API**: This is a system API. 7626 7627**System capability**: SystemCapability.Multimedia.Camera.Core 7628 7629**Parameters** 7630 7631| Name | Type | Mandatory| Description | 7632| -------- | ----------------------------------------- | ---- | ------------------------ | 7633| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 7634| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.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.| 7635 7636**Error codes** 7637 7638For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7639 7640| ID| Error Message | 7641|-------|----------------------------| 7642| 202 | Not System Application. | 7643 7644**Example** 7645 7646```ts 7647function unregisterSmoothZoomInfo(macroPhotoSession: camera.MacroPhotoSession): void { 7648 macroPhotoSession.off('smoothZoomInfoAvailable'); 7649} 7650``` 7651 7652## MacroVideoSession<sup>12+</sup> 7653 7654MacroVideoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ManualFocus 7655 7656Implements a macro video session, which sets the parameters of the macro video mode and saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera. It inherits from [Session](arkts-apis-camera-Session.md). 7657 7658### on('error')<sup>12+</sup> 7659 7660on(type: 'error', callback: ErrorCallback): void 7661 7662Subscribes to MacroVideoSession error events. This API uses an asynchronous callback to return the result. 7663 7664**System API**: This is a system API. 7665 7666**System capability**: SystemCapability.Multimedia.Camera.Core 7667 7668**Parameters** 7669 7670| Name | Type | Mandatory | Description | 7671|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 7672| 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](arkts-apis-camera-Session.md#beginconfig11), [commitConfig](arkts-apis-camera-Session.md#commitconfig11-1), and [addInput](arkts-apis-camera-Session.md#addinput11).| 7673| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes | Callback used to return an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode). | 7674 7675**Error codes** 7676 7677For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7678 7679| ID| Error Message | 7680|-------|----------------------------| 7681| 202 | Not System Application. | 7682 7683**Example** 7684 7685```ts 7686import { BusinessError } from '@kit.BasicServicesKit'; 7687 7688function callback(err: BusinessError): void { 7689 console.error(`MacroPhotoSession error code: ${err.code}`); 7690} 7691 7692function registerSessionError(macroVideoSession: camera.MacroVideoSession): void { 7693 macroVideoSession.on('error', callback); 7694} 7695``` 7696 7697### off('error')<sup>12+</sup> 7698 7699off(type: 'error', callback?: ErrorCallback): void 7700 7701Unsubscribes from MacroVideoSession error events. 7702 7703**System API**: This is a system API. 7704 7705**System capability**: SystemCapability.Multimedia.Camera.Core 7706 7707**Parameters** 7708 7709| Name | Type | Mandatory| Description | 7710|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 7711| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. | 7712| 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.| 7713 7714**Error codes** 7715 7716For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7717 7718| ID| Error Message | 7719|-------|----------------------------| 7720| 202 | Not System Application. | 7721 7722**Example** 7723 7724```ts 7725function unregisterSessionError(macroVideoSession: camera.MacroVideoSession): void { 7726 macroVideoSession.off('error'); 7727} 7728``` 7729 7730### on('focusStateChange')<sup>12+</sup> 7731 7732on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7733 7734Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 7735 7736**System API**: This is a system API. 7737 7738**System capability**: SystemCapability.Multimedia.Camera.Core 7739 7740**Parameters** 7741 7742| Name | Type | Mandatory| Description | 7743|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 7744| 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.| 7745| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | Yes | Callback used to return the focus state change. | 7746 7747**Error codes** 7748 7749For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7750 7751| ID| Error Message | 7752|-------|----------------------------| 7753| 202 | Not System Application. | 7754 7755**Example** 7756 7757```ts 7758import { BusinessError } from '@kit.BasicServicesKit'; 7759 7760function callback(err: BusinessError, focusState: camera.FocusState): void { 7761 if (err !== undefined && err.code !== 0) { 7762 console.error(`Callback Error, errorCode: ${err.code}`); 7763 return; 7764 } 7765 console.info(`Focus state: ${focusState}`); 7766} 7767 7768function registerFocusStateChange(macroVideoSession: camera.MacroVideoSession): void { 7769 macroVideoSession.on('focusStateChange', callback); 7770} 7771``` 7772 7773### off('focusStateChange')<sup>12+</sup> 7774 7775off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7776 7777Unsubscribes from focus state change events. 7778 7779**System API**: This is a system API. 7780 7781**System capability**: SystemCapability.Multimedia.Camera.Core 7782 7783**Parameters** 7784 7785| Name | Type | Mandatory| Description | 7786|-----------|---------------------------------------------|----|--------------------------------------------------------------| 7787| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. | 7788| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.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. | 7789 7790**Error codes** 7791 7792For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7793 7794| ID| Error Message | 7795|-------|----------------------------| 7796| 202 | Not System Application. | 7797 7798**Example** 7799 7800```ts 7801function unregisterFocusStateChange(macroVideoSession: camera.MacroVideoSession): void { 7802 macroVideoSession.off('focusStateChange'); 7803} 7804``` 7805 7806### on('smoothZoomInfoAvailable')<sup>12+</sup> 7807 7808on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 7809 7810Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 7811 7812**System API**: This is a system API. 7813 7814**System capability**: SystemCapability.Multimedia.Camera.Core 7815 7816**Parameters** 7817 7818| Name | Type | Mandatory| Description | 7819| -------- | ----------------------- | ---- | ------------------------ | 7820| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 7821| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 7822 7823**Error codes** 7824 7825For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7826 7827| ID| Error Message | 7828|-------|----------------------------| 7829| 202 | Not System Application. | 7830 7831**Example** 7832 7833```ts 7834import { BusinessError } from '@kit.BasicServicesKit'; 7835 7836function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 7837 if (err !== undefined && err.code !== 0) { 7838 console.error(`Callback Error, errorCode: ${err.code}`); 7839 return; 7840 } 7841 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 7842} 7843 7844function registerSmoothZoomInfo(macroVideoSession: camera.MacroVideoSession): void { 7845 macroVideoSession.on('smoothZoomInfoAvailable', callback); 7846} 7847``` 7848 7849### off('smoothZoomInfoAvailable')<sup>12+</sup> 7850 7851off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 7852 7853Unsubscribes from smooth zoom state change events. 7854 7855**System API**: This is a system API. 7856 7857**System capability**: SystemCapability.Multimedia.Camera.Core 7858 7859**Parameters** 7860 7861| Name | Type | Mandatory| Description | 7862| -------- | ----------------------------------------- | ---- | ------------------------ | 7863| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 7864| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.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.| 7865 7866**Error codes** 7867 7868For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7869 7870| ID| Error Message | 7871|-------|----------------------------| 7872| 202 | Not System Application. | 7873 7874**Example** 7875 7876```ts 7877function unregisterSmoothZoomInfo(macroVideoSession: camera.MacroVideoSession): void { 7878 macroVideoSession.off('smoothZoomInfoAvailable'); 7879} 7880``` 7881 7882## FlashQuery<sup>12+</sup> 7883 7884Provides APIs to obtain the flash information of a camera device, including whether the LCD flash is supported. 7885 7886### isLcdFlashSupported<sup>12+</sup> 7887 7888isLcdFlashSupported(): boolean 7889 7890Checks whether the LCD flash is supported. 7891 7892**System API**: This is a system API. 7893 7894**System capability**: SystemCapability.Multimedia.Camera.Core 7895 7896**Return value** 7897 7898| Type | Description | 7899| -------------- | ----------------------- | 7900| boolean | Check result for the support of the LCD flash. **true** if supported, **false** otherwise.| 7901 7902**Error codes** 7903 7904For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 7905 7906| ID | Error Message | 7907| --------------- | --------------- | 7908| 202 | Not System Application. | 7909| 7400103 | Session not config, only throw in session usage. | 7910 7911**Example** 7912 7913```ts 7914function isLcdFlashSupported(nightPhotoSession: camera.NightPhotoSession): boolean { 7915 return nightPhotoSession.isLcdFlashSupported(); 7916} 7917``` 7918 7919## Flash<sup>11+</sup> 7920 7921Flash extends [FlashQuery](arkts-apis-camera-FlashQuery.md) 7922 7923Provides APIs related to the flash. 7924 7925### enableLcdFlash<sup>13+</sup> 7926 7927enableLcdFlash(enabled: boolean): void 7928 7929Enables or disables the LCD flash. 7930 7931Before the setting, call [isLcdFlashSupported](#islcdflashsupported12) to check whether the device supports the LCD flash. 7932 7933**System capability**: SystemCapability.Multimedia.Camera.Core 7934 7935**Parameters** 7936 7937| Name | Type | Mandatory| Description | 7938| --------- | ----------------------- | ---- |--------------------------------------------------| 7939| enabled | boolean | Yes | Whether to enable or disable the LCD flash. **true** to enable, **false** otherwise. If null or undefined is passed, it is treated as 0 and the LCD flash is disabled.| 7940 7941**Error codes** 7942 7943For details about the error codes, see [Camera Error Codes](errorcode-camera.md) and [Universal Error Codes](../errorcode-universal.md). 7944 7945| ID | Error Message | 7946| --------------- | --------------- | 7947| 202 | Not System Application. | 7948| 7400103 | Session not config. | 7949 7950**Example** 7951 7952```ts 7953import { BusinessError } from '@kit.BasicServicesKit'; 7954 7955function enableLcdFlash(session: camera.PhotoSessionForSys | camera.VideoSessionForSys | camera.NightPhotoSession): void { 7956 try { 7957 session.enableLcdFlash(true); 7958 } catch (error) { 7959 // If the operation fails, error.code is returned and processed. 7960 let err = error as BusinessError; 7961 console.error(`The setFlashMode call failed. error code: ${err.code}`); 7962 } 7963} 7964``` 7965 7966## TimeLapseRecordState<sup>12+</sup> 7967 7968Enumerates the time-lapse recording states. 7969 7970**System API**: This is a system API. 7971 7972**System capability**: SystemCapability.Multimedia.Camera.Core 7973 7974| Name | Value | Description | 7975| ----------------------------- | ---- | ----------- | 7976| IDLE | 0 | Recording not started.| 7977| RECORDING | 1 | Recording.| 7978 7979## TimeLapsePreviewType<sup>12+</sup> 7980 7981Enumerates the time-lapse preview types, which affect the shooting algorithm. 7982 7983**System API**: This is a system API. 7984 7985**System capability**: SystemCapability.Multimedia.Camera.Core 7986 7987| Name | Value | Description | 7988| ----------------------------- | ---- | ----------- | 7989| DARK | 1 | Dark environment, a scenario with poor illumination, for example, at night or in a dark area.| 7990| LIGHT | 2 | Bright environment, a scenario with good illumination, for example, in the daytime or under light.| 7991 7992## TryAEInfo<sup>12+</sup> 7993 7994Describes the Try AE parameters. Try AE indicates that the hardware reports the status based on the ambient illumination change during time-lapse photographing. 7995 7996**System API**: This is a system API. 7997 7998**System capability**: SystemCapability.Multimedia.Camera.Core 7999 8000| Name| Type | Read-only| Optional| Description | 8001| ---- | ------- | ---- |--| -------------- | 8002| isTryAEDone | boolean | Yes | No| Whether Try AE is complete. | 8003| isTryAEHintNeeded | boolean | Yes | Yes| Whether Try AE is required. | 8004| previewType | [TimeLapsePreviewType](#timelapsepreviewtype12) | Yes | Yes| Preview type. | 8005| captureInterval | number | Yes | Yes| Shooting interval, in ms. | 8006 8007## TimeLapsePhotoSession<sup>12+</sup> 8008 8009TimeLapsePhotoSession extends Session, Focus, ManualFocus, AutoExposure, ManualExposure, ManualIso, WhiteBalance, Zoom, ColorEffect 8010 8011Implements a time-lapse photo session, which sets the parameters of the time-lapse photo mode and saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera. It inherits from [Session](arkts-apis-camera-Session.md). 8012 8013### on('error')<sup>12+</sup> 8014 8015on(type: 'error', callback: ErrorCallback): void 8016 8017Subscribes to TimeLapsePhotoSession error events. This API uses an asynchronous callback to return the result. 8018 8019**System API**: This is a system API. 8020 8021**System capability**: SystemCapability.Multimedia.Camera.Core 8022 8023**Parameters** 8024 8025| Name | Type | Mandatory| Description | 8026| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 8027| 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](arkts-apis-camera-Session.md#beginconfig11), [commitConfig](arkts-apis-camera-Session.md#commitconfig11-1), and [addInput](arkts-apis-camera-Session.md#addinput11).| 8028| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes | Callback used to return an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode).| 8029 8030**Error codes** 8031 8032For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8033 8034| ID | Error Message | 8035|---------| --------------- | 8036| 202 | Not System Application. | 8037 8038**Example** 8039 8040```ts 8041import { BusinessError } from '@kit.BasicServicesKit'; 8042 8043function callback(err: BusinessError): void { 8044 console.error(`Time lapse photo session error code: ${err.code}`); 8045} 8046 8047function registerSessionError(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8048 timeLapsePhotoSession.on('error', callback); 8049} 8050``` 8051 8052### off('error')<sup>12+</sup> 8053 8054off(type: 'error', callback?: ErrorCallback): void 8055 8056Unsubscribes from TimeLapsePhotoSession error events. 8057 8058**System API**: This is a system API. 8059 8060**System capability**: SystemCapability.Multimedia.Camera.Core 8061 8062**Parameters** 8063 8064| Name | Type | Mandatory| Description | 8065| -------- | ------------------------ | ---- | ------------------------------ | 8066| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 8067| 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. | 8068 8069**Error codes** 8070 8071For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8072 8073| ID | Error Message | 8074|---------| --------------- | 8075| 202 | Not System Application. | 8076 8077**Example** 8078 8079```ts 8080function unregisterSessionError(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8081 timeLapsePhotoSession.off('error'); 8082} 8083``` 8084 8085### on('focusStateChange')<sup>12+</sup> 8086 8087on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 8088 8089Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 8090 8091**System API**: This is a system API. 8092 8093**System capability**: SystemCapability.Multimedia.Camera.Core 8094 8095**Parameters** 8096 8097| Name | Type | Mandatory| Description | 8098| -------- | ---------------- | ---- | ------------------------ | 8099| 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.| 8100| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | Yes | Callback used to return the focus state change. | 8101 8102**Error codes** 8103 8104For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8105 8106| ID | Error Message | 8107|---------| --------------- | 8108| 202 | Not System Application. | 8109 8110**Example** 8111 8112```ts 8113import { BusinessError } from '@kit.BasicServicesKit'; 8114 8115function callback(err: BusinessError, focusState: camera.FocusState): void { 8116 if (err !== undefined && err.code !== 0) { 8117 console.error(`Callback Error, errorCode: ${err.code}`); 8118 return; 8119 } 8120 console.info(`Focus state: ${focusState}`); 8121} 8122 8123function registerFocusStateChange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8124 timeLapsePhotoSession.on('focusStateChange', callback); 8125} 8126``` 8127 8128### off('focusStateChange')<sup>12+</sup> 8129 8130off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 8131 8132Unsubscribes from focus state change events. 8133 8134**System API**: This is a system API. 8135 8136**System capability**: SystemCapability.Multimedia.Camera.Core 8137 8138**Parameters** 8139 8140| Name | Type | Mandatory| Description | 8141| -------- | ----------------------------------------- | ---- | ------------------------ | 8142| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 8143| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.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.) | 8144 8145**Error codes** 8146 8147For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8148 8149| ID | Error Message | 8150|---------| --------------- | 8151| 202 | Not System Application. | 8152 8153**Example** 8154 8155```ts 8156function unregisterFocusStateChange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8157 timeLapsePhotoSession.off('focusStateChange'); 8158} 8159``` 8160 8161### on('isoInfoChange')<sup>12+</sup> 8162 8163on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 8164 8165Subscribes to automatic ISO change events to obtain real-time ISO information. This API uses an asynchronous callback to return the result. 8166 8167**System API**: This is a system API. 8168 8169**System capability**: SystemCapability.Multimedia.Camera.Core 8170 8171**Parameters** 8172 8173| Name | Type | Mandatory| Description | 8174| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8175| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 8176| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| Yes | Callback used to return the ISO information. | 8177 8178**Error codes** 8179 8180| ID| Error Message | 8181| ------- | ---------------------- | 8182| 202 | Not System Application. | 8183 8184**Example** 8185 8186```ts 8187import { BusinessError } from '@kit.BasicServicesKit'; 8188 8189function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 8190 if (err !== undefined && err.code !== 0) { 8191 console.error(`Callback Error, errorCode: ${err.code}`); 8192 return; 8193 } 8194 console.log(`ISO value: ${info.iso}`); 8195} 8196 8197function registerIsoInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8198 timeLapsePhotoSession.on('isoInfoChange', isoInfoCallback); 8199} 8200``` 8201 8202### off('isoInfoChange')<sup>12+</sup> 8203 8204off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 8205 8206Unsubscribes from automatic ISO change events. 8207 8208**System API**: This is a system API. 8209 8210**System capability**: SystemCapability.Multimedia.Camera.Core 8211 8212**Parameters** 8213 8214| Name | Type | Mandatory| Description | 8215| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8216| type | string | Yes | Event type. The value is fixed at **'isoInfoChange'**. | 8217| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('isoInfoChange')**.| 8218 8219**Error codes** 8220 8221| ID| Error Message | 8222| ------- | ---------------------- | 8223| 202 | Not System Application. | 8224 8225**Example** 8226 8227```ts 8228function unregisterIsoInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8229 timeLapsePhotoSession.off('isoInfoChange'); 8230} 8231``` 8232 8233### on('exposureInfoChange')<sup>12+</sup> 8234 8235on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 8236 8237Subscribes to exposure information change events to obtain the exposure information. This API uses an asynchronous callback to return the result. 8238 8239**System API**: This is a system API. 8240 8241**System capability**: SystemCapability.Multimedia.Camera.Core 8242 8243**Parameters** 8244 8245| Name | Type | Mandatory| Description | 8246| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8247| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 8248| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| Yes | Callback used to return the exposure information. | 8249 8250**Error codes** 8251 8252| ID| Error Message | 8253| ------- | ---------------------- | 8254| 202 | Not System Application. | 8255 8256**Example** 8257 8258```ts 8259import { BusinessError } from '@kit.BasicServicesKit'; 8260 8261function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 8262 if (err !== undefined && err.code !== 0) { 8263 console.error(`Callback Error, errorCode: ${err.code}`); 8264 return; 8265 } 8266 console.log(`exposureTimeValue: ${info.exposureTime}`); 8267} 8268 8269function registerExposureInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8270 timeLapsePhotoSession.on('exposureInfoChange', exposureInfoCallback); 8271} 8272``` 8273 8274### off('exposureInfoChange')<sup>12+</sup> 8275 8276off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 8277 8278Unsubscribes from exposure information change events. 8279 8280**System API**: This is a system API. 8281 8282**System capability**: SystemCapability.Multimedia.Camera.Core 8283 8284**Parameters** 8285 8286| Name | Type | Mandatory| Description | 8287| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8288| type | string | Yes | Event type. The value is fixed at **'exposureInfoChange'**. | 8289| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('exposureInfoChange')**.| 8290 8291**Error codes** 8292 8293| ID| Error Message | 8294| ------- | ---------------------- | 8295| 202 | Not System Application. | 8296 8297**Example** 8298 8299```ts 8300function unregisterExposureInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8301 timeLapsePhotoSession.off('exposureInfoChange'); 8302} 8303``` 8304 8305### on('luminationInfoChange')<sup>12+</sup> 8306 8307on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 8308 8309Subscribes to illumination change events to obtain real-time illumination information. This API uses an asynchronous callback to return the result. 8310 8311**System API**: This is a system API. 8312 8313**System capability**: SystemCapability.Multimedia.Camera.Core 8314 8315**Parameters** 8316 8317| Name | Type | Mandatory| Description | 8318| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8319| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 8320| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| Yes | Callback used to return the illumination information. | 8321 8322**Error codes** 8323 8324| ID| Error Message | 8325| ------- | ---------------------- | 8326| 202 | Not System Application. | 8327 8328**Example** 8329 8330```ts 8331import { BusinessError } from '@kit.BasicServicesKit'; 8332 8333function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 8334 if (err !== undefined && err.code !== 0) { 8335 console.error(`Callback Error, errorCode: ${err.code}`); 8336 return; 8337 } 8338 console.log(`Lumination: ${info.lumination}`); 8339} 8340 8341function registerLuminationInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8342 timeLapsePhotoSession.on('luminationInfoChange', luminationInfoCallback); 8343} 8344``` 8345 8346### off('luminationInfoChange')<sup>12+</sup> 8347 8348off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 8349 8350Unsubscribes from illumination change events. 8351 8352**System API**: This is a system API. 8353 8354**System capability**: SystemCapability.Multimedia.Camera.Core 8355 8356**Parameters** 8357 8358| Name | Type | Mandatory| Description | 8359| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8360| type | string | Yes | Event type. The value is fixed at **'luminationInfoChange'**. | 8361| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('luminationInfoChange')**.| 8362 8363**Error codes** 8364 8365| ID| Error Message | 8366| ------- | ---------------------- | 8367| 202 | Not System Application. | 8368 8369**Example** 8370 8371```ts 8372function unregisterLuminationInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8373 timeLapsePhotoSession.off('luminationInfoChange'); 8374} 8375``` 8376 8377### on('tryAEInfoChange')<sup>12+</sup> 8378 8379on(type: 'tryAEInfoChange', callback: AsyncCallback\<TryAEInfo\>): void 8380 8381Subscribes to Try AE change events to obtain real-time Try AE parameters. This API uses an asynchronous callback to return the result. 8382 8383**System API**: This is a system API. 8384 8385**System capability**: SystemCapability.Multimedia.Camera.Core 8386 8387**Parameters** 8388 8389| Name | Type | Mandatory| Description | 8390| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8391| type | string | Yes | Event type. The value is fixed at **'tryAEInfoChange'**. | 8392| callback | AsyncCallback\<[TryAEInfo](#tryaeinfo12)\>| Yes | Callback used to return the Try AE parameters. | 8393 8394**Error codes** 8395 8396| ID| Error Message | 8397| ------- | ---------------------- | 8398| 202 | Not System Application. | 8399 8400**Example** 8401 8402```ts 8403import { BusinessError } from '@kit.BasicServicesKit'; 8404 8405function tryAEInfoCallback(err: BusinessError, info: camera.TryAEInfo): void { 8406 if (err !== undefined && err.code !== 0) { 8407 console.error(`Callback Error, errorCode: ${err.code}`); 8408 return; 8409 } 8410 console.log(`TryAEInfo: ${info.isTryAEDone}, ${info.isTryAEHintNeeded}, ${info.previewType}, ${info.captureInterval}`); 8411} 8412 8413function registerTryAEInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8414 timeLapsePhotoSession.on('tryAEInfoChange', tryAEInfoCallback); 8415} 8416``` 8417 8418### off('tryAEInfoChange')<sup>12+</sup> 8419 8420off(type: 'tryAEInfoChange', callback?: AsyncCallback\<TryAEInfo\>): void 8421 8422Unsubscribes from Try AE change events. 8423 8424**System API**: This is a system API. 8425 8426**System capability**: SystemCapability.Multimedia.Camera.Core 8427 8428**Parameters** 8429 8430| Name | Type | Mandatory| Description | 8431| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8432| type | string | Yes | Event type. The value is fixed at **'tryAEInfoChange'**. | 8433| callback | AsyncCallback\<[TryAEInfo](#tryaeinfo12)\>| No | Callback, which is optional and is used to match **callback** in **on('tryAEInfoChange')**.| 8434 8435**Error codes** 8436 8437| ID| Error Message | 8438| ------- | ---------------------- | 8439| 202 | Not System Application. | 8440 8441**Example** 8442 8443```ts 8444function unregisterTryAEInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8445 timeLapsePhotoSession.off('tryAEInfoChange'); 8446} 8447``` 8448 8449### isTryAENeeded<sup>12+</sup> 8450 8451isTryAENeeded(): boolean 8452 8453Checks whether Try AE is required. 8454 8455**System API**: This is a system API. 8456 8457**System capability**: SystemCapability.Multimedia.Camera.Core 8458 8459**Return value** 8460 8461| Type | Description | 8462| ---------- | ----------------------------- | 8463| boolean | Check result for whether Try AE is required. **true** if required, **false** otherwise. The error code type is defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode).| 8464 8465**Error codes** 8466 8467For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8468 8469| ID | Error Message | 8470| --------------- | --------------- | 8471| 202 | Not System Application. | 8472| 7400103 | Session not config. | 8473 8474**Example** 8475 8476```ts 8477import { BusinessError } from '@kit.BasicServicesKit'; 8478 8479function isTryAENeeded(timeLapsePhotoSession: camera.TimeLapsePhotoSession): boolean { 8480 let needed = false; 8481 try { 8482 needed = timeLapsePhotoSession.isTryAENeeded(); 8483 } catch (error) { 8484 // If the operation fails, error.code is returned and processed. 8485 let err = error as BusinessError; 8486 console.error(`The isTryAENeeded call failed. error code: ${err.code}`); 8487 } 8488 return needed; 8489} 8490``` 8491 8492### startTryAE<sup>12+</sup> 8493 8494startTryAE(): void 8495 8496Starts to execute Try AE. 8497 8498**System API**: This is a system API. 8499 8500**System capability**: SystemCapability.Multimedia.Camera.Core 8501 8502**Error codes** 8503 8504For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8505 8506| ID | Error Message | 8507| --------------- | --------------- | 8508| 202 | Not System Application. | 8509| 7400103 | Session not config. | 8510 8511**Example** 8512 8513```ts 8514import { BusinessError } from '@kit.BasicServicesKit'; 8515 8516function startTryAE(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8517 try { 8518 timeLapsePhotoSession.startTryAE(); 8519 } catch (error) { 8520 // If the operation fails, error.code is returned and processed. 8521 let err = error as BusinessError; 8522 console.error(`The startTryAE call failed. error code: ${err.code}`); 8523 } 8524} 8525``` 8526 8527### stopTryAE<sup>12+</sup> 8528 8529stopTryAE(): void 8530 8531Stops the execution of Try AE. 8532 8533**System API**: This is a system API. 8534 8535**System capability**: SystemCapability.Multimedia.Camera.Core 8536 8537**Error codes** 8538 8539For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8540 8541| ID | Error Message | 8542| --------------- | --------------- | 8543| 202 | Not System Application. | 8544| 7400103 | Session not config. | 8545 8546**Example** 8547 8548```ts 8549import { BusinessError } from '@kit.BasicServicesKit'; 8550 8551function stopTryAE(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8552 try { 8553 timeLapsePhotoSession.stopTryAE(); 8554 } catch (error) { 8555 // If the operation fails, error.code is returned and processed. 8556 let err = error as BusinessError; 8557 console.error(`The stopTryAE call failed. error code: ${err.code}`); 8558 } 8559} 8560``` 8561 8562### getSupportedTimeLapseIntervalRange<sup>12+</sup> 8563 8564getSupportedTimeLapseIntervalRange(): Array\<number\> 8565 8566Obtains the supported time-lapse shooting interval range. 8567 8568**System API**: This is a system API. 8569 8570**System capability**: SystemCapability.Multimedia.Camera.Core 8571 8572**Return value** 8573 8574| Type | Description | 8575| ---------- | ----------------------------- | 8576| Array\<number\> | Interval range, in ms. The value depends on the underlying capability. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 8577 8578**Error codes** 8579 8580For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8581 8582| ID | Error Message | 8583| --------------- | --------------- | 8584| 202 | Not System Application. | 8585| 7400103 | Session not config. | 8586 8587**Example** 8588 8589```ts 8590import { BusinessError } from '@kit.BasicServicesKit'; 8591 8592function getSupportedTimeLapseIntervalRange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): Array<number> { 8593 let intervalRange: Array<number> = []; 8594 try { 8595 intervalRange = timeLapsePhotoSession.getSupportedTimeLapseIntervalRange(); 8596 } catch (error) { 8597 // If the operation fails, error.code is returned and processed. 8598 let err = error as BusinessError; 8599 console.error(`The getSupportedTimeLapseIntervalRange call failed. error code: ${err.code}`); 8600 } 8601 return intervalRange; 8602} 8603``` 8604 8605### getTimeLapseInterval<sup>12+</sup> 8606 8607getTimeLapseInterval(): number 8608 8609Obtains the current time-lapse shooting interval. 8610 8611**System API**: This is a system API. 8612 8613**System capability**: SystemCapability.Multimedia.Camera.Core 8614 8615**Return value** 8616 8617| Type | Description | 8618| ---------- | ----------------------------- | 8619| number | Shooting interval, in ms.| 8620 8621**Error codes** 8622 8623For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8624 8625| ID | Error Message | 8626| --------------- | --------------- | 8627| 202 | Not System Application. | 8628| 7400103 | Session not config. | 8629 8630**Example** 8631 8632```ts 8633import { BusinessError } from '@kit.BasicServicesKit'; 8634 8635function getTimeLapseInterval(timeLapsePhotoSession: camera.TimeLapsePhotoSession): number { 8636 let interval: number = 0; 8637 try { 8638 interval = timeLapsePhotoSession.getTimeLapseInterval(); 8639 } catch (error) { 8640 // If the operation fails, error.code is returned and processed. 8641 let err = error as BusinessError; 8642 console.error(`The getTimeLapseInterval call failed. error code: ${err.code}`); 8643 } 8644 return interval; 8645} 8646``` 8647 8648### setTimeLapseInterval<sup>12+</sup> 8649setTimeLapseInterval(interval: number): void 8650 8651Sets a time-lapse shooting interval. 8652 8653**System API**: This is a system API. 8654 8655**System capability**: SystemCapability.Multimedia.Camera.Core 8656 8657**Parameters** 8658 8659| Name | Type | Mandatory| Description | 8660| -------- | ----------------------- | ---- | ------------------- | 8661| interval | number | Yes | Shooting interval, in ms.| 8662 8663**Error codes** 8664 8665For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8666 8667| ID | Error Message | 8668| --------------- | --------------- | 8669| 202 | Not System Application. | 8670| 7400101 | Parameter missing or parameter type incorrect. | 8671| 7400103 | Session not config. | 8672 8673**Example** 8674 8675```ts 8676import { BusinessError } from '@kit.BasicServicesKit'; 8677 8678function setTimeLapseInterval(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8679 try { 8680 let interval: number = 10000; 8681 timeLapsePhotoSession.setTimeLapseInterval(interval); 8682 } catch (error) { 8683 // If the operation fails, error.code is returned and processed. 8684 let err = error as BusinessError; 8685 console.error(`The setTimeLapseInterval call failed. error code: ${err.code}`); 8686 } 8687} 8688``` 8689 8690### getTimeLapseRecordState<sup>12+</sup> 8691 8692getTimeLapseRecordState(): TimeLapseRecordState 8693 8694Obtains the time-lapse shooting state. 8695 8696**System API**: This is a system API. 8697 8698**System capability**: SystemCapability.Multimedia.Camera.Core 8699 8700**Return value** 8701 8702| Type | Description | 8703| ---------- | ----------------------------- | 8704| [TimeLapseRecordState](#timelapserecordstate12) | Shooting state. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 8705 8706**Error codes** 8707 8708For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8709 8710| ID | Error Message | 8711| --------------- | --------------- | 8712| 202 | Not System Application. | 8713| 7400103 | Session not config. | 8714 8715**Example** 8716 8717```ts 8718import { BusinessError } from '@kit.BasicServicesKit'; 8719 8720function getTimeLapseRecordState(timeLapsePhotoSession: camera.TimeLapsePhotoSession): camera.TimeLapseRecordState { 8721 let state = camera.TimeLapseRecordState.IDLE; 8722 try { 8723 state = timeLapsePhotoSession.getTimeLapseRecordState(); 8724 } catch (error) { 8725 // If the operation fails, error.code is returned and processed. 8726 let err = error as BusinessError; 8727 console.error(`The getTimeLapseRecordState call failed. error code: ${err.code}`); 8728 } 8729 return state; 8730} 8731``` 8732 8733### setTimeLapseRecordState<sup>12+</sup> 8734 8735setTimeLapseRecordState(state: TimeLapseRecordState): void 8736 8737Sets the time-lapse shooting state. 8738 8739**System API**: This is a system API. 8740 8741**System capability**: SystemCapability.Multimedia.Camera.Core 8742 8743**Parameters** 8744 8745| Name | Type | Mandatory| Description | 8746| -------- | -------------------------------| ---- | ----------------------- | 8747| state | [TimeLapseRecordState](#timelapserecordstate12) | Yes | Shooting state. | 8748 8749**Error codes** 8750 8751For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8752 8753| ID | Error Message | 8754| --------------- | --------------- | 8755| 202 | Not System Application. | 8756| 7400101 | Parameter missing or parameter type incorrect. | 8757| 7400103 | Session not config. | 8758 8759**Example** 8760 8761```ts 8762import { BusinessError } from '@kit.BasicServicesKit'; 8763 8764function setTimeLapseRecordState(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8765 try { 8766 timeLapsePhotoSession.setTimeLapseRecordState(camera.TimeLapseRecordState.RECORDING); 8767 } catch (error) { 8768 // If the operation fails, error.code is returned and processed. 8769 let err = error as BusinessError; 8770 console.error(`The setTimeLapseRecordState call failed. error code: ${err.code}`); 8771 } 8772} 8773``` 8774 8775### getTimeLapsePreviewType<sup>12+</sup> 8776 8777getTimeLapsePreviewType(): TimeLapsePreviewType 8778 8779Obtains the time-lapse preview type. 8780 8781**System API**: This is a system API. 8782 8783**System capability**: SystemCapability.Multimedia.Camera.Core 8784 8785**Return value** 8786 8787| Type | Description | 8788| ---------- | ----------------------------- | 8789| [TimeLapsePreviewType](#timelapsepreviewtype12) | Preview type. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 8790 8791**Error codes** 8792 8793For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8794 8795| ID | Error Message | 8796| --------------- | --------------- | 8797| 202 | Not System Application. | 8798| 7400103 | Session not config. | 8799 8800**Example** 8801 8802```ts 8803import { BusinessError } from '@kit.BasicServicesKit'; 8804 8805function getTimeLapsePreviewType(timeLapsePhotoSession: camera.TimeLapsePhotoSession): camera.TimeLapsePreviewType { 8806 let type = camera.TimeLapsePreviewType.DARK; 8807 try { 8808 type = timeLapsePhotoSession.getTimeLapsePreviewType(); 8809 } catch (error) { 8810 // If the operation fails, error.code is returned and processed. 8811 let err = error as BusinessError; 8812 console.error(`The getTimeLapsePreviewType call failed. error code: ${err.code}`); 8813 } 8814 return type; 8815} 8816``` 8817 8818### setTimeLapsePreviewType<sup>12+</sup> 8819 8820setTimeLapsePreviewType(type: TimeLapsePreviewType): void 8821 8822Sets the time-lapse preview type. 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| state | [TimeLapsePreviewType](#timelapsepreviewtype12) | Yes | Preview type. | 8833 8834**Error codes** 8835 8836For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8837 8838| ID | Error Message | 8839| --------------- | --------------- | 8840| 202 | Not System Application. | 8841| 7400101 | Parameter missing or parameter type incorrect. | 8842| 7400103 | Session not config. | 8843 8844**Example** 8845 8846```ts 8847import { BusinessError } from '@kit.BasicServicesKit'; 8848 8849function setTimeLapsePreviewType(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8850 try { 8851 timeLapsePhotoSession.setTimeLapsePreviewType(camera.TimeLapsePreviewType.LIGHT); 8852 } catch (error) { 8853 // If the operation fails, error.code is returned and processed. 8854 let err = error as BusinessError; 8855 console.error(`The setTimeLapsePreviewType call failed. error code: ${err.code}`); 8856 } 8857} 8858``` 8859 8860## LightPaintingPhotoSession<sup>12+</sup> 8861 8862LightPaintingPhotoSession extends Session, Flash, Focus, Zoom, ColorEffect 8863 8864Implements a light painting photo session, which sets the parameters of the light painting photo mode and saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera. It inherits from [Session](arkts-apis-camera-Session.md). 8865 8866### on('error')<sup>12+</sup> 8867 8868on(type: 'error', callback: ErrorCallback): void 8869 8870Subscribes to LightPaintingPhotoSession error events. This API uses an asynchronous callback to return the result. 8871 8872**System API**: This is a system API. 8873 8874**System capability**: SystemCapability.Multimedia.Camera.Core 8875 8876**Parameters** 8877 8878| Name | Type | Mandatory | Description | 8879|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 8880| 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](arkts-apis-camera-Session.md#beginconfig11), [commitConfig](arkts-apis-camera-Session.md#commitconfig11-1), and [addInput](arkts-apis-camera-Session.md#addinput11).| 8881| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes | Callback used to return an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode). | 8882 8883**Error codes** 8884 8885For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8886 8887| ID| Error Message | 8888|-------|----------------------------| 8889| 202 | Not System Application. | 8890 8891**Example** 8892 8893```ts 8894import { BusinessError } from '@kit.BasicServicesKit'; 8895 8896function callback(err: BusinessError): void { 8897 console.error(`LightPaintingPhotoSession error code: ${err.code}`); 8898} 8899 8900function registerSessionError(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8901 lightPaintingPhotoSession.on('error', callback); 8902} 8903``` 8904 8905### off('error')<sup>12+</sup> 8906 8907off(type: 'error', callback?: ErrorCallback): void 8908 8909Unsubscribes from LightPaintingPhotoSession error events. 8910 8911**System API**: This is a system API. 8912 8913**System capability**: SystemCapability.Multimedia.Camera.Core 8914 8915**Parameters** 8916 8917| Name | Type | Mandatory| Description | 8918|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 8919| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. | 8920| 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.| 8921 8922**Error codes** 8923 8924For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8925 8926| ID| Error Message | 8927|-------|----------------------------| 8928| 202 | Not System Application. | 8929 8930**Example** 8931 8932```ts 8933function unregisterSessionError(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8934 lightPaintingPhotoSession.off('error'); 8935} 8936``` 8937 8938### on('focusStateChange')<sup>12+</sup> 8939 8940on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 8941 8942Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 8943 8944**System API**: This is a system API. 8945 8946**System capability**: SystemCapability.Multimedia.Camera.Core 8947 8948**Parameters** 8949 8950| Name | Type | Mandatory| Description | 8951|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 8952| 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.| 8953| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | Yes | Callback used to return the focus state change. | 8954 8955**Error codes** 8956 8957For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 8958 8959| ID| Error Message | 8960|-------|----------------------------| 8961| 202 | Not System Application. | 8962 8963**Example** 8964 8965```ts 8966import { BusinessError } from '@kit.BasicServicesKit'; 8967 8968function callback(err: BusinessError, focusState: camera.FocusState): void { 8969 if (err !== undefined && err.code !== 0) { 8970 console.error(`Callback Error, errorCode: ${err.code}`); 8971 return; 8972 } 8973 console.info(`Focus state: ${focusState}`); 8974} 8975 8976function registerFocusStateChange(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8977 lightPaintingPhotoSession.on('focusStateChange', callback); 8978} 8979``` 8980 8981### off('focusStateChange')<sup>12+</sup> 8982 8983off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 8984 8985Unsubscribes from focus state change events. 8986 8987**System API**: This is a system API. 8988 8989**System capability**: SystemCapability.Multimedia.Camera.Core 8990 8991**Parameters** 8992 8993| Name | Type | Mandatory| Description | 8994|-----------|---------------------------------------------|----|--------------------------------------------------------------| 8995| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. | 8996| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.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. | 8997 8998**Error codes** 8999 9000For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 9001 9002| ID| Error Message | 9003|-------|----------------------------| 9004| 202 | Not System Application. | 9005 9006**Example** 9007 9008```ts 9009function unregisterFocusStateChange(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 9010 lightPaintingPhotoSession.off('focusStateChange'); 9011} 9012``` 9013 9014### on('smoothZoomInfoAvailable')<sup>12+</sup> 9015 9016on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 9017 9018Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result. 9019 9020**System API**: This is a system API. 9021 9022**System capability**: SystemCapability.Multimedia.Camera.Core 9023 9024**Parameters** 9025 9026| Name | Type | Mandatory| Description | 9027| -------- | ----------------------- | ---- | ------------------------ | 9028| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 9029| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | Yes | Callback used to return the smooth zoom state change. | 9030 9031**Error codes** 9032 9033For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 9034 9035| ID| Error Message | 9036|-------|----------------------------| 9037| 202 | Not System Application. | 9038 9039**Example** 9040 9041```ts 9042import { BusinessError } from '@kit.BasicServicesKit'; 9043 9044function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 9045 if (err !== undefined && err.code !== 0) { 9046 console.error(`Callback Error, errorCode: ${err.code}`); 9047 return; 9048 } 9049 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 9050} 9051 9052function registerSmoothZoomInfo(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 9053 lightPaintingPhotoSession.on('smoothZoomInfoAvailable', callback); 9054} 9055``` 9056 9057### off('smoothZoomInfoAvailable')<sup>12+</sup> 9058 9059off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 9060 9061Unsubscribes from smooth zoom state change events. 9062 9063**System API**: This is a system API. 9064 9065**System capability**: SystemCapability.Multimedia.Camera.Core 9066 9067**Parameters** 9068 9069| Name | Type | Mandatory| Description | 9070| -------- | ----------------------------------------- | ---- | ------------------------ | 9071| type | string | Yes | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.| 9072| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.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.| 9073 9074**Error codes** 9075 9076For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 9077 9078| ID| Error Message | 9079|-------|----------------------------| 9080| 202 | Not System Application. | 9081 9082**Example** 9083 9084```ts 9085function unregisterSmoothZoomInfo(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 9086 lightPaintingPhotoSession.off('smoothZoomInfoAvailable'); 9087} 9088``` 9089 9090### getLightPaintingType<sup>12+</sup> 9091 9092getLightPaintingType(): LightPaintingType 9093 9094Obtains the type of light painting shutter mode in use. 9095 9096**System API**: This is a system API. 9097 9098**System capability**: SystemCapability.Multimedia.Camera.Core 9099 9100**Return value** 9101| Type | Description | 9102|------------------------------------------------- | --------------------- | 9103| [LightPaintingType](#lightpaintingtype12) | Type of light painting shutter mode. | 9104 9105**Error codes** 9106 9107For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 9108 9109| ID | Error Message | 9110| --------------- | --------------- | 9111| 202 | Not System Application. | 9112| 7400103 | Session not config. | 9113 9114**Example** 9115 9116```ts 9117function getLightPaintingType(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): camera.LightPaintingType { 9118 let type: camera.LightPaintingType = lightPaintingPhotoSession.getLightPaintingType(); 9119 return type; 9120} 9121``` 9122 9123### setLightPaintingType<sup>12+</sup> 9124 9125setLightPaintingType(type: LightPaintingType): void 9126 9127Sets the type of light painting shutter mode. 9128 9129**System API**: This is a system API. 9130 9131**System capability**: SystemCapability.Multimedia.Camera.Core 9132 9133**Return value** 9134| Name | Type | Mandatory| Description | 9135| -------- | ----------------------- | ---- | ------------------- | 9136| type | [LightPaintingType](#lightpaintingtype12) | Yes | Type of light painting mode.| 9137 9138**Error codes** 9139 9140For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 9141 9142| ID | Error Message | 9143| --------------- | --------------- | 9144| 202 | Not System Application. | 9145| 7400101 | Parameter missing or parameter type incorrect. | 9146| 7400103 | Session not config. | 9147 9148**Example** 9149 9150```ts 9151import { BusinessError } from '@kit.BasicServicesKit'; 9152 9153function setLightPaintingType(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 9154 try { 9155 let type: camera.LightPaintingType = camera.LightPaintingType.TRAFFIC_TRAILS; 9156 lightPaintingPhotoSession.setLightPaintingType(type); 9157 } catch (error) { 9158 // If the operation fails, error.code is returned and processed. 9159 let err = error as BusinessError; 9160 console.error(`The setLightPaintingType call failed. error code: ${err.code}`); 9161 } 9162} 9163``` 9164 9165### getSupportedLightPaintingTypes<sup>12+</sup> 9166 9167getSupportedLightPaintingTypes(): Array\<LightPaintingType\> 9168 9169Obtains the supported types of light painting shutter mode. 9170 9171**System API**: This is a system API. 9172 9173**System capability**: SystemCapability.Multimedia.Camera.Core 9174 9175**Return value** 9176| Type | Description | 9177|------------------------------------------------- | --------------------- | 9178| Array\<[LightPaintingType](#lightpaintingtype12)\> | Supported types of light painting shutter mode. | 9179 9180**Error codes** 9181 9182For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 9183 9184| ID | Error Message | 9185| --------------- | --------------- | 9186| 202 | Not System Application. | 9187| 7400103 | Session not config. | 9188 9189**Example** 9190 9191```ts 9192function getSupportedLightPaintingTypes(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): Array<camera.LightPaintingType> { 9193 let types: Array<camera.LightPaintingType> = lightPaintingPhotoSession.getSupportedLightPaintingTypes(); 9194 return types 9195} 9196``` 9197 9198## ColorReservationType<sup>15+</sup> 9199 9200Enumerates the color reservation types. 9201 9202**System capability**: SystemCapability.Multimedia.Camera.Core 9203 9204| Name | Value | Description | 9205| -------- | ---- | ---------------- | 9206| NONE | 0 | No color reservation.| 9207| PORTRAIT | 1 | Portrait color reservation. | 9208 9209## ColorReservationQuery<sup>15+</sup> 9210 9211Provides APIs for querying the color retention type supported by the device. 9212 9213### getSupportedColorReservationTypes<sup>15+</sup> 9214 9215getSupportedColorReservationTypes(): Array\<ColorReservationType\> 9216 9217Obtains the supported color reservation types. 9218 9219**System API**: This is a system API. 9220 9221**System capability**: SystemCapability.Multimedia.Camera.Core 9222 9223**Return value** 9224 9225| Type | Description | 9226| ------------------------------------------------------ | ------------------------ | 9227| Array<[ColorReservationType](#colorreservationtype15)> | Array of color reservation types supported.| 9228 9229**Error codes** 9230 9231For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 9232 9233| ID| Error Message | 9234| -------- | ----------------------- | 9235| 202 | Not System Application. | 9236| 7400103 | Session not config. | 9237 9238**Example** 9239 9240```ts 9241import { BusinessError } from '@kit.BasicServicesKit'; 9242 9243function getSupportedColorReservationTypes(session: camera.VideoSessionForSys): Array<camera.ColorReservationType> { 9244 let colorReservationTypes: Array<camera.ColorReservationType> = []; 9245 try { 9246 colorReservationTypes = session.getSupportedColorReservationTypes(); 9247 } catch (error) { 9248 // If the operation fails, error.code is returned and processed. 9249 let err = error as BusinessError; 9250 console.error(`The getSupportedColorReservationTypes call failed. error code: ${err.code}`); 9251 } 9252 return colorReservationTypes; 9253} 9254``` 9255 9256## ColorReservation<sup>15+</sup> 9257 9258ColorReservation extends [ColorReservationQuery](#colorreservationquery15) 9259 9260Provides API for obtaining and setting a color reservation type. 9261 9262### setColorReservation<sup>15+</sup> 9263 9264setColorReservation(type: ColorReservationType): void 9265 9266Sets a color reservation type. Before the setting, call [getSupportedColorReservationTypes](#getsupportedcolorreservationtypes15) to obtain the supported color reservation types. 9267 9268**System API**: This is a system API. 9269 9270**System capability**: SystemCapability.Multimedia.Camera.Core 9271 9272**Parameters** 9273 9274| Name| Type | Mandatory| Description | 9275| ------ | ----------------------------------------------- | ---- | ------------------------------------------------------------ | 9276| type | [ColorReservationType](#colorreservationtype15) | Yes | Color reservation type, which is obtained by calling [getSupportedColorReservationTypes](#getsupportedcolorreservationtypes15).| 9277 9278**Error codes** 9279 9280For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 9281 9282| ID| Error Message | 9283| -------- | ------------------------------------------------------------ | 9284| 202 | Not System Application. | 9285| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3.Parameter verification failed. | 9286| 7400102 | Operation not allowed. | 9287| 7400103 | Session not config. | 9288| 7400201 | Camera service fatal error. | 9289 9290**Example** 9291 9292```ts 9293import { BusinessError } from '@kit.BasicServicesKit'; 9294 9295function setColorReservation(session: camera.VideoSessionForSys, type: camera.ColorReservationType): void { 9296 try { 9297 session.setColorReservation(type); 9298 } catch (error) { 9299 // If the operation fails, error.code is returned and processed. 9300 let err = error as BusinessError; 9301 console.error(`The setColorReservation call failed. error code: ${err.code}`); 9302 } 9303} 9304``` 9305 9306### getColorReservation<sup>15+</sup> 9307 9308getColorReservation(): ColorReservationType 9309 9310Obtains the color reservation type in use. 9311 9312**System API**: This is a system API. 9313 9314**System capability**: SystemCapability.Multimedia.Camera.Core 9315 9316**Return value** 9317 9318| Type | Description | 9319| ----------------------------------------------- | ------------------------ | 9320| [ColorReservationType](#colorreservationtype15) | Color reservation type.| 9321 9322**Error codes** 9323 9324For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 9325 9326| ID| Error Message | 9327| -------- | ----------------------- | 9328| 202 | Not System Application. | 9329| 7400103 | Session not config. | 9330 9331**Example** 9332 9333```ts 9334import { BusinessError } from '@kit.BasicServicesKit'; 9335 9336function getColorReservation(session: camera.VideoSessionForSys): camera.ColorReservationType | undefined { 9337 let colorReservation: camera.ColorReservationType | undefined = undefined; 9338 try { 9339 colorReservation = session.getColorReservation(); 9340 } catch (error) { 9341 // If the operation fails, error.code is returned and processed. 9342 let err = error as BusinessError; 9343 console.error(`The setColorReservation call failed. error code: ${err.code}`); 9344 } 9345 return colorReservation; 9346} 9347``` 9348