1# Deprecated Interface (CaptureSession, deprecated) 2<!--Kit: Camera Kit--> 3<!--Subsystem: Multimedia--> 4<!--Owner: @qano--> 5<!--SE: @leo_ysl--> 6<!--TSE: @xchaosioda--> 7 8> **NOTE** 9> 10> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [PhotoSession](arkts-apis-camera-PhotoSession.md) and [VideoSession](arkts-apis-camera-VideoSession.md) instead. 11 12CaptureSession implements a capture session, which saves all [CameraInput](arkts-apis-camera-CameraInput.md) and [CameraOutput](arkts-apis-camera-CameraOutput.md) instances required to run the camera and requests the camera to complete shooting or video recording. 13 14## Modules to Import 15 16```ts 17import { camera } from '@kit.CameraKit'; 18``` 19 20## beginConfig<sup>(deprecated)</sup> 21 22beginConfig(): void 23 24Starts configuration for the session. 25 26> **NOTE** 27> 28> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.beginConfig](arkts-apis-camera-Session.md#beginconfig11) instead. 29 30**System capability**: SystemCapability.Multimedia.Camera.Core 31 32**Error codes** 33 34For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 35 36| ID | Error Message | 37| --------------- | --------------- | 38| 7400105 | Session config locked. | 39 40**Example** 41 42```ts 43import { BusinessError } from '@kit.BasicServicesKit'; 44 45function beginConfig(captureSession: camera.CaptureSession): void { 46 try { 47 captureSession.beginConfig(); 48 } catch (error) { 49 // If the operation fails, error.code is returned and processed. 50 let err = error as BusinessError; 51 console.error(`The beginConfig call failed. error code: ${err.code}`); 52 } 53} 54``` 55 56## commitConfig<sup>(deprecated)</sup> 57 58commitConfig(callback: AsyncCallback\<void\>): void 59 60Commits the configuration for this session. This API uses an asynchronous callback to return the result. 61 62> **NOTE** 63> 64> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.commitConfig](arkts-apis-camera-Session.md#commitconfig11) instead. 65 66**System capability**: SystemCapability.Multimedia.Camera.Core 67 68**Parameters** 69 70| Name | Type | Mandatory| Description | 71| -------- | -------------------- | ---- | -------------------- | 72| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 73 74**Error codes** 75 76For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 77 78| ID | Error Message | 79| --------------- | --------------- | 80| 7400102 | Operation not allowed. | 81| 7400201 | Camera service fatal error. | 82 83**Example** 84 85```ts 86import { BusinessError } from '@kit.BasicServicesKit'; 87 88function commitConfig(captureSession: camera.CaptureSession): void { 89 captureSession.commitConfig((err: BusinessError) => { 90 if (err) { 91 console.error(`The commitConfig call failed. error code: ${err.code}`); 92 return; 93 } 94 console.info('Callback invoked to indicate the commit config success.'); 95 }); 96} 97``` 98 99## commitConfig<sup>(deprecated)</sup> 100 101commitConfig(): Promise\<void\> 102 103Commits the configuration for this session. This API uses a promise to return the result. 104 105> **NOTE** 106> 107> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.commitConfig](arkts-apis-camera-Session.md#commitconfig11-1) instead. 108 109**System capability**: SystemCapability.Multimedia.Camera.Core 110 111**Return value** 112 113| Type | Description | 114| -------------- |-------------------| 115| Promise\<void\> | Promise that returns no value.| 116 117**Error codes** 118 119For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 120 121| ID | Error Message | 122| --------------- | --------------- | 123| 7400102 | Operation not allowed. | 124| 7400201 | Camera service fatal error. | 125 126**Example** 127 128```ts 129import { BusinessError } from '@kit.BasicServicesKit'; 130 131function commitConfig(captureSession: camera.CaptureSession): void { 132 captureSession.commitConfig().then(() => { 133 console.info('Promise returned to indicate the commit config success.'); 134 }).catch((error: BusinessError) => { 135 // If the operation fails, error.code is returned and processed. 136 console.error(`The commitConfig call failed. error code: ${error.code}`); 137 }); 138} 139``` 140 141## addInput<sup>(deprecated)</sup> 142 143addInput(cameraInput: CameraInput): void 144 145Adds a [CameraInput](arkts-apis-camera-CameraInput.md) instance to this session. 146 147> **NOTE** 148> 149> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.addInput](arkts-apis-camera-Session.md#addinput11) instead. 150 151**System capability**: SystemCapability.Multimedia.Camera.Core 152 153**Parameters** 154 155| Name | Type | Mandatory| Description | 156| ----------- | --------------------------- | ---- | ------------------------ | 157| cameraInput | [CameraInput](arkts-apis-camera-CameraInput.md) | Yes | CameraInput instance to add.| 158 159**Error codes** 160 161For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 162 163| ID | Error Message | 164|---------|-----------------------------------------------| 165| 7400101 | Parameter missing or parameter type incorrect. | 166| 7400102 | Operation not allowed. | 167 168**Example** 169 170```ts 171import { BusinessError } from '@kit.BasicServicesKit'; 172 173function addInput(captureSession: camera.CaptureSession, cameraInput: camera.CameraInput): void { 174 try { 175 captureSession.addInput(cameraInput); 176 } catch (error) { 177 // If the operation fails, error.code is returned and processed. 178 let err = error as BusinessError; 179 console.error(`The addInput call failed. error code: ${err.code}`); 180 } 181} 182``` 183 184## removeInput<sup>(deprecated)</sup> 185 186removeInput(cameraInput: CameraInput): void 187 188Removes a [CameraInput](arkts-apis-camera-CameraInput.md) instance from this session. 189 190> **NOTE** 191> 192> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.removeInput](arkts-apis-camera-Session.md#removeinput11) instead. 193 194**System capability**: SystemCapability.Multimedia.Camera.Core 195 196**Parameters** 197 198| Name | Type | Mandatory| Description | 199| ----------- | --------------------------- | ---- | ------------------------ | 200| cameraInput | [CameraInput](arkts-apis-camera-CameraInput.md) | Yes | CameraInput instance to remove.| 201 202**Error codes** 203 204For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 205 206| ID | Error Message | 207| --------------- | --------------- | 208| 7400101 | Parameter missing or parameter type incorrect. | 209| 7400102 | Operation not allowed. | 210 211**Example** 212 213```ts 214import { BusinessError } from '@kit.BasicServicesKit'; 215 216function removeInput(captureSession: camera.CaptureSession, cameraInput: camera.CameraInput): void { 217 try { 218 captureSession.removeInput(cameraInput); 219 } catch (error) { 220 // If the operation fails, error.code is returned and processed. 221 let err = error as BusinessError; 222 console.error(`The removeInput call failed. error code: ${err.code}`); 223 } 224} 225``` 226 227## addOutput<sup>(deprecated)</sup> 228 229addOutput(cameraOutput: CameraOutput): void 230 231Adds a [CameraOutput](arkts-apis-camera-CameraOutput.md) instance to this session. 232 233> **NOTE** 234> 235> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.addOutput](arkts-apis-camera-Session.md#addoutput11) instead. 236 237**System capability**: SystemCapability.Multimedia.Camera.Core 238 239**Parameters** 240 241| Name | Type | Mandatory| Description | 242| ------------- | ------------------------------- | ---- | ------------------------ | 243| cameraOutput | [CameraOutput](arkts-apis-camera-CameraOutput.md) | Yes | CameraOutput instance to add.| 244 245**Error codes** 246 247For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 248 249| ID | Error Message | 250| --------------- | --------------- | 251| 7400101 | Parameter missing or parameter type incorrect. | 252| 7400102 | Operation not allowed. | 253 254**Example** 255 256```ts 257import { BusinessError } from '@kit.BasicServicesKit'; 258 259function addOutput(captureSession: camera.CaptureSession, cameraOutput: camera.CameraOutput): void { 260 try { 261 captureSession.addOutput(cameraOutput); 262 } catch (error) { 263 // If the operation fails, error.code is returned and processed. 264 let err = error as BusinessError; 265 console.error(`The addOutput call failed. error code: ${err.code}`); 266 } 267} 268``` 269 270## removeOutput<sup>(deprecated)</sup> 271 272removeOutput(cameraOutput: CameraOutput): void 273 274Removes a [CameraOutput](arkts-apis-camera-CameraOutput.md) instance from this session. 275 276> **NOTE** 277> 278> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.removeOutput](arkts-apis-camera-Session.md#removeoutput11) instead. 279 280**System capability**: SystemCapability.Multimedia.Camera.Core 281 282**Parameters** 283 284| Name | Type | Mandatory| Description | 285| ------------- | ------------------------------- | ---- | ------------------------ | 286| cameraOutput | [CameraOutput](arkts-apis-camera-CameraOutput.md) | Yes | CameraOutput instance to remove.| 287 288**Error codes** 289 290For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 291 292| ID | Error Message | 293| --------------- | --------------- | 294| 7400101 | Parameter missing or parameter type incorrect. | 295| 7400102 | Operation not allowed. | 296 297**Example** 298 299```ts 300import { BusinessError } from '@kit.BasicServicesKit'; 301 302function removeOutput(captureSession: camera.CaptureSession, previewOutput: camera.PreviewOutput): void { 303 try { 304 captureSession.removeOutput(previewOutput); 305 } catch (error) { 306 // If the operation fails, error.code is returned and processed. 307 let err = error as BusinessError; 308 console.error(`The removeOutput call failed. error code: ${err.code}`); 309 } 310} 311``` 312 313## start<sup>(deprecated)</sup> 314 315start(callback: AsyncCallback\<void\>): void 316 317Starts this session. This API uses an asynchronous callback to return the result. 318 319> **NOTE** 320> 321> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.start](arkts-apis-camera-Session.md#start11) instead. 322 323**System capability**: SystemCapability.Multimedia.Camera.Core 324 325**Parameters** 326 327| Name | Type | Mandatory| Description | 328| -------- | -------------------- | ---- | -------------------- | 329| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 330 331**Error codes** 332 333For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 334 335| ID | Error Message | 336| --------------- | --------------- | 337| 7400103 | Session not config. | 338| 7400201 | Camera service fatal error. | 339 340**Example** 341 342```ts 343import { BusinessError } from '@kit.BasicServicesKit'; 344 345function startCaptureSession(captureSession: camera.CaptureSession): void { 346 captureSession.start((err: BusinessError) => { 347 if (err) { 348 console.error(`Failed to start the session, error code: ${err.code}.`); 349 return; 350 } 351 console.info('Callback invoked to indicate the session start success.'); 352 }); 353} 354``` 355 356## start<sup>(deprecated)</sup> 357 358start(): Promise\<void\> 359 360Starts this session. This API uses a promise to return the result. 361 362> **NOTE** 363> 364> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.start](arkts-apis-camera-Session.md#start11-1) instead. 365 366**System capability**: SystemCapability.Multimedia.Camera.Core 367 368**Return value** 369 370| Type | Description | 371| -------------- | ------------------------ | 372| Promise\<void\> | Promise that returns no value.| 373 374**Error codes** 375 376For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 377 378| ID | Error Message | 379| --------------- | --------------- | 380| 7400103 | Session not config. | 381| 7400201 | Camera service fatal error. | 382 383**Example** 384 385```ts 386import { BusinessError } from '@kit.BasicServicesKit'; 387 388function startCaptureSession(captureSession: camera.CaptureSession): void { 389 captureSession.start().then(() => { 390 console.info('Promise returned to indicate the session start success.'); 391 }).catch((err: BusinessError) => { 392 console.error(`Failed to start the session, error code: ${err.code}.`); 393 }); 394} 395``` 396 397## stop<sup>(deprecated)</sup> 398 399stop(callback: AsyncCallback\<void\>): void 400 401Stops this session. This API uses an asynchronous callback to return the result. 402 403> **NOTE** 404> 405> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.stop](arkts-apis-camera-Session.md#stop11) instead. 406 407**System capability**: SystemCapability.Multimedia.Camera.Core 408 409**Parameters** 410 411| Name | Type | Mandatory| Description | 412| -------- | -------------------- | ---- | ------------------- | 413| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 414 415**Error codes** 416 417For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 418 419| ID | Error Message | 420| --------------- | --------------- | 421| 7400201 | Camera service fatal error. | 422 423**Example** 424 425```ts 426import { BusinessError } from '@kit.BasicServicesKit'; 427 428function stopCaptureSession(captureSession: camera.CaptureSession): void { 429 captureSession.stop((err: BusinessError) => { 430 if (err) { 431 console.error(`Failed to stop the session, error code: ${err.code}.`); 432 return; 433 } 434 console.info('Callback invoked to indicate the session stop success.'); 435 }); 436} 437``` 438 439## stop<sup>(deprecated)</sup> 440 441stop(): Promise\<void\> 442 443Stops this session. This API uses a promise to return the result. 444 445> **NOTE** 446> 447> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.stop](arkts-apis-camera-Session.md#stop11-1) instead. 448 449**System capability**: SystemCapability.Multimedia.Camera.Core 450 451**Return value** 452 453| Type | Description | 454| -------------- | ----------------------- | 455| Promise\<void\> | Promise that returns no value.| 456 457**Error codes** 458 459For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 460 461| ID | Error Message | 462| --------------- | --------------- | 463| 7400201 | Camera service fatal error. | 464 465**Example** 466 467```ts 468import { BusinessError } from '@kit.BasicServicesKit'; 469 470function stopCaptureSession(captureSession: camera.CaptureSession): void { 471 captureSession.stop().then(() => { 472 console.info('Promise returned to indicate the session stop success.'); 473 }).catch((err: BusinessError) => { 474 console.error(`Failed to stop the session, error code: ${err.code}.`); 475 }); 476} 477``` 478 479## release<sup>(deprecated)</sup> 480 481release(callback: AsyncCallback\<void\>): void 482 483Releases this session. This API uses an asynchronous callback to return the result. 484 485> **NOTE** 486> 487> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.release](arkts-apis-camera-Session.md#release11) instead. 488 489**System capability**: SystemCapability.Multimedia.Camera.Core 490 491**Parameters** 492 493| Name | Type | Mandatory| Description | 494| -------- | -------------------- | ---- | -------------------- | 495| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 496 497**Error codes** 498 499For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 500 501| ID | Error Message | 502| --------------- | --------------- | 503| 7400201 | Camera service fatal error. | 504 505**Example** 506 507```ts 508import { BusinessError } from '@kit.BasicServicesKit'; 509 510function releaseCaptureSession(captureSession: camera.CaptureSession): void { 511 captureSession.release((err: BusinessError) => { 512 if (err) { 513 console.error(`Failed to release the CaptureSession instance, error code: ${err.code}.`); 514 return; 515 } 516 console.info('Callback invoked to indicate that the CaptureSession instance is released successfully.'); 517 }); 518} 519``` 520 521## release<sup>(deprecated)</sup> 522 523release(): Promise\<void\> 524 525Releases this session. This API uses a promise to return the result. 526 527> **NOTE** 528> 529> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.release](arkts-apis-camera-Session.md#release11-1) instead. 530 531**System capability**: SystemCapability.Multimedia.Camera.Core 532 533**Return value** 534 535| Type | Description | 536| -------------- | ------------------------ | 537| Promise\<void\> | Promise that returns no value.| 538 539**Error codes** 540 541For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 542 543| ID | Error Message | 544| --------------- | --------------- | 545| 7400201 | Camera service fatal error. | 546 547**Example** 548 549```ts 550import { BusinessError } from '@kit.BasicServicesKit'; 551 552function releaseCaptureSession(captureSession: camera.CaptureSession): void { 553 captureSession.release().then(() => { 554 console.info('Promise returned to indicate that the CaptureSession instance is released successfully.'); 555 }).catch((err: BusinessError) => { 556 console.error(`Failed to release the CaptureSession instance, error code: ${err.code}.`); 557 }); 558} 559``` 560 561## hasFlash<sup>(deprecated)</sup> 562 563hasFlash(): boolean 564 565Checks whether the camera device has flash. 566 567> **NOTE** 568> 569> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Flash.hasFlash](arkts-apis-camera-FlashQuery.md#hasflash11) instead. 570 571**System capability**: SystemCapability.Multimedia.Camera.Core 572 573**Return value** 574 575| Type | Description | 576| ---------- | ----------------------------- | 577| boolean | Check result for whether the camera device has flash. **true** if it has flash, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 578 579**Error codes** 580 581For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 582 583| ID | Error Message | 584| --------------- | --------------- | 585| 7400103 | Session not config. | 586 587**Example** 588 589```ts 590import { BusinessError } from '@kit.BasicServicesKit'; 591 592function hasFlash(captureSession: camera.CaptureSession): boolean { 593 let status: boolean = false; 594 try { 595 status = captureSession.hasFlash(); 596 } catch (error) { 597 // If the operation fails, error.code is returned and processed. 598 let err = error as BusinessError; 599 console.error(`The hasFlash call failed. error code: ${err.code}`); 600 } 601 return status; 602} 603``` 604 605## isFlashModeSupported<sup>(deprecated)</sup> 606 607isFlashModeSupported(flashMode: FlashMode): boolean 608 609Checks whether a flash mode is supported. 610 611> **NOTE** 612> 613> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Flash.isFlashModeSupported](arkts-apis-camera-FlashQuery.md#isflashmodesupported11) instead. 614 615**System capability**: SystemCapability.Multimedia.Camera.Core 616 617**Parameters** 618 619| Name | Type | Mandatory| Description | 620| --------- | ----------------------- | ---- | --------------------------------- | 621| flashMode | [FlashMode](arkts-apis-camera-e.md#flashmode) | Yes | Flash mode. | 622 623**Return value** 624 625| Type | Description | 626| ---------- | ----------------------------- | 627| boolean | Check result for the support of the flash mode. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 628 629**Error codes** 630 631For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 632 633| ID | Error Message | 634| --------------- | --------------- | 635| 7400103 | Session not config. | 636 637**Example** 638 639```ts 640import { BusinessError } from '@kit.BasicServicesKit'; 641 642function isFlashModeSupported(captureSession: camera.CaptureSession): boolean { 643 let status: boolean = false; 644 try { 645 status = captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO); 646 } catch (error) { 647 // If the operation fails, error.code is returned and processed. 648 let err = error as BusinessError; 649 console.error(`The isFlashModeSupported call failed. error code: ${err.code}`); 650 } 651 return status; 652} 653``` 654 655## setFlashMode<sup>(deprecated)</sup> 656 657setFlashMode(flashMode: FlashMode): void 658 659Sets a flash mode. 660 661Before the setting, do the following checks: 662 6631. Use [hasFlash](#hasflashdeprecated) to check whether the camera device has flash. 6642. Use [isFlashModeSupported](#isflashmodesupporteddeprecated) to check whether the camera device supports the flash mode. 665 666> **NOTE** 667> 668> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Flash.setFlashMode](arkts-apis-camera-Flash.md#setflashmode11) instead. 669 670**System capability**: SystemCapability.Multimedia.Camera.Core 671 672**Parameters** 673 674| Name | Type | Mandatory| Description | 675| --------- | ----------------------- | ---- | -------------------- | 676| flashMode | [FlashMode](arkts-apis-camera-e.md#flashmode) | Yes | Flash mode. | 677 678**Error codes** 679 680For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 681 682| ID | Error Message | 683| --------------- | --------------- | 684| 7400103 | Session not config. | 685 686**Example** 687 688```ts 689import { BusinessError } from '@kit.BasicServicesKit'; 690 691function setFlashMode(captureSession: camera.CaptureSession): void { 692 try { 693 captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO); 694 } catch (error) { 695 // If the operation fails, error.code is returned and processed. 696 let err = error as BusinessError; 697 console.error(`The setFlashMode call failed. error code: ${err.code}`); 698 } 699} 700``` 701 702## getFlashMode<sup>(deprecated)</sup> 703 704getFlashMode(): FlashMode 705 706Obtains the flash mode in use. 707 708> **NOTE** 709> 710> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Flash.getFlashMode](arkts-apis-camera-Flash.md#getflashmode11) instead. 711 712**System capability**: SystemCapability.Multimedia.Camera.Core 713 714**Return value** 715 716| Type | Description | 717| ---------- | ----------------------------- | 718| [FlashMode](arkts-apis-camera-e.md#flashmode) | Flash mode obtained. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 719 720**Error codes** 721 722For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 723 724| ID | Error Message | 725| --------------- | --------------- | 726| 7400103 | Session not config. | 727 728**Example** 729 730```ts 731import { BusinessError } from '@kit.BasicServicesKit'; 732 733function getFlashMode(captureSession: camera.CaptureSession): camera.FlashMode | undefined { 734 let flashMode: camera.FlashMode | undefined = undefined; 735 try { 736 flashMode = captureSession.getFlashMode(); 737 } catch (error) { 738 // If the operation fails, error.code is returned and processed. 739 let err = error as BusinessError; 740 console.error(`The getFlashMode call failed.error code: ${err.code}`); 741 } 742 return flashMode; 743} 744``` 745 746## isExposureModeSupported<sup>(deprecated)</sup> 747 748isExposureModeSupported(aeMode: ExposureMode): boolean 749 750Checks whether an exposure mode is supported. 751 752> **NOTE** 753> 754> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.isExposureModeSupported](arkts-apis-camera-AutoExposureQuery.md#isexposuremodesupported11) instead. 755 756**System capability**: SystemCapability.Multimedia.Camera.Core 757 758**Parameters** 759 760| Name | Type | Mandatory | Description | 761| -------- | -------------------------------| ---- | ----------------------------- | 762| aeMode | [ExposureMode](arkts-apis-camera-e.md#exposuremode) | Yes | Exposure mode. | 763 764**Return value** 765 766| Type | Description | 767| ---------- | ----------------------------- | 768| boolean | Check result for the support of the exposure mode. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 769 770**Error codes** 771 772For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 773 774| ID | Error Message | 775| --------------- | --------------- | 776| 7400103 | Session not config. | 777 778**Example** 779 780```ts 781import { BusinessError } from '@kit.BasicServicesKit'; 782 783function isExposureModeSupported(captureSession: camera.CaptureSession): boolean { 784 let isSupported: boolean = false; 785 try { 786 isSupported = captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED); 787 } catch (error) { 788 // If the operation fails, error.code is returned and processed. 789 let err = error as BusinessError; 790 console.error(`The isExposureModeSupported call failed. error code: ${err.code}`); 791 } 792 return isSupported; 793} 794``` 795 796## getExposureMode<sup>(deprecated)</sup> 797 798getExposureMode(): ExposureMode 799 800Obtains the exposure mode in use. 801 802> **NOTE** 803> 804> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.getExposureMode](arkts-apis-camera-AutoExposure.md#getexposuremode11) instead. 805 806**System capability**: SystemCapability.Multimedia.Camera.Core 807 808**Return value** 809 810| Type | Description | 811| ---------- | ----------------------------- | 812| [ExposureMode](arkts-apis-camera-e.md#exposuremode) | Exposure mode obtained. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 813 814**Error codes** 815 816For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 817 818| ID | Error Message | 819| --------------- | --------------- | 820| 7400103 | Session not config. | 821 822**Example** 823 824```ts 825import { BusinessError } from '@kit.BasicServicesKit'; 826 827function getExposureMode(captureSession: camera.CaptureSession): camera.ExposureMode | undefined { 828 let exposureMode: camera.ExposureMode | undefined = undefined; 829 try { 830 exposureMode = captureSession.getExposureMode(); 831 } catch (error) { 832 // If the operation fails, error.code is returned and processed. 833 let err = error as BusinessError; 834 console.error(`The getExposureMode call failed. error code: ${err.code}`); 835 } 836 return exposureMode; 837} 838``` 839 840## setExposureMode<sup>(deprecated)</sup> 841 842setExposureMode(aeMode: ExposureMode): void 843 844Sets an exposure mode. Before the setting, call [isExposureModeSupported](#isexposuremodesupporteddeprecated) to check whether the target exposure mode is supported. 845 846> **NOTE** 847> 848> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.setExposureMode](arkts-apis-camera-AutoExposure.md#setexposuremode11) instead. 849 850**System capability**: SystemCapability.Multimedia.Camera.Core 851 852**Parameters** 853 854| Name | Type | Mandatory| Description | 855| -------- | -------------------------------| ---- | ----------------------- | 856| aeMode | [ExposureMode](arkts-apis-camera-e.md#exposuremode) | Yes | Exposure mode. | 857 858**Error codes** 859 860For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 861 862| ID | Error Message | 863| --------------- | --------------- | 864| 7400103 | Session not config. | 865 866**Example** 867 868```ts 869import { BusinessError } from '@kit.BasicServicesKit'; 870 871function setExposureMode(captureSession: camera.CaptureSession): void { 872 try { 873 captureSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED); 874 } catch (error) { 875 // If the operation fails, error.code is returned and processed. 876 let err = error as BusinessError; 877 console.error(`The setExposureMode call failed. error code: ${err.code}`); 878 } 879} 880``` 881 882## getMeteringPoint<sup>(deprecated)</sup> 883 884getMeteringPoint(): Point 885 886Obtains the metering point of the camera device. 887 888> **NOTE** 889> 890> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.getMeteringPoint](arkts-apis-camera-AutoExposure.md#getmeteringpoint11) instead. 891 892**System capability**: SystemCapability.Multimedia.Camera.Core 893 894**Return value** 895 896| Type | Description | 897| ---------- | ----------------------------- | 898| [Point](arkts-apis-camera-i.md#point) | Metering point obtained. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 899 900**Error codes** 901 902For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 903 904| ID | Error Message | 905| --------------- | --------------- | 906| 7400103 | Session not config. | 907 908**Example** 909 910```ts 911import { BusinessError } from '@kit.BasicServicesKit'; 912 913function getMeteringPoint(captureSession: camera.CaptureSession): camera.Point | undefined { 914 let exposurePoint: camera.Point | undefined = undefined; 915 try { 916 exposurePoint = captureSession.getMeteringPoint(); 917 } catch (error) { 918 // If the operation fails, error.code is returned and processed. 919 let err = error as BusinessError; 920 console.error(`The getMeteringPoint call failed. error code: ${err.code}`); 921 } 922 return exposurePoint; 923} 924``` 925 926## setMeteringPoint<sup>(deprecated)</sup> 927 928setMeteringPoint(point: Point): void 929 930Sets the metering point, which is the center point of the metering rectangle. 931 932The metering point must be in the coordinate system (0-1), where the upper left corner is {0, 0} and the lower right corner is {1, 1}. 933 934The coordinate system is based on the horizontal device direction with the device's charging port on the right. If the layout of the preview screen of an application is based on the vertical direction with the charging port on the lower side, the layout width and height are {w, h}, and the touch point is {x, y}, then the coordinate point after conversion is {y/h, 1-x/w}. 935 936> **NOTE** 937> 938> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.setMeteringPoint](arkts-apis-camera-AutoExposure.md#setmeteringpoint11) instead. 939 940**System capability**: SystemCapability.Multimedia.Camera.Core 941 942**Parameters** 943 944| Name | Type | Mandatory| Description | 945| ------------- | -------------------------------| ---- | ------------------- | 946| point | [Point](arkts-apis-camera-i.md#point) | Yes | Metering point. The value range of x and y must be within [0,1]. If a value less than 0 is passed, the value **0** is used. If a value greater than **1** is passed, the value **1** is used. | 947 948**Error codes** 949 950For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 951 952| ID | Error Message | 953| --------------- | --------------- | 954| 7400103 | Session not config. | 955 956**Example** 957 958```ts 959import { BusinessError } from '@kit.BasicServicesKit'; 960 961function setMeteringPoint(captureSession: camera.CaptureSession): void { 962 const point: camera.Point = {x: 1, y: 1}; 963 try { 964 captureSession.setMeteringPoint(point); 965 } catch (error) { 966 // If the operation fails, error.code is returned and processed. 967 let err = error as BusinessError; 968 console.error(`The setMeteringPoint call failed. error code: ${err.code}`); 969 } 970} 971``` 972 973## getExposureBiasRange<sup>(deprecated)</sup> 974 975getExposureBiasRange(): Array\<number\> 976 977Obtains the exposure compensation values of the camera device. 978 979> **NOTE** 980> 981> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.getExposureBiasRange](arkts-apis-camera-AutoExposureQuery.md#getexposurebiasrange11) instead. 982 983**System capability**: SystemCapability.Multimedia.Camera.Core 984 985**Return value** 986 987| Type | Description | 988| ---------- | ----------------------------- | 989| Array\<number\> | Array of compensation values. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 990 991**Error codes** 992 993For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 994 995| ID | Error Message | 996| --------------- | --------------- | 997| 7400103 | Session not config. | 998 999**Example** 1000 1001```ts 1002import { BusinessError } from '@kit.BasicServicesKit'; 1003 1004function getExposureBiasRange(captureSession: camera.CaptureSession): Array<number> { 1005 let biasRangeArray: Array<number> = []; 1006 try { 1007 biasRangeArray = captureSession.getExposureBiasRange(); 1008 } catch (error) { 1009 // If the operation fails, error.code is returned and processed. 1010 let err = error as BusinessError; 1011 console.error(`The getExposureBiasRange call failed. error code: ${err.code}`); 1012 } 1013 return biasRangeArray; 1014} 1015``` 1016 1017## setExposureBias<sup>(deprecated)</sup> 1018 1019setExposureBias(exposureBias: number): void 1020 1021Sets an exposure compensation value (EV). 1022 1023Before the setting, you are advised to use [getExposureBiasRange](#getexposurebiasrangedeprecated) to obtain the supported values. 1024 1025> **NOTE** 1026> 1027> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.setExposureBias](arkts-apis-camera-AutoExposure.md#setexposurebias11) instead. 1028 1029**System capability**: SystemCapability.Multimedia.Camera.Core 1030 1031**Parameters** 1032 1033| Name | Type | Mandatory | Description | 1034| -------- | -----------|-----|-----------------| 1035| exposureBias | number | Yes | EV. The supported EV range can be obtained by calling [getExposureBiasRange](arkts-apis-camera-AutoExposureQuery.md#getexposurebiasrange11). If the value passed is not within the supported range, the nearest critical point is used. There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned. If the input parameter is null or undefined, the EV is set to 0.| 1036 1037**Error codes** 1038 1039For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1040 1041| ID | Error Message | 1042| --------------- | --------------- | 1043| 7400103 | Session not config. | 1044 1045**Example** 1046 1047```ts 1048import { BusinessError } from '@kit.BasicServicesKit'; 1049 1050function setExposureBias(captureSession: camera.CaptureSession, biasRangeArray: Array<number>): void { 1051 if (biasRangeArray && biasRangeArray.length > 0) { 1052 let exposureBias = biasRangeArray[0]; 1053 try { 1054 captureSession.setExposureBias(exposureBias); 1055 } catch (error) { 1056 // If the operation fails, error.code is returned and processed. 1057 let err = error as BusinessError; 1058 console.error(`The setExposureBias call failed. error code: ${err.code}`); 1059 } 1060 } 1061} 1062``` 1063 1064## getExposureValue<sup>(deprecated)</sup> 1065 1066getExposureValue(): number 1067 1068Obtains the exposure value in use. 1069 1070> **NOTE** 1071> 1072> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.getExposureValue](arkts-apis-camera-AutoExposure.md#getexposurevalue11) instead. 1073 1074**System capability**: SystemCapability.Multimedia.Camera.Core 1075 1076**Return value** 1077 1078| Type | Description | 1079| ---------- | ----------------------------- | 1080| number | Exposure value obtained. There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 1081 1082**Error codes** 1083 1084For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1085 1086| ID | Error Message | 1087| --------------- | --------------- | 1088| 7400103 | Session not config. | 1089 1090**Example** 1091 1092```ts 1093import { BusinessError } from '@kit.BasicServicesKit'; 1094 1095function getExposureValue(captureSession: camera.CaptureSession): number { 1096 const invalidValue: number = -1; 1097 let exposureValue: number = invalidValue; 1098 try { 1099 exposureValue = captureSession.getExposureValue(); 1100 } catch (error) { 1101 // If the operation fails, error.code is returned and processed. 1102 let err = error as BusinessError; 1103 console.error(`The getExposureValue call failed. error code: ${err.code}`); 1104 } 1105 return exposureValue; 1106} 1107``` 1108 1109## isFocusModeSupported<sup>(deprecated)</sup> 1110 1111isFocusModeSupported(afMode: FocusMode): boolean 1112 1113Checks whether a focus mode is supported. 1114 1115> **NOTE** 1116> 1117> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.isFocusModeSupported](arkts-apis-camera-FocusQuery.md#isfocusmodesupported11) instead. 1118 1119**System capability**: SystemCapability.Multimedia.Camera.Core 1120 1121**Parameters** 1122 1123| Name | Type | Mandatory| Description | 1124| -------- | ----------------------- | ---- | -------------------------------- | 1125| afMode | [FocusMode](arkts-apis-camera-e.md#focusmode) | Yes | Focus mode. | 1126 1127**Return value** 1128 1129| Type | Description | 1130| ---------- | ----------------------------- | 1131| boolean | Check result for the support of the focus mode. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 1132 1133**Error codes** 1134 1135For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1136 1137| ID | Error Message | 1138| --------------- | --------------- | 1139| 7400103 | Session not config. | 1140 1141**Example** 1142 1143```ts 1144import { BusinessError } from '@kit.BasicServicesKit'; 1145 1146function isFocusModeSupported(captureSession: camera.CaptureSession): boolean { 1147 let status: boolean = false; 1148 try { 1149 status = captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO); 1150 } catch (error) { 1151 // If the operation fails, error.code is returned and processed. 1152 let err = error as BusinessError; 1153 console.error(`The isFocusModeSupported call failed. error code: ${err.code}`); 1154 } 1155 return status; 1156} 1157``` 1158 1159## setFocusMode<sup>(deprecated)</sup> 1160 1161setFocusMode(afMode: FocusMode): void 1162 1163Sets a focus mode. 1164 1165Before the setting, call [isFocusModeSupported](#isfocusmodesupporteddeprecated) to check whether the focus mode is supported. 1166 1167> **NOTE** 1168> 1169> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.setFocusMode](arkts-apis-camera-Focus.md#setfocusmode11) instead. 1170 1171**System capability**: SystemCapability.Multimedia.Camera.Core 1172 1173**Parameters** 1174 1175| Name | Type | Mandatory| Description | 1176| -------- | ----------------------- | ---- | ------------------- | 1177| afMode | [FocusMode](arkts-apis-camera-e.md#focusmode) | Yes | Focus mode. | 1178 1179**Error codes** 1180 1181For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1182 1183| ID | Error Message | 1184| --------------- | --------------- | 1185| 7400103 | Session not config. | 1186 1187**Example** 1188 1189```ts 1190import { BusinessError } from '@kit.BasicServicesKit'; 1191 1192function setFocusMode(captureSession: camera.CaptureSession): void { 1193 try { 1194 captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO); 1195 } catch (error) { 1196 // If the operation fails, error.code is returned and processed. 1197 let err = error as BusinessError; 1198 console.error(`The setFocusMode call failed. error code: ${err.code}`); 1199 } 1200} 1201``` 1202 1203## getFocusMode<sup>(deprecated)</sup> 1204 1205getFocusMode(): FocusMode 1206 1207Obtains the focus mode in use. 1208 1209> **NOTE** 1210> 1211> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.getFocusMode](arkts-apis-camera-Focus.md#getfocusmode11) instead. 1212 1213**System capability**: SystemCapability.Multimedia.Camera.Core 1214 1215**Return value** 1216 1217| Type | Description | 1218| ---------- | ----------------------------- | 1219| [FocusMode](arkts-apis-camera-e.md#focusmode) | Focus mode obtained. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 1220 1221**Error codes** 1222 1223For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1224 1225| ID | Error Message | 1226| --------------- | --------------- | 1227| 7400103 | Session not config. | 1228 1229**Example** 1230 1231```ts 1232import { BusinessError } from '@kit.BasicServicesKit'; 1233 1234function getFocusMode(captureSession: camera.CaptureSession): camera.FocusMode | undefined { 1235 let afMode: camera.FocusMode | undefined = undefined; 1236 try { 1237 afMode = captureSession.getFocusMode(); 1238 } catch (error) { 1239 // If the operation fails, error.code is returned and processed. 1240 let err = error as BusinessError; 1241 console.error(`The getFocusMode call failed. error code: ${err.code}`); 1242 } 1243 return afMode; 1244} 1245``` 1246 1247## setFocusPoint<sup>(deprecated)</sup> 1248 1249setFocusPoint(point: Point): void 1250 1251Sets the focal point. The focal point must be in the coordinate system (0-1), where the upper left corner is {0, 0} and the lower right corner is {1, 1}. 1252 1253The coordinate system is based on the horizontal device direction with the device's charging port on the right. If the layout of the preview screen of an application is based on the vertical direction with the charging port on the lower side, the layout width and height are {w, h}, and the touch point is {x, y}, then the coordinate point after conversion is {y/h, 1-x/w}. 1254 1255> **NOTE** 1256> 1257> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.setFocusPoint](arkts-apis-camera-Focus.md#setfocuspoint11) instead. 1258 1259**System capability**: SystemCapability.Multimedia.Camera.Core 1260 1261**Parameters** 1262 1263| Name | Type | Mandatory | Description | 1264|-------| ----------------------- |-----| ------------------- | 1265| point | [Point](arkts-apis-camera-i.md#point) | Yes | Focal point. The value range of x and y must be within [0,1]. If a value less than 0 is passed, the value **0** is used. If a value greater than **1** is passed, the value **1** is used. | 1266 1267**Error codes** 1268 1269For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1270 1271| ID | Error Message | 1272| --------------- | --------------- | 1273| 7400103 | Session not config. | 1274 1275**Example** 1276 1277```ts 1278import { BusinessError } from '@kit.BasicServicesKit'; 1279 1280function setFocusPoint(captureSession: camera.CaptureSession): void { 1281 const focusPoint: camera.Point = {x: 1, y: 1}; 1282 try { 1283 captureSession.setFocusPoint(focusPoint); 1284 } catch (error) { 1285 // If the operation fails, error.code is returned and processed. 1286 let err = error as BusinessError; 1287 console.error(`The setFocusPoint call failed. error code: ${err.code}`); 1288 } 1289} 1290``` 1291 1292## getFocusPoint<sup>(deprecated)</sup> 1293 1294getFocusPoint(): Point 1295 1296Obtains the focal point of the camera device. 1297 1298> **NOTE** 1299> 1300> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.getFocusPoint](arkts-apis-camera-Focus.md#getfocuspoint11) instead. 1301 1302**System capability**: SystemCapability.Multimedia.Camera.Core 1303 1304**Return value** 1305 1306| Type | Description | 1307| ---------- | ----------------------------- | 1308| [Point](arkts-apis-camera-i.md#point) | Focal point obtained. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 1309 1310**Error codes** 1311 1312For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1313 1314| ID | Error Message | 1315| --------------- | --------------- | 1316| 7400103 | Session not config. | 1317 1318**Example** 1319 1320```ts 1321import { BusinessError } from '@kit.BasicServicesKit'; 1322 1323function getFocusPoint(captureSession: camera.CaptureSession): camera.Point | undefined { 1324 let point: camera.Point | undefined = undefined; 1325 try { 1326 point = captureSession.getFocusPoint(); 1327 } catch (error) { 1328 // If the operation fails, error.code is returned and processed. 1329 let err = error as BusinessError; 1330 console.error(`The getFocusPoint call failed. error code: ${err.code}`); 1331 } 1332 return point; 1333} 1334``` 1335 1336## getFocalLength<sup>(deprecated)</sup> 1337 1338getFocalLength(): number 1339 1340Obtains the focal length of the camera device. 1341 1342> **NOTE** 1343> 1344> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.getFocalLength](arkts-apis-camera-Focus.md#getfocallength11) instead. 1345 1346**System capability**: SystemCapability.Multimedia.Camera.Core 1347 1348**Return value** 1349 1350| Type | Description | 1351| ---------- | ----------------------------- | 1352| number | Focal length obtained. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 1353 1354**Error codes** 1355 1356For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1357 1358| ID | Error Message | 1359| --------------- | --------------- | 1360| 7400103 | Session not config. | 1361 1362**Example** 1363 1364```ts 1365import { BusinessError } from '@kit.BasicServicesKit'; 1366 1367function getFocalLength(captureSession: camera.CaptureSession): number { 1368 const invalidValue: number = -1; 1369 let focalLength: number = invalidValue; 1370 try { 1371 focalLength = captureSession.getFocalLength(); 1372 } catch (error) { 1373 // If the operation fails, error.code is returned and processed. 1374 let err = error as BusinessError; 1375 console.error(`The getFocalLength call failed. error code: ${err.code}`); 1376 } 1377 return focalLength; 1378} 1379``` 1380 1381## getZoomRatioRange<sup>(deprecated)</sup> 1382 1383getZoomRatioRange(): Array\<number\> 1384 1385Obtains the supported zoom ratio range. 1386 1387> **NOTE** 1388> 1389> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Zoom.getZoomRatioRange](arkts-apis-camera-ZoomQuery.md#getzoomratiorange11) instead. 1390 1391**System capability**: SystemCapability.Multimedia.Camera.Core 1392 1393**Return value** 1394 1395| Type | Description | 1396| ---------- | ----------------------------- | 1397| Array\<number\> | Array containing the minimum and maximum zoom ratios. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 1398 1399**Error codes** 1400 1401For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1402 1403| ID | Error Message | 1404| --------------- | --------------- | 1405| 7400103 | Session not config. | 1406 1407**Example** 1408 1409```ts 1410import { BusinessError } from '@kit.BasicServicesKit'; 1411 1412function getZoomRatioRange(captureSession: camera.CaptureSession): Array<number> { 1413 let zoomRatioRange: Array<number> = []; 1414 try { 1415 zoomRatioRange = captureSession.getZoomRatioRange(); 1416 } catch (error) { 1417 // If the operation fails, error.code is returned and processed. 1418 let err = error as BusinessError; 1419 console.error(`The getZoomRatioRange call failed. error code: ${err.code}`); 1420 } 1421 return zoomRatioRange; 1422} 1423``` 1424 1425## setZoomRatio<sup>(deprecated)</sup> 1426 1427setZoomRatio(zoomRatio: number): void 1428 1429Sets a zoom ratio, with a maximum precision of two decimal places. 1430 1431> **NOTE** 1432> 1433> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Zoom.setZoomRatio](arkts-apis-camera-Zoom.md#setzoomratio11) instead. 1434 1435**System capability**: SystemCapability.Multimedia.Camera.Core 1436 1437**Parameters** 1438 1439| Name | Type | Mandatory | Description | 1440| --------- | -------------------- |-----| ------------------- | 1441| zoomRatio | number | Yes | Zoom ratio. The supported zoom ratio range can be obtained by calling [getZoomRatioRange](arkts-apis-camera-ZoomQuery.md#getzoomratiorange11). If the value passed in is not within the supported range, the value within the precision range is retained. If the input parameter is null or undefined, it is treated as 0 and the minimum zoom ratio is used.| 1442 1443**Error codes** 1444 1445For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1446 1447| ID | Error Message | 1448| --------------- | --------------- | 1449| 7400103 | Session not config. | 1450 1451**Example** 1452 1453```ts 1454import { BusinessError } from '@kit.BasicServicesKit'; 1455 1456function setZoomRatio(captureSession: camera.CaptureSession, zoomRatioRange: Array<number>): void { 1457 if (zoomRatioRange === undefined || zoomRatioRange.length <= 0) { 1458 return; 1459 } 1460 let zoomRatio = zoomRatioRange[0]; 1461 try { 1462 captureSession.setZoomRatio(zoomRatio); 1463 } catch (error) { 1464 // If the operation fails, error.code is returned and processed. 1465 let err = error as BusinessError; 1466 console.error(`The setZoomRatio call failed. error code: ${err.code}`); 1467 } 1468} 1469``` 1470 1471## getZoomRatio<sup>(deprecated)</sup> 1472 1473getZoomRatio(): number 1474 1475Obtains the zoom ratio in use. 1476 1477> **NOTE** 1478> 1479> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Zoom.getZoomRatio](arkts-apis-camera-Zoom.md#getzoomratio11) instead. 1480 1481**System capability**: SystemCapability.Multimedia.Camera.Core 1482 1483**Return value** 1484 1485| Type | Description | 1486| ---------- | ----------------------------- | 1487| number | Zoom ratio obtained. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 1488 1489**Error codes** 1490 1491For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1492 1493| ID | Error Message | 1494| --------------- | --------------- | 1495| 7400103 | Session not config. | 1496 1497**Example** 1498 1499```ts 1500import { BusinessError } from '@kit.BasicServicesKit'; 1501 1502function getZoomRatio(captureSession: camera.CaptureSession): number { 1503 const invalidValue: number = -1; 1504 let zoomRatio: number = invalidValue; 1505 try { 1506 zoomRatio = captureSession.getZoomRatio(); 1507 } catch (error) { 1508 // If the operation fails, error.code is returned and processed. 1509 let err = error as BusinessError; 1510 console.error(`The getZoomRatio call failed. error code: ${err.code}`); 1511 } 1512 return zoomRatio; 1513} 1514``` 1515 1516## isVideoStabilizationModeSupported<sup>(deprecated)</sup> 1517 1518isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean 1519 1520Checks whether a video stabilization mode is supported. 1521 1522> **NOTE** 1523> 1524> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Stabilization.isVideoStabilizationModeSupported](arkts-apis-camera-StabilizationQuery.md#isvideostabilizationmodesupported11) instead. 1525 1526**System capability**: SystemCapability.Multimedia.Camera.Core 1527 1528**Parameters** 1529 1530| Name | Type | Mandatory| Description | 1531| -------- | ------------------------------------------------- | ---- | ------------------------------ | 1532| vsMode | [VideoStabilizationMode](arkts-apis-camera-e.md#videostabilizationmode) | Yes | Video stabilization mode. If the input parameter is null or undefined, it is treated as 0 and video stabilization is disabled. | 1533 1534**Return value** 1535 1536| Type | Description | 1537| ---------- | ----------------------------- | 1538| boolean | Check result for the support of the video stabilization mode. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 1539 1540**Error codes** 1541 1542For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1543 1544| ID | Error Message | 1545| --------------- | --------------- | 1546| 7400103 | Session not config. | 1547 1548**Example** 1549 1550```ts 1551import { BusinessError } from '@kit.BasicServicesKit'; 1552 1553function isVideoStabilizationModeSupported(captureSession: camera.CaptureSession): boolean { 1554 let isSupported: boolean = false; 1555 try { 1556 isSupported = captureSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF); 1557 } catch (error) { 1558 // If the operation fails, error.code is returned and processed. 1559 let err = error as BusinessError; 1560 console.error(`The isVideoStabilizationModeSupported call failed. error code: ${err.code}`); 1561 } 1562 return isSupported; 1563} 1564``` 1565 1566## getActiveVideoStabilizationMode<sup>(deprecated)</sup> 1567 1568getActiveVideoStabilizationMode(): VideoStabilizationMode 1569 1570Obtains the video stabilization mode in use. 1571 1572> **NOTE** 1573> 1574> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Stabilization.getActiveVideoStabilizationMode](arkts-apis-camera-Stabilization.md#getactivevideostabilizationmode11) instead. 1575 1576**System capability**: SystemCapability.Multimedia.Camera.Core 1577 1578**Return value** 1579 1580| Type | Description | 1581| ---------- | ----------------------------- | 1582| [VideoStabilizationMode](arkts-apis-camera-e.md#videostabilizationmode) | Video stabilization mode obtained. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 1583 1584**Error codes** 1585 1586For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1587 1588| ID | Error Message | 1589| --------------- | --------------- | 1590| 7400103 | Session not config. | 1591 1592**Example** 1593 1594```ts 1595import { BusinessError } from '@kit.BasicServicesKit'; 1596 1597function getActiveVideoStabilizationMode(captureSession: camera.CaptureSession): camera.VideoStabilizationMode | undefined { 1598 let vsMode: camera.VideoStabilizationMode | undefined = undefined; 1599 try { 1600 vsMode = captureSession.getActiveVideoStabilizationMode(); 1601 } catch (error) { 1602 // If the operation fails, error.code is returned and processed. 1603 let err = error as BusinessError; 1604 console.error(`The getActiveVideoStabilizationMode call failed. error code: ${err.code}`); 1605 } 1606 return vsMode; 1607} 1608``` 1609 1610## setVideoStabilizationMode<sup>(deprecated)</sup> 1611 1612setVideoStabilizationMode(mode: VideoStabilizationMode): void 1613 1614Sets a video stabilization mode. Before the setting, call [isVideoStabilizationModeSupported](#isvideostabilizationmodesupporteddeprecated) to check whether the target video stabilization mode is supported. 1615 1616> **NOTE** 1617> 1618> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Stabilization.setVideoStabilizationMode](arkts-apis-camera-Stabilization.md#setvideostabilizationmode11) instead. 1619 1620**System capability**: SystemCapability.Multimedia.Camera.Core 1621 1622**Parameters** 1623 1624| Name | Type | Mandatory| Description | 1625| -------- | ------------------------------------------------- | ---- | --------------------- | 1626| mode | [VideoStabilizationMode](arkts-apis-camera-e.md#videostabilizationmode) | Yes | Video stabilization mode. If the input parameter is null or undefined, it is treated as 0 and video stabilization is disabled. | 1627 1628**Error codes** 1629 1630For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 1631 1632| ID | Error Message | 1633| --------------- | --------------- | 1634| 7400103 | Session not config. | 1635 1636**Example** 1637 1638```ts 1639import { BusinessError } from '@kit.BasicServicesKit'; 1640 1641function setVideoStabilizationMode(captureSession: camera.CaptureSession): void { 1642 try { 1643 captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF); 1644 } catch (error) { 1645 // If the operation fails, error.code is returned and processed. 1646 let err = error as BusinessError; 1647 console.error(`The setVideoStabilizationMode call failed. error code: ${err.code}`); 1648 } 1649} 1650``` 1651 1652## on('focusStateChange')<sup>(deprecated)</sup> 1653 1654on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 1655 1656Subscribes to focus state change events. This API uses an asynchronous callback to return the result. 1657 1658> **NOTE** 1659> 1660> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [VideoSession.on('focusStateChange')](arkts-apis-camera-VideoSession.md#onfocusstatechange11) instead. 1661> 1662> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**. 1663 1664**System capability**: SystemCapability.Multimedia.Camera.Core 1665 1666**Parameters** 1667 1668| Name | Type | Mandatory| Description | 1669| -------- | ----------------------------------------- | ---- | ------------------------ | 1670| 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.| 1671| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | Yes | Callback used to return the focus state change. | 1672 1673**Example** 1674 1675```ts 1676import { BusinessError } from '@kit.BasicServicesKit'; 1677 1678function registerFocusStateChange(captureSession: camera.CaptureSession): void { 1679 captureSession.on('focusStateChange', (err: BusinessError, focusState: camera.FocusState) => { 1680 if (err !== undefined && err.code !== 0) { 1681 console.error(`Callback Error, errorCode: ${err.code}`); 1682 return; 1683 } 1684 console.info(`Focus state: ${focusState}`); 1685 }); 1686} 1687``` 1688 1689## off('focusStateChange')<sup>(deprecated)</sup> 1690 1691off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 1692 1693Unsubscribes from focus state change events. 1694 1695> **NOTE** 1696> 1697> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [VideoSession.off('focusStateChange')](arkts-apis-camera-VideoSession.md#offfocusstatechange11) instead. 1698 1699**System capability**: SystemCapability.Multimedia.Camera.Core 1700 1701**Parameters** 1702 1703| Name | Type | Mandatory| Description | 1704| -------- | ----------------------------------------- | ---- | ------------------------ | 1705| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.| 1706| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | No | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.| 1707 1708**Example** 1709 1710```ts 1711function unregisterFocusStateChange(captureSession: camera.CaptureSession): void { 1712 captureSession.off('focusStateChange'); 1713} 1714``` 1715 1716## on('error')<sup>(deprecated)</sup> 1717 1718on(type: 'error', callback: ErrorCallback): void 1719 1720Subscribes to CaptureSession error events. This API uses an asynchronous callback to return the result. 1721 1722> **NOTE** 1723> 1724> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**. 1725 1726> **NOTE** 1727> 1728> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [VideoSession.on('error')](arkts-apis-camera-VideoSession.md#onerror11) instead. 1729 1730**System capability**: SystemCapability.Multimedia.Camera.Core 1731 1732**Parameters** 1733 1734| Name | Type | Mandatory| Description | 1735| -------- |--------------------------------------------------------------------------| ---- | ------------------------------ | 1736| 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](#beginconfigdeprecated), [commitConfig](#commitconfigdeprecated-1), and [addInput](#addinputdeprecated).| 1737| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes | Callback used to return an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode). | 1738 1739**Example** 1740 1741```ts 1742import { BusinessError } from '@kit.BasicServicesKit'; 1743 1744function registerCaptureSessionError(captureSession: camera.CaptureSession): void { 1745 captureSession.on('error', (error: BusinessError) => { 1746 console.error(`Capture session error code: ${error.code}`); 1747 }); 1748} 1749``` 1750 1751## off('error')<sup>(deprecated)</sup> 1752 1753off(type: 'error', callback?: ErrorCallback): void 1754 1755Unsubscribes from CaptureSession error events. This API uses a callback to return the result. 1756 1757> **NOTE** 1758> 1759> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [VideoSession.off('error')](arkts-apis-camera-VideoSession.md#offerror11) instead. 1760 1761**System capability**: SystemCapability.Multimedia.Camera.Core 1762 1763**Parameters** 1764 1765| Name | Type | Mandatory| Description | 1766| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 1767| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.| 1768| 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.| 1769 1770**Example** 1771 1772```ts 1773function unregisterCaptureSessionError(captureSession: camera.CaptureSession): void { 1774 captureSession.off('error'); 1775} 1776``` 1777