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