1# @ohos.multimedia.camera (相机管理)(系统接口) 2 3本模块为开发者提供一套简单且易于理解的相机服务接口,开发者通过调用接口可以开发相机应用。应用通过访问和操作相机硬件,实现基础操作,如预览、拍照和录像;还可以通过接口组合完成更多操作,如控制闪光灯和曝光时间、对焦或调焦等。 4 5> **说明:** 6> 7> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 8> - 当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.multimedia.camera (相机管理)](js-apis-camera.md)。 9 10## 导入模块 11 12```ts 13import { camera } from '@kit.CameraKit'; 14``` 15 16## CameraDevice 17 18相机设备信息。 19 20**系统能力:** SystemCapability.Multimedia.Camera.Core 21 22| 名称 | 类型 | 只读 | 必填 | 说明 | 23| -------------- | --------------------------------- | ---- | ---- |---------- | 24| hostDeviceName | string | 是 | 是 | 远端设备名称。**系统接口:** 此接口为系统接口。 | 25| hostDeviceType | [HostDeviceType](#hostdevicetype) | 是 | 是 | 远端相机设备类型。**系统接口:** 此接口为系统接口。 | 26 27## HostDeviceType 28 29枚举,远端相机设备类型。 30 31**系统接口:** 此接口为系统接口。 32 33**系统能力:** SystemCapability.Multimedia.Camera.Core 34 35| 名称 | 值 | 说明 | 36| ---------------------------- | ---- | ------------- | 37| UNKNOWN_TYPE | 0 | 未知设备类型。 | 38| PHONE | 0x0E | 手机相机。 | 39| TABLET | 0x11 | 平板相机。 | 40 41## SceneMode<sup>11+</sup> 42 43枚举,相机支持模式。 44 45**系统能力:** SystemCapability.Multimedia.Camera.Core 46 47| 名称 | 值 | 说明 | 48| ----------------------- | --------- | ------------ | 49| PORTRAIT_PHOTO | 3 | 人像拍照模式。**系统接口:** 此接口为系统接口。 | 50| NIGHT_PHOTO | 4 | 夜景拍照模式。**系统接口:** 此接口为系统接口。 | 51| PROFESSIONAL_PHOTO<sup>12+</sup> | 5 | 专业拍照模式。**系统接口:** 此接口为系统接口。 | 52| PROFESSIONAL_VIDEO<sup>12+</sup> | 6 | 专业录像模式。**系统接口:** 此接口为系统接口。 | 53| SLOW_MOTION_VIDEO<sup>12+</sup> | 7 | 慢动作模式。**系统接口:** 此接口为系统接口。 | 54| HIGH_RESOLUTION_PHOTO<sup>12+</sup> | 11 | 高像素拍照模式。 **系统接口:** 此接口为系统接口。 | 55| PANORAMA_PHOTO<sup>12+</sup> | 15 | 全景拍照模式。 **系统接口:** 此接口为系统接口。 | 56| TIME_LAPSE_PHOTO<sup>12+</sup> | 16 | 延时摄影模式。 **系统接口:** 此接口为系统接口。 | 57 58## SlowMotionStatus<sup>12+</sup> 59 60枚举,慢动作状态。 61 62**系统能力:** SystemCapability.Multimedia.Camera.Core 63 64| 名称 | 值 | 说明 | 65|----------------|-----|---------------| 66| DISABLED | 0 | 慢动作关闭状态。 | 67| READY | 1 | 慢动作就绪状态。 | 68| VIDEO_START | 2 | 慢动作视频开始状态。 | 69| VIDEO_DONE | 3 | 慢动作视频完成状态。 | 70| FINISHED | 4 | 慢动作结束状态。 | 71 72## LcdFlashStatus<sup>12+</sup> 73 74lcd闪光灯信息项。 75 76**系统接口:** 此接口为系统接口。 77 78**系统能力:** SystemCapability.Multimedia.Camera.Core 79 80| 名称 | 类型 | 只读 | 可选 | 说明 | 81| -------- | ----------------------------- |---- |-----| ------------- | 82| isLcdFlashNeeded | boolean | 是 | 否 | 是否需要lcd闪光灯。 | 83| lcdCompensation | number | 是 | 否 | lcd闪光灯补偿值。 | 84 85## Photo<sup>11+</sup> 86 87全质量图对象。 88 89**系统接口:** 此接口为系统接口。 90 91**系统能力:** SystemCapability.Multimedia.Camera.Core 92 93| 名称 | 类型 | 只读 | 可选 | 说明 | 94| ------ | ----------------------------- |-----| ---------- | ---------- | 95| raw<sup>12+</sup> | [image.Image](../apis-image-kit/js-apis-image.md#image9)| NA | 是 | raw图。 | 96 97## ExposureMode 98 99枚举,曝光模式。 100 101**系统接口:** 此接口为系统接口。 102 103**系统能力:** SystemCapability.Multimedia.Camera.Core 104 105| 名称 | 值 | 说明 | 106| ----------------------------- |-----|---------| 107| EXPOSURE_MODE_MANUAL<sup>12+</sup> | 3 | 手动曝光模式。 | 108 109## PolicyType<sup>12+</sup> 110 111枚举,策略类型。 112 113**系统接口:** 此接口为系统接口。 114 115**系统能力:** SystemCapability.Multimedia.Camera.Core 116 117| 名称 | 值 | 说明 | 118| ----------------------------- |-----|---------| 119| PRIVACY<sup>12+</sup> | 1 | 隐私类型。 | 120 121## LightPaintingType<sup>12+</sup> 122 123枚举,流光快门模式类型。 124 125**系统接口:** 此接口为系统接口。 126 127**系统能力:** SystemCapability.Multimedia.Camera.Core 128 129| 名称 | 值 | 说明 | 130| ----------------------------- |-----|---------| 131| TRAFFIC_TRAILS | 0 | 车水马龙。 | 132| STAR_TRAILS | 1 | 绚丽星轨。 | 133| SILKY_WATER | 2 | 丝绢流水。 | 134| LIGHT_GRAFFITI | 3 | 光绘涂鸦。 | 135 136## CameraManager 137 138相机管理器类,使用前需要通过[getCameraManager](js-apis-camera.md#cameragetcameramanager)获取相机管理实例。 139 140### createDepthDataOutput<sup>12+</sup> 141 142createDepthDataOutput(profile: Profile): DepthDataOutput 143 144创建深度输出对象,同步返回结果。 145 146**系统接口:** 此接口为系统接口。 147 148**系统能力:** SystemCapability.Multimedia.Camera.Core 149 150**参数:** 151 152| 参数名 | 类型 | 必填 | 说明 | 153| -------- | ----------------------------------------------- | ---- | ------------------------------- | 154| profile | [Profile](js-apis-camera.md#profile) | 是 | 支持的预览配置信息,通过[getSupportedOutputCapability](js-apis-camera.md#getsupportedoutputcapability11)接口获取。| 155 156**返回值:** 157 158| 类型 | 说明 | 159| ---------- | ----------------------------- | 160| [DepthDataOutput](#depthdataoutput12) | DepthDataOutput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 161 162**错误码:** 163 164以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 165 166| 错误码ID | 错误信息 | 167| --------------- | --------------- | 168| 7400101 | Parameter missing or parameter type incorrect. | 169| 7400201 | Camera service fatal error. | 170 171**示例:** 172 173```ts 174import { BusinessError } from '@kit.BasicServicesKit'; 175 176function createDepthDataOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager): camera.DepthDataOutput | undefined { 177 let profile: camera.Profile = cameraOutputCapability.depthProfiles[0]; 178 let depthDataOutput: camera.DepthDataOutput | undefined = undefined; 179 try { 180 depthDataOutput = cameraManager.createDepthDataOutput(profile); 181 } catch (error) { 182 // 失败返回错误码error.code并处理 183 let err = error as BusinessError; 184 console.error(`The createDepthDataOutput call failed. error code: ${err.code}`); 185 } 186 return depthDataOutput; 187} 188``` 189 190### isCameraMuteSupported 191 192isCameraMuteSupported(): boolean 193 194查询当前设备是否支持禁用相机。 195 196**系统接口:** 此接口为系统接口。 197 198**系统能力:** SystemCapability.Multimedia.Camera.Core 199 200**返回值:** 201 202| 类型 | 说明 | 203| ---------- | ----------------------------- | 204| boolean | 返回true表示相机可以被禁用,返回false表示相机不能被禁用。 | 205 206**示例:** 207 208```ts 209function isCameraMuteSupported(cameraManager: camera.CameraManager): boolean { 210 let isMuteSupported: boolean = cameraManager.isCameraMuteSupported(); 211 return isMuteSupported; 212} 213``` 214 215### muteCamera 216 217muteCamera(mute: boolean): void 218 219禁用相机。 220 221> **说明:** 222>从 API version 10开始支持,从API version 12开始废弃。建议使用[muteCameraPersistent](#mutecamerapersistent12)替代。 223 224**系统接口:** 此接口为系统接口。 225 226**系统能力:** SystemCapability.Multimedia.Camera.Core 227 228**参数:** 229 230| 参数名 | 类型 | 必填 | 说明 | 231| -------- | --------------------------------- | ---- | ---------- | 232| mute | boolean | 是 | 禁用相机。true为禁用;false为解除禁用。 | 233 234**示例:** 235 236```ts 237function muteCamera(cameraManager: camera.CameraManager): void { 238 let mute: boolean = true; 239 cameraManager.muteCamera(mute); 240} 241``` 242 243### muteCameraPersistent<sup>12+</sup> 244 245muteCameraPersistent(mute: boolean, type: PolicyType): void 246 247以持久化的方式禁用相机。 248 249**系统接口:** 此接口为系统接口。 250 251**系统能力:** SystemCapability.Multimedia.Camera.Core 252 253**参数:** 254 255| 参数名 | 类型 | 必填 | 说明 | 256| -------- |-----------------------------| ---- |--------------------------------------------| 257| mute | boolean | 是 | 禁用相机。true为禁用;false为解除禁用。 | 258| type | [PolicyType](#policytype12) | 是 | 策略类型。请使用[PolicyType](#policytype12)里面支持的类型 | 259 260**示例:** 261 262```ts 263function muteCameraPersistent(cameraManager: camera.CameraManager): void { 264 let mute: boolean = true; 265 cameraManager.muteCameraPersistent(mute, camera.PolicyType.PRIVACY); 266} 267``` 268 269### on('cameraMute') 270 271on(type: 'cameraMute', callback: AsyncCallback\<boolean\>): void 272 273禁用回调,通过注册回调函数获取相机禁用状态变化。使用callback异步回调。 274 275**系统接口:** 此接口为系统接口。 276 277**系统能力:** SystemCapability.Multimedia.Camera.Core 278 279**参数:** 280 281| 参数名 | 类型 | 必填 | 说明 | 282| -------- | --------------- | ---- | --------- | 283| type | string | 是 | 监听事件,固定为'cameraMute',系统相机摄像头开关,cameraManager对象获取成功后可监听。系统设置打开或禁用相机会触发该事件并返回状态。 | 284| callback | AsyncCallback\<boolean> | 是 | 回调函数,用于获取禁用状态变化信息,返回true是开启状态,返回false是禁用状态。 | 285 286**示例:** 287 288```ts 289import { BusinessError } from '@kit.BasicServicesKit'; 290 291function callback(err: BusinessError, curMuted: boolean): void { 292 if (err !== undefined && err.code !== 0) { 293 console.error(`Callback Error, errorCode: ${err.code}`); 294 return; 295 } 296 let isMuted: boolean = curMuted; 297 console.info(`cameraMute status: ${isMuted}`); 298} 299 300function registerCameraMute(cameraManager: camera.CameraManager): void { 301 cameraManager.on('cameraMute', callback); 302} 303``` 304 305### off('cameraMute') 306 307off(type: 'cameraMute', callback?: AsyncCallback\<boolean\>): void 308 309禁用回调,通过注销注册回调函数获取相机禁用状态变化。 310 311**系统接口:** 此接口为系统接口。 312 313**系统能力:** SystemCapability.Multimedia.Camera.Core 314 315**参数:** 316 317| 参数名 | 类型 | 必填 | 说明 | 318| -------- | --------------- | ---- |---------------------------------------------------------| 319| type | string | 是 | 监听事件,固定为'cameraMute',系统相机摄像头开关,cameraManager对象获取成功后可监听。 | 320| callback | AsyncCallback\<boolean> | 否 | 回调函数,可选参数,有就是匹配on('cameraMute') callback(callback对象不可是匿名函数)。 | 321 322**示例:** 323 324```ts 325import { BusinessError } from '@kit.BasicServicesKit'; 326 327function callback(err: BusinessError, curMuted: boolean): void { 328 let isMuted: boolean = curMuted; 329} 330 331function unregisterCameraMute(cameraManager: camera.CameraManager): void { 332 cameraManager.off('cameraMute', callback); 333} 334``` 335 336### isPrelaunchSupported 337 338isPrelaunchSupported(camera: CameraDevice): boolean 339 340检查指定cameraDevice是否支持预热启动。 341 342**系统接口:** 此接口为系统接口。 343 344**系统能力:** SystemCapability.Multimedia.Camera.Core 345 346**参数:** 347 348| 参数名 | 类型 | 必填 | 说明 | 349| -------- | --------------- | ---- | --------- | 350| camera | [CameraDevice](#cameradevice) | 是 | 相机信息。| 351 352**返回值:** 353 354| 类型 | 说明 | 355| -------- | --------------- | 356| boolean | 返回指定cameraDevice是否支持预热启动。| 357 358**错误码:** 359 360以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 361 362| 错误码ID | 错误信息 | 363| --------------- | --------------- | 364| 202 | Not System Application. | 365| 7400101 | Parameter missing or parameter type incorrect. | 366 367**示例:** 368 369```ts 370import { common } from '@kit.AbilityKit'; 371 372function isPreLaunchSupported(context: common.BaseContext): boolean { 373 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 374 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 375 let isSupported: boolean = false; 376 if (cameras && cameras.length >= 1) { 377 isSupported = cameraManager.isPrelaunchSupported(cameras[0]); 378 console.info(`PreLaunch supported states: ${isSupported}`); 379 return isSupported; 380 } 381 return isSupported; 382} 383``` 384 385### setPrelaunchConfig 386 387setPrelaunchConfig(prelaunchConfig: PrelaunchConfig): void 388 389设置预热启动的配置参数。 390 391在调用setPrelaunchConfig接口前,需要先检查设备是否支持预热启动,使用[isPrelaunchSupported](#isprelaunchsupported)判断指定cameraDevice是否支持预热启动。 392 393**系统接口:** 此接口为系统接口。 394 395**需要权限:** ohos.permission.CAMERA 396 397**系统能力:** SystemCapability.Multimedia.Camera.Core 398 399**参数:** 400 401| 参数名 | 类型 | 必填 | 说明 | 402| -------- | --------------- | ---- | --------- | 403| prelaunchConfig | [PrelaunchConfig](#prelaunchconfig) | 是 | 预启动配置参数。| 404 405**错误码:** 406 407以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 408 409| 错误码ID | 错误信息 | 410| --------------- | --------------- | 411| 202 | Not System Application. | 412| 7400101 | Parameter missing or parameter type incorrect. | 413| 7400102 | Operation not allowed. | 414| 7400201 | Camera service fatal error. | 415 416**示例:** 417 418```ts 419import { common } from '@kit.AbilityKit'; 420import { BusinessError } from '@kit.BasicServicesKit'; 421 422function setPrelaunchConfig(context: common.BaseContext): void { 423 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 424 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 425 if (cameras && cameras.length >= 1) { 426 let cameraDevice: camera.CameraDevice = cameras[0]; 427 if(cameraManager.isPrelaunchSupported(cameraDevice)) { 428 try { 429 cameraManager.setPrelaunchConfig({cameraDevice: cameraDevice}); 430 } catch (error) { 431 let err = error as BusinessError; 432 console.error(`setPrelaunchConfig error. Code: ${err.code}, message: ${err.message}`); 433 } 434 } 435 } 436} 437``` 438 439### prelaunch 440 441prelaunch(): void 442 443用户点击系统相机图标,拉起相机应用同时调用,下发预热请求,使能相机预热启动。 444 445**系统接口:** 此接口为系统接口。 446 447**系统能力:** SystemCapability.Multimedia.Camera.Core 448 449**示例:** 450 451```ts 452import { common } from '@kit.AbilityKit'; 453import { BusinessError } from '@kit.BasicServicesKit'; 454 455function preLaunch(context: common.BaseContext): void { 456 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 457 try { 458 cameraManager.prelaunch(); 459 } catch (error) { 460 let err = error as BusinessError; 461 console.error(`prelaunch error. Code: ${err.code}, message: ${err.message}`); 462 } 463} 464``` 465 466### createDeferredPreviewOutput 467 468createDeferredPreviewOutput(profile: Profile): PreviewOutput 469 470创建延迟预览输出对象,在配流时替代普通的预览输出对象加入数据流。 471 472**系统接口:** 此接口为系统接口。 473 474**系统能力:** SystemCapability.Multimedia.Camera.Core 475 476**参数:** 477 478| 参数名 | 类型 | 必填 | 说明 | 479| -------- | --------------- | ---- | --------- | 480| profile | [Profile](js-apis-camera.md#profile) | 是 | 相机预览流的配置文件。 | 481 482**返回值:** 483 484| 类型 | 说明 | 485| -------- | --------------- | 486| [PreviewOutput](#previewoutput) | 返回预览输出对象。 | 487 488**错误码:** 489 490以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 491 492| 错误码ID | 错误信息 | 493| --------------- | --------------- | 494| 202 | Not System Application. | 495| 7400101 | Parameter missing or parameter type incorrect. | 496 497**示例:** 498 499```ts 500import { common } from '@kit.AbilityKit'; 501 502function getDeferredPreviewOutput(context: common.BaseContext, previewProfile: camera.Profile): camera.PreviewOutput { 503 const cameraManager: camera.CameraManager = camera.getCameraManager(context); 504 const output: camera.PreviewOutput = cameraManager.createDeferredPreviewOutput(previewProfile); 505 return output; 506} 507``` 508 509### preSwitchCamera<sup>11+</sup> 510 511preSwitchCamera(cameraId: string): void 512 513预切换摄像头,提升摄像头启动速度。 514 515**系统接口:** 此接口为系统接口。 516 517**系统能力:** SystemCapability.Multimedia.Camera.Core 518 519**参数:** 520 521| 参数名 | 类型 | 必填 | 说明 | 522| -------- | --------------- | ---- | --------- | 523| cameraId | string | 是 | 相机id。 | 524 525**错误码:** 526 527以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 528 529| 错误码ID | 错误信息 | 530| ------- |------------------------------------------------| 531| 202 | Not System Application. | 532| 7400101 | Parameter missing or parameter type incorrect. | 533| 7400201 | Camera service fatal error. | 534 535**示例:** 536 537```ts 538import { common } from '@kit.AbilityKit'; 539import { BusinessError } from '@kit.BasicServicesKit'; 540 541function preSwitch(cameraDevice: camera.CameraDevice, context: common.BaseContext): void { 542 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 543 try { 544 cameraManager.preSwitchCamera(cameraDevice.cameraId); 545 } catch (error) { 546 let err = error as BusinessError; 547 console.error(`prelaunch error. Code: ${err.code}, message: ${err.message}`); 548 } 549} 550``` 551 552## CameraOcclusionDetectionResult<sup>12+</sup> 553摄像头模组被遮挡状态。 554 555**系统接口:** 此接口为系统接口。 556 557**系统能力:** SystemCapability.Multimedia.Camera.Core 558 559| 名称 | 类型 | 只读 | 可选 | 说明 | 560| ----------------------------- | --------------------------------------------------- | ---- | ---- |-------------------| 561| isCameraOccluded | boolean | 是 | 否 |遮挡状态。 | 562 563## CameraOutputCapability<sup>12+</sup> 564 565相机输出能力项。 566 567**系统接口:** 此接口为系统接口。 568 569**系统能力:** SystemCapability.Multimedia.Camera.Core 570 571| 名称 | 类型 | 只读 | 可选 | 说明 | 572| ----------------------------- | --------------------------------------------------- | ---- | ---- |-------------------| 573| depthProfiles | Array\<[DepthProfile](#depthprofile12)\> | 是 | 否 | 支持的深度流配置信息集合。 | 574 575## CameraFormat 576 577枚举,输出格式。 578 579**系统接口:** 此接口为系统接口。 580 581**系统能力:** SystemCapability.Multimedia.Camera.Core 582 583| 名称 | 值 | 说明 | 584| ----------------------- | --------- | ------------ | 585| CAMERA_FORMAT_DEPTH_16<sup>12+</sup> | 3000 | DEPTH_16格式的深度图。 | 586| CAMERA_FORMAT_DEPTH_32<sup>12+</sup> | 3001 | DEPTH_32格式的深度图。 | 587 588## CameraInput 589 590相机设备输入对象。 591 592会话中[Session](js-apis-camera.md#session11)使用的相机信息。 593 594### on('cameraOcclusionDetection')<sup>12+</sup> 595 596on(type: 'cameraOcclusionDetection', callback: AsyncCallback\<CameraOcclusionDetectionResult\>): void 597 598监听CameraInput的遮挡事件,通过注册回调函数获取结果。使用callback异步回调。 599 600**系统能力:** SystemCapability.Multimedia.Camera.Core 601 602**参数:** 603 604| 参数名 | 类型 | 必填 | 说明 | 605| -------- | -------------------------------- | --- | ------------------------------------------- | 606| type | string | 是 | 监听事件,固定为'cameraOcclusionDetection',CameraInput对象创建成功可监听。相机模组遮挡状态发生改变时触发该事件并返回结果。 | 607| callback | AsyncCallback\<[CameraOcclusionDetectionResult](#cameraocclusiondetectionresult12)\> | 是 | 回调函数,用于获取结果。返回遮挡状态。 | 608 609**示例:** 610 611```ts 612import { BusinessError } from '@kit.BasicServicesKit'; 613 614function callback(err: BusinessError, CameraOcclusionDetectionResult: camera.CameraOcclusionDetectionResult): void { 615 if (err !== undefined && err.code !== 0) { 616 console.error('cameraOcclusionDetection with errorCode = ' + err.code); 617 return; 618 } 619 console.info(`isCameraOccluded : ${CameraOcclusionDetectionResult.isCameraOccluded}`); 620} 621 622function registerCameraOcclusionDetection(cameraInput: camera.CameraInput): void { 623 cameraInput.on('cameraOcclusionDetection', callback); 624} 625``` 626 627### off('cameraOcclusionDetection')<sup>12+</sup> 628 629off(type: 'cameraOcclusionDetection', callback?: AsyncCallback\<CameraOcclusionDetectionResult\>): void 630 631注销CameraInput遮挡监听事件。 632 633**系统能力:** SystemCapability.Multimedia.Camera.Core 634 635**参数:** 636 637| 参数名 | 类型 | 必填 | 说明 | 638| -------- | --------------- | ---- |---------------------------------------------------------| 639| type | string | 是 | 监听事件,固定为'cameraOcclusionDetection',CameraInput对象创建成功可监听。 | 640| callback | AsyncCallback\<[CameraOcclusionDetectionResult](#cameraocclusiondetectionresult12)\> | 否 | 回调函数,可选参数,有就是匹配on('cameraOcclusionDetection') callback(callback对象不可是匿名函数)。 | 641 642**示例:** 643 644```ts 645import { BusinessError } from '@kit.BasicServicesKit'; 646 647function callback(err: BusinessError, CameraOcclusionDetectionResult: camera.CameraOcclusionDetectionResult): void { 648 if (err !== undefined && err.code !== 0) { 649 console.error('cameraOcclusionDetection with errorCode = ' + err.code); 650 return; 651 } 652 console.info(`isCameraOccluded : ${CameraOcclusionDetectionResult.isCameraOccluded}`); 653} 654 655function unregisterCameraOcclusionDetection(cameraInput: camera.CameraInput): void { 656 cameraInput.off('cameraOcclusionDetection', callback); 657} 658``` 659 660## DepthDataAccuracy<sup>12+</sup> 661 662深度数据的精度。 663 664**系统接口:** 此接口为系统接口。 665 666**系统能力:** SystemCapability.Multimedia.Camera.Core 667 668| 名称 | 类型 | 只读 | 可选 | 说明 | 669| -------- | ----------------------------- |----- |---| -------------- | 670| DEPTH_DATA_ACCURACY_RELATIVE | number | 是 | 否 | 相对精度,基于视差计算得到的深度图。 | 671| DEPTH_DATA_ACCURACY_ABSOLUTE | number | 是 | 否 | 绝对精度,基于测距计算得到的深度图。 | 672 673## DepthProfile<sup>12+</sup> 674 675深度数据配置信息项,继承[Profile](js-apis-camera.md#profile)。 676 677**系统接口:** 此接口为系统接口。 678 679**系统能力:** SystemCapability.Multimedia.Camera.Core 680 681| 名称 | 类型 | 只读 | 可选 | 说明 | 682| ------------------------- | ----------------------------------------- | --- | ---- |----------- | 683| depthDataAccuracy | [DepthDataAccuracy](#depthdataaccuracy12) | 是 | 否 | 深度数据的精度,分为相对精度和绝对精度 | 684 685## DepthDataQualityLevel<sup>12+</sup> 686 687深度数据的质量。 688 689**系统接口:** 此接口为系统接口。 690 691**系统能力:** SystemCapability.Multimedia.Camera.Core 692 693| 名称 | 类型 | 只读 | 可选 | 说明 | 694| -------- | ----------------------------- |----- |---| -------------- | 695| DEPTH_DATA_QUALITY_BAD | number | 是 | 否 | 深度图的质量很差,无法用于虚化等。 | 696| DEPTH_DATA_QUALITY_FAIR | number | 是 | 否 | 深度图的质量一般,无法生成高质量的虚化等。 | 697| DEPTH_DATA_QUALITY_GOOD | number | 是 | 否 | 深度图的质量较高,可以生成高质量的虚化等。 | 698 699## DepthData<sup>12+</sup> 700 701深度数据对象。 702 703### 属性 704 705**系统接口:** 此接口为系统接口。 706 707**系统能力:** SystemCapability.Multimedia.Camera.Core 708 709| 名称 | 类型 | 只读 | 可选 | 说明 | 710| -------- | ----------------------------- |----- |---| -------------- | 711| format | [CameraFormat](#cameraformat) | 是 | 否 | 深度图的格式。 | 712| depthMap | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | 是 | 否 | 深度图。 | 713| qualityLevel | [DepthDataQualityLevel](#depthdataqualitylevel12) | 是 | 否 | 深度图的质量。 | 714| accuracy | [DepthDataAccuracy](#depthdataaccuracy12) | 是 | 否 | 深度图的精度。 | 715 716### release<sup>12+</sup> 717 718release(): void 719 720释放输出资源。 721 722**系统接口:** 此接口为系统接口。 723 724**系统能力:** SystemCapability.Multimedia.Camera.Core 725 726**示例:** 727 728```ts 729function releaseDepthData(depthData: camera.DepthData): void { 730 await depthData.release(); 731} 732``` 733 734## DepthDataOutput<sup>12+</sup> 735 736深度信息输出类。继承[CameraOutput](js-apis-camera.md#cameraoutput)。 737 738### start<sup>12+</sup> 739 740start(): Promise\<void\> 741 742启动深度信息输出流,通过Promise获取结果。 743 744**系统接口:** 此接口为系统接口。 745 746**系统能力:** SystemCapability.Multimedia.Camera.Core 747 748**返回值:** 749 750| 类型 | 说明 | 751| -------------- | ----------------------- | 752| Promise\<void\> | 无返回结果的Promise对象。 | 753 754**错误码:** 755 756以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 757 758| 错误码ID | 错误信息 | 759| --------------- | --------------- | 760| 7400103 | Session not config. | 761| 7400201 | Camera service fatal error. | 762 763**示例:** 764 765```ts 766import { BusinessError } from '@kit.BasicServicesKit'; 767 768function startDepthDataOutput(depthDataOutput: camera.DepthDataOutput): void { 769 depthDataOutput.start().then(() => { 770 console.info('Promise returned to indicate that start method execution success.'); 771 }).catch((error: BusinessError) => { 772 console.error(`Failed to depth data output start, error code: ${error.code}.`); 773 }); 774} 775``` 776 777### stop<sup>12+</sup> 778 779stop(): Promise\<void\> 780 781结束深度信息输出,通过Promise获取结果。 782 783**系统接口:** 此接口为系统接口。 784 785**系统能力:** SystemCapability.Multimedia.Camera.Core 786 787**返回值:** 788 789| 类型 | 说明 | 790| -------------- | ----------------------- | 791| Promise\<void\> | 无返回结果的Promise对象。 | 792 793**示例:** 794 795```ts 796import { BusinessError } from '@kit.BasicServicesKit'; 797 798function stopDepthDataOutput(depthDataOutput: camera.DepthDataOutput): void { 799 depthDataOutput.stop().then(() => { 800 console.info('Promise returned to indicate that stop method execution success.'); 801 }).catch((error: BusinessError) => { 802 console.error(`Failed to depth data output stop, error code: ${error.code}.`); 803 }); 804} 805``` 806 807### on('depthDataAvailable')<sup>12+</sup> 808 809on(type: 'depthDataAvailable', callback: AsyncCallback\<DepthData\>): void 810 811注册监听深度数据上报。使用callback异步回调。 812 813> **说明:** 814> 815> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。 816 817**系统接口:** 此接口为系统接口。 818 819**系统能力:** SystemCapability.Multimedia.Camera.Core 820 821**参数:** 822 823| 参数名 | 类型 | 必填 | 说明 | 824| -------- | ---------- | --- | ------------------------------------ | 825| type | string | 是 | 监听事件,固定为'depthDataAvailable',depthDataOutput创建成功后可监听。 | 826| callback | AsyncCallback\<[DepthData](#depthdata12)\> | 是 | 回调函数,用于监听深度信息上报。 | 827 828**示例:** 829 830```ts 831import { BusinessError } from '@kit.BasicServicesKit'; 832 833function callback(err: BusinessError, depthData: camera.DepthData): void { 834 if (err !== undefined && err.code !== 0) { 835 console.error(`Callback Error, errorCode: ${err.code}`); 836 return; 837 } 838} 839 840function registerDepthDataAvailable(depthDataOutput: camera.DepthDataOutput): void { 841 depthDataOutput.on('depthDataAvailable', callback); 842} 843``` 844 845### off('depthDataAvailable')<sup>12+</sup> 846 847off(type: 'depthDataAvailable', callback?: AsyncCallback\<DepthData\>): void 848 849注销监听深度信息上报。 850 851**系统接口:** 此接口为系统接口。 852 853**系统能力:** SystemCapability.Multimedia.Camera.Core 854 855**参数:** 856 857| 参数名 | 类型 | 必填 | 说明 | 858| -------- | ---------------------- | ---- | ------------------------------------------ | 859| type | string | 是 | 监听事件,固定为'depthDataAvailable',depthDataOutput创建成功后可监听。 | 860| callback | AsyncCallback\<[DepthData](#depthdata12)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 861 862**示例:** 863 864```ts 865import { BusinessError } from '@kit.BasicServicesKit'; 866 867function callback(err: BusinessError, depthData: camera.DepthData): void { 868 if (err !== undefined && err.code !== 0) { 869 console.error(`Callback Error, errorCode: ${err.code}`); 870 return; 871 } 872} 873 874function unRegisterDepthDataAvailable(depthDataOutput: camera.DepthDataOutput): void { 875 depthDataOutput.off('depthDataAvailable', callback); 876} 877``` 878 879### on('error')<sup>12+</sup> 880 881on(type: 'error', callback: ErrorCallback): void 882 883监听深度信息输出的错误事件,通过注册回调函数获取结果。使用callback异步回调。 884 885> **说明:** 886> 887> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。 888 889**系统接口:** 此接口为系统接口。 890 891**系统能力:** SystemCapability.Multimedia.Camera.Core 892 893**参数:** 894 895| 参数名 | 类型 | 必填 | 说明 | 896| -------- | --------------| ---- | ------------------------ | 897| type | string | 是 | 监听事件,固定为'error',depthDataOutput创建成功可监听。 | 898| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 899 900**示例:** 901 902```ts 903import { BusinessError } from '@kit.BasicServicesKit'; 904 905function callback(depthDataOutputError: BusinessError): void { 906 console.error(`Depth data output error code: ${depthDataOutputError.code}`); 907} 908 909function registerDepthDataOutputError(depthDataOutput: camera.DepthDataOutput): void { 910 depthDataOutput.on('error', callback) 911} 912``` 913 914### off('error')<sup>12+</sup> 915 916off(type: 'error', callback?: ErrorCallback): void 917 918注销监听深度信息输出的错误事件。 919 920**系统接口:** 此接口为系统接口。 921 922**系统能力:** SystemCapability.Multimedia.Camera.Core 923 924**参数:** 925 926| 参数名 | 类型 | 必填 | 说明 | 927| -------- | --------------| ---- | ------------------------ | 928| type | string | 是 | 监听事件,固定为'error',depthDataOutput创建成功可监听。 | 929| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 930 931**示例:** 932 933```ts 934function unregisterDepthDataOutputError(depthDataOutput: camera.DepthDataOutput): void { 935 depthDataOutput.off('error'); 936} 937``` 938 939## PrelaunchConfig 940 941相机预启动配置参数。 942 943当前sensor级别预热,待扩展流预热参数。 944 945**系统接口:** 此接口为系统接口。 946 947**系统能力:** SystemCapability.Multimedia.Camera.Core 948 949| 名称 | 类型 | 只读 | 必填 | 说明 | 950| ------------------------------- | ---------------------------------------- | ----------- | ------------ | ---------- | 951| cameraDevice | [CameraDevice](#cameradevice) | 否 | 是 | 相机信息。 | 952| restoreParamType<sup>11+</sup> | [RestoreParamType](#restoreparamtype11) | 否 | 否 | 预保存参数类型。 | 953| activeTime<sup>11+</sup> | number | 否 | 否 | 激活时间,单位min。 | 954| settingParam<sup>11+</sup> | [SettingParam](#settingparam11) | 否 | 否 | 设置参数内容。 | 955 956## RestoreParamType<sup>11+</sup> 957 958预保存参数类型。 959 960**系统接口:** 此接口为系统接口。 961 962**系统能力:** SystemCapability.Multimedia.Camera.Core 963 964| 名称 | 值 | 说明 | 965| ----------------| ---- | ---------| 966| NO_NEED_RESTORE_PARAM | 0 | 不需要预保存参数类型。 | 967| PRESISTENT_DEFAULT_PARAM | 1 | 持久化参数类型,指某一时间点后,使用该参数恢复流信息。 | 968| TRANSIENT_ACTIVE_PARAM | 2 | 临时参数类型,只在关闭相机后一段时间内,使用该参数恢复流信息,优先级高于持久化参数。 | 969 970## SettingParam<sup>11+</sup> 971 972用于预热出图的效果参数。 973 974**系统接口:** 此接口为系统接口。 975 976**系统能力:** SystemCapability.Multimedia.Camera.Core 977 978| 名称 | 类型 | 只读 | 可选 | 说明 | 979| --------------- | ------ | --------- |-----|---------------------------------------------------------------------------------------------------| 980| skinSmoothLevel | number | 否 | 否 | 美颜类型光滑信息,从[Beauty.getSupportedBeautyRange](#getsupportedbeautyrange12)获取支持的光滑范围,例如1表示1级光滑。 | 981| faceSlender | number | 否 | 否 | 美颜类型瘦脸信息,从[Beauty.getSupportedBeautyRange](#getsupportedbeautyrange12)获取支持的瘦脸范围,例如1表示1级瘦脸。 | 982| skinTone | number | 否 | 否 | 美颜类型肤色信息,从[Beauty.getSupportedBeautyRange](#getsupportedbeautyrange12)获取支持的肤色范围,例如0xBF986C表示一个颜色。 | 983 984## PreviewOutput 985 986预览输出类。继承[CameraOutput](js-apis-camera.md#cameraoutput)。 987 988### addDeferredSurface 989 990addDeferredSurface(surfaceId: string): void 991 992配置延迟预览的Surface,可以在[Session.commitConfig](js-apis-camera.md#commitconfig11-1)配流和[Session.start](js-apis-camera.md#start11-1)启流之后运行。 993 994**系统接口:** 此接口为系统接口。 995 996**系统能力:** SystemCapability.Multimedia.Camera.Core 997 998**参数:** 999 1000| 参数名 | 类型 | 必填 | 说明 | 1001| -------- | --------------| ---- | ------------------------ | 1002| surfaceId | string | 是 | 从[XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md)组件获取的surfaceId。| 1003 1004**错误码:** 1005 1006以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1007 1008| 错误码ID | 错误信息 | 1009| --------------- | --------------- | 1010| 7400101 | Parameter missing or parameter type incorrect. | 1011 1012**示例:** 1013 1014```ts 1015import { common } from '@kit.AbilityKit'; 1016 1017async function preview(context: common.BaseContext, cameraDevice: camera.CameraDevice, previewProfile: camera.Profile, photoProfile: camera.Profile, mode: camera.SceneMode, previewSurfaceId: string): Promise<void> { 1018 const cameraManager: camera.CameraManager = camera.getCameraManager(context); 1019 const cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameraDevice); 1020 const previewOutput: camera.PreviewOutput = cameraManager.createDeferredPreviewOutput(previewProfile); 1021 const photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 1022 const session: camera.Session = cameraManager.createSession(mode); 1023 session.beginConfig(); 1024 session.addInput(cameraInput); 1025 session.addOutput(previewOutput); 1026 session.addOutput(photoOutput); 1027 await session.commitConfig(); 1028 await session.start(); 1029 previewOutput.addDeferredSurface(previewSurfaceId); 1030} 1031``` 1032 1033### isSketchSupported<sup>11+</sup> 1034 1035isSketchSupported(): boolean 1036 1037查询是否支持画中画能力。 1038 1039**系统接口:** 此接口为系统接口。 1040 1041**系统能力:** SystemCapability.Multimedia.Camera.Core 1042 1043**返回值:** 1044 1045| 类型 | 说明 | 1046| -------------- | ----------------------- | 1047| boolean | 返回是否支持画中画。 | 1048 1049**错误码:** 1050 1051以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1052 1053| 错误码ID | 错误信息 | 1054| --------------- |-------------------------| 1055| 202 | Not System Application. | 1056 1057**示例:** 1058 1059```ts 1060function isSketchSupported(previewOutput: camera.PreviewOutput): boolean { 1061 try { 1062 let isSupported: boolean = previewOutput.isSketchSupported(); 1063 return isSupported; 1064 } catch (error) { 1065 // 失败返回错误码error.code并处理 1066 let err = error as BusinessError; 1067 console.error(`The isSketchSupported call failed. error code: ${err.code}`); 1068 } 1069 return false; 1070} 1071``` 1072 1073### getSketchRatio<sup>11+</sup> 1074 1075getSketchRatio(): number 1076 1077获取当前状态下启动画中画的Zoom倍率。 1078 1079**系统接口:** 此接口为系统接口。 1080 1081**系统能力:** SystemCapability.Multimedia.Camera.Core 1082 1083**返回值:** 1084 1085| 类型 | 说明 | 1086| -------------- | ----------------------- | 1087| number | 当前状态下启动画中画的Zoom倍率。不支持画中画的情况下,该接口返回-1。 | 1088 1089**错误码:** 1090 1091以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1092 1093| 错误码ID | 错误信息 | 1094| --------------- | --------------- | 1095| 7400103 | Session not config. | 1096| 202 | Not System Application. | 1097 1098**示例:** 1099 1100```ts 1101function getSketchRatio(previewOutput: camera.PreviewOutput): number { 1102 let sketchRatio: number = previewOutput.getSketchRatio(); 1103 return sketchRatio; 1104} 1105``` 1106 1107### enableSketch<sup>11+</sup> 1108 1109enableSketch(enabled: boolean): void 1110 1111使能画中画。 1112 1113**系统接口:** 此接口为系统接口。 1114 1115**系统能力:** SystemCapability.Multimedia.Camera.Core 1116 1117**参数:** 1118 1119| 参数名 | 类型 | 必填 | 说明 | 1120|---------|---------| ---- | ------------------------ | 1121| enabled | boolean | 是 | true表明开启画中画流进行预览。| 1122 1123**错误码:** 1124 1125以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1126 1127| 错误码ID | 错误信息 | 1128|-----------|-----------------------------| 1129| 202 | Not System Application. | 1130| 7400102 | Operation not allowed. | 1131| 7400103 | Session not config. | 1132| 7400201 | Camera service fatal error. | 1133 1134**示例:** 1135 1136```ts 1137import { BusinessError } from '@kit.BasicServicesKit'; 1138 1139function enableSketch(previewOutput: camera.PreviewOutput, session: camera.Session, cameraInput: camera.CameraInput): void { 1140 try { 1141 session.beginConfig(); 1142 session.addInput(cameraInput); 1143 session.addOutput(previewOutput); 1144 previewOutput.enableSketch(true); 1145 session.commitConfig(); 1146 } catch (error) { 1147 // 失败返回错误码error.code并处理 1148 let err = error as BusinessError; 1149 console.error(`The enableSketch call failed. error code: ${err.code}`); 1150 } 1151} 1152``` 1153 1154### attachSketchSurface<sup>11+</sup> 1155 1156attachSketchSurface(surfaceId: string): void 1157 1158添加画中画预览的Surface。 1159 1160**系统接口:** 此接口为系统接口。 1161 1162**系统能力:** SystemCapability.Multimedia.Camera.Core 1163 1164**参数:** 1165 1166| 参数名 | 类型 | 必填 | 说明 | 1167| -------- | --------------| ---- | ------------------------ | 1168| surfaceId | string | 是 | 从[XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md)组件获取的surfaceId。| 1169 1170**错误码:** 1171 1172以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1173 1174| 错误码ID | 错误信息 | 1175|---------|------------------------------------------------| 1176| 202 | Not System Application. | 1177| 7400101 | Parameter missing or parameter type incorrect. | 1178| 7400103 | Session not config. | 1179| 7400201 | Camera service fatal error. | 1180 1181**示例:** 1182 1183```ts 1184import { BusinessError } from '@kit.BasicServicesKit'; 1185 1186function attachSketchSurface(previewOutput: camera.PreviewOutput, session: camera.Session, cameraInput: camera.CameraInput, sketchSurfaceId: string): void { 1187 try { 1188 session.beginConfig(); 1189 session.addInput(cameraInput); 1190 session.addOutput(previewOutput); 1191 previewOutput.enableSketch(true); 1192 session.commitConfig(); 1193 previewOutput.attachSketchSurface(sketchSurfaceId); 1194 } catch (error) { 1195 // 失败返回错误码error.code并处理 1196 let err = error as BusinessError; 1197 console.error(`The attachSketchSurface call failed. error code: ${err.code}`); 1198 } 1199} 1200``` 1201 1202### on('sketchStatusChanged')<sup>11+</sup> 1203 1204on(type: 'sketchStatusChanged', callback: AsyncCallback\<SketchStatusData\>): void 1205 1206监听画中画状态信息改变,通过注册回调函数获取SketchStatusData。使用callback异步回调。 1207 1208**系统接口:** 此接口为系统接口。 1209 1210**系统能力:** SystemCapability.Multimedia.Camera.Core 1211 1212**参数:** 1213 1214| 参数名 | 类型 | 必填 | 说明 | 1215| -------- | ---------------------- | ---- | ------------------------------------------ | 1216| type | string | 是 | 监听事件,固定为'sketchStatusChanged',画中画流创建成功后可监听。底层画中画的状态启停以及画中画Zoom值变更会回调该接口。 | 1217| callback | AsyncCallback\<[SketchStatusData](#sketchstatusdata11)\> | 是 | 使用callback的方式获取SketchStatusData。 | 1218 1219**错误码:** 1220 1221以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1222 1223| 错误码ID | 错误信息 | 1224|---------|-------------------------------| 1225| 202 | Not System Application. | 1226 1227**示例:** 1228 1229```ts 1230import { BusinessError } from '@kit.BasicServicesKit'; 1231 1232function callback(error: BusinessError, data: camera.SketchStatusData): void { 1233 if (error !== undefined && error.code !== 0) { 1234 console.error(`Callback Error, errorCode: ${error.code}`); 1235 return; 1236 } 1237 console.info(`sketch errorCode is ${error.code}, data is ${JSON.stringify(data)}`); 1238} 1239 1240function registerSketchStatusChanged(previewOutput: camera.PreviewOutput): void { 1241 previewOutput.on('sketchStatusChanged', callback); 1242} 1243``` 1244 1245### off('sketchStatusChanged')<sup>11+</sup> 1246 1247off(type: 'sketchStatusChanged', callback?: AsyncCallback\<SketchStatusData\>): void 1248 1249注销监听画中画状态信息改变。 1250 1251**系统接口:** 此接口为系统接口。 1252 1253**系统能力:** SystemCapability.Multimedia.Camera.Core 1254 1255**参数:** 1256 1257| 参数名 | 类型 | 必填 | 说明 | 1258| -------- | ---------------------- | ---- | ------------------------------------------ | 1259| type | string | 是 | 监听事件,固定为'sketchStatusChanged',画中画流创建成功后可监听。 | 1260| callback | AsyncCallback\<[SketchStatusData](#sketchstatusdata11)\> | 否 | 回调函数,可选,有就是匹配on('sketchStatusChanged') callback(callback对象不可是匿名函数)。 | 1261 1262**错误码:** 1263 1264以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1265 1266| 错误码ID | 错误信息 | 1267|---------|-------------------------------| 1268| 202 | Not System Application. | 1269 1270**示例:** 1271 1272```ts 1273function unregisterSketchStatusChanged(previewOutput: camera.PreviewOutput): void { 1274 previewOutput.off('sketchStatusChanged'); 1275} 1276``` 1277 1278## DeferredDeliveryImageType<sup>11+</sup> 1279 1280枚举,分段式能力类型。即将拍照/录像分为两个阶段,一阶段以较快速度输出图片/视频提供给用户,二阶段完成优化处理,重新输出高质量图片/视频。 1281 1282**系统接口:** 此接口为系统接口。 1283 1284**系统能力:** SystemCapability.Multimedia.Camera.Core 1285 1286| 名称 | 值 | 说明 | 1287| ------- | ---- | ------------ | 1288| NONE | 0 | 无分段式能力。| 1289| PHOTO | 1 | 分段式拍照。| 1290| VIDEO | 2 | 分段式录像。| 1291 1292## DeferredPhotoProxy<sup>11+</sup> 1293 1294类对象,缩略图代理类。 1295 1296### getThumbnail<sup>11+</sup> 1297 1298getThumbnail(): Promise<image.PixelMap> 1299 1300通过缩略图代理类提供的方法,获取缩略图 PixelMap。 1301 1302**系统接口:** 此接口为系统接口。 1303 1304**系统能力:** SystemCapability.Multimedia.Camera.Core 1305 1306**返回值:** 1307 1308| 类型 | 说明 | 1309| -------------- | ----------------------- | 1310| Promise\<image.PixelMap\> | 缩略图 PixelMap。 | 1311 1312**错误码:** 1313 1314以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1315 1316| 错误码ID | 错误信息 | 1317| --------------- | --------------- | 1318| 202 | Not System Application. | 1319 1320**示例:** 1321 1322```ts 1323import { image } from '@kit.ImageKit'; 1324 1325function getThumbnail(proxyObj: camera.DeferredPhotoProxy): void { 1326 proxyObj.getThumbnail().then((thumbnail: image.PixelMap) => { 1327 AppStorage.setOrCreate('proxyThumbnail', thumbnail); 1328 }); 1329} 1330``` 1331 1332### release<sup>11+</sup> 1333 1334release(): Promise\<void\> 1335 1336释放输出资源,通过Promise获取结果。 1337 1338**系统接口:** 此接口为系统接口。 1339 1340**系统能力:** SystemCapability.Multimedia.Camera.Core 1341 1342**返回值:** 1343 1344| 类型 | 说明 | 1345| -------------- |------------------| 1346| Promise\<void\> | 无返回结果的Promise对象。 | 1347 1348**错误码:** 1349 1350以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1351 1352| 错误码ID | 错误信息 | 1353| --------------- | --------------- | 1354| 202 | Not System Application. | 1355 1356**示例:** 1357 1358```ts 1359async function releaseDeferredPhotoProxy(proxyObj: camera.DeferredPhotoProxy): Promise<void> { 1360 await proxyObj.release(); 1361} 1362``` 1363 1364## PhotoOutput 1365 1366拍照会话中使用的输出信息,继承[CameraOutput](js-apis-camera.md#cameraoutput)。 1367 1368### burstCapture<sup>12+</sup> 1369 1370burstCapture(setting: PhotoCaptureSetting): Promise\<void\> 1371 1372开始连续拍照,一般用于拍照模式下,开始后底层持续上图,可以通过[confirmCapture](#confirmcapture11)取消连续拍照。 1373 1374**系统接口:** 此接口为系统接口。 1375 1376**系统能力:** SystemCapability.Multimedia.Camera.Core 1377 1378**参数:** 1379 1380| 参数名 | 类型 | 必填 | 说明 | 1381| ------- | ------------------------------------------- | ---- | -------- | 1382| setting | [PhotoCaptureSetting](js-apis-camera.md#photocapturesetting) | 是 | 拍照设置,传入undefined类型数据按默认无参处理。 | 1383 1384**返回值:** 1385 1386| 类型 | 说明 | 1387| -------------- | ------------------------ | 1388| Promise\<void\> | 无返回结果的Promise对象。 | 1389 1390**错误码:** 1391 1392以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1393 1394| 错误码ID | 错误信息 | 1395| --------------- | --------------- | 1396| 202 | Not System Application. | 1397| 7400101 | Parameter missing or parameter type incorrect. | 1398| 7400104 | Session not running. | 1399| 7400201 | Camera service fatal error. | 1400 1401**示例:** 1402 1403```ts 1404import { BusinessError } from '@kit.BasicServicesKit'; 1405 1406function burstCapture(photoOutput: camera.PhotoOutput): void { 1407 let captureLocation: camera.Location = { 1408 latitude: 0, 1409 longitude: 0, 1410 altitude: 0 1411 } 1412 let settings: camera.PhotoCaptureSetting = { 1413 quality: camera.QualityLevel.QUALITY_LEVEL_LOW, 1414 rotation: camera.ImageRotation.ROTATION_0, 1415 location: captureLocation, 1416 mirror: false 1417 } 1418 photoOutput.burstCapture(settings).then(() => { 1419 console.info('Promise returned to indicate that photo burstCapture request success.'); 1420 }).catch((error: BusinessError) => { 1421 console.error(`Failed to photo output burstCapture, error code: ${error.code}.`); 1422 }); 1423} 1424``` 1425 1426### confirmCapture<sup>11+</sup> 1427 1428confirmCapture() 1429 1430确认拍照,一般用于夜景模式下,在曝光倒计时过程中如需终止倒计时提前拍照的时候调用。 1431 1432已经调用[burstCapture](#burstcapture12)开始连续拍照后,调用该接口用于结束连续拍照。 1433 1434**系统接口:** 此接口为系统接口。 1435 1436**系统能力:** SystemCapability.Multimedia.Camera.Core 1437 1438**错误码:** 1439 1440以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1441 1442| 错误码ID | 错误信息 | 1443| --------------- | --------------- | 1444| 202 | Not System Application. | 1445| 7400104 | Session not running. | 1446| 7400201 | Camera service fatal error. | 1447 1448**示例:** 1449 1450```ts 1451import { BusinessError } from '@kit.BasicServicesKit'; 1452 1453function confirmCapture(photoOutput: camera.PhotoOutput): void { 1454 try { 1455 photoOutput.confirmCapture(); 1456 } catch (error) { 1457 let err = error as BusinessError; 1458 console.error(`The confirmCapture call failed. error code: ${err.code}`); 1459 } 1460} 1461``` 1462 1463### isDeferredImageDeliverySupported<sup>11+</sup> 1464 1465isDeferredImageDeliverySupported(type: DeferredDeliveryImageType): boolean 1466 1467查询当前模式是否支持相关分段式能力。 1468 1469**系统接口:** 此接口为系统接口。 1470 1471**系统能力:** SystemCapability.Multimedia.Camera.Core 1472 1473**参数:** 1474 1475| 参数名 | 类型 | 必填 | 说明 | 1476| -------- | -------------------- | ---- | ------------------- | 1477| type | [DeferredDeliveryImageType](#deferreddeliveryimagetype11) | 是 | 分段式能力类型。 | 1478 1479**返回值:** 1480 1481| 类型 | 说明 | 1482| -------------- | ----------------------- | 1483| boolean | true: 当前模式支持该类型分段式能力, false: 不支持。 | 1484 1485**错误码:** 1486 1487以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1488 1489| 错误码ID | 错误信息 | 1490| --------------- |-----------------------------------------------------| 1491| 7400101 | Parameter missing or parameter type incorrect. | 1492| 7400104 | Session not running. | 1493| 7400201 | Camera service fatal error. | 1494| 202 | Not System Application. | 1495 1496**示例:** 1497 1498```ts 1499function isDeferredImageDeliverySupported(photoOutput: camera.PhotoOutput, type: camera.DeferredDeliveryImageType): boolean { 1500 let res: boolean = false; 1501 res = photoOutput.isDeferredImageDeliverySupported(type); 1502 return res; 1503} 1504``` 1505 1506### isDeferredImageDeliveryEnabled<sup>11+</sup> 1507 1508isDeferredImageDeliveryEnabled(type: DeferredDeliveryImageType): boolean 1509 1510查询当前模式是否已开启相关分段式能力。 1511 1512**系统接口:** 此接口为系统接口。 1513 1514**系统能力:** SystemCapability.Multimedia.Camera.Core 1515 1516**参数:** 1517 1518| 参数名 | 类型 | 必填 | 说明 | 1519| -------- | -------------------- | ---- | ------------------- | 1520| type | [DeferredDeliveryImageType](#deferreddeliveryimagetype11) | 是 | 分段式能力类型。 | 1521 1522**返回值:** 1523 1524| 类型 | 说明 | 1525| -------------- | ----------------------- | 1526| boolean | true: 当前模式已开启该类型分段式能力, false: 未开启。 | 1527 1528**错误码:** 1529 1530以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1531 1532| 错误码ID | 错误信息 | 1533| --------------- | --------------- | 1534| 7400101 | Parameter missing or parameter type incorrect. | 1535| 7400104 | Session not running. | 1536| 7400201 | Camera service fatal error. | 1537| 202 | Not System Application. | 1538 1539**示例:** 1540 1541```ts 1542function isDeferredImageDeliveryEnabled(photoOutput: camera.PhotoOutput, type: camera.DeferredDeliveryImageType): boolean { 1543 let res: boolean = false; 1544 res = photoOutput.isDeferredImageDeliveryEnabled(type); 1545 return res; 1546} 1547``` 1548 1549### deferImageDelivery<sup>11+</sup> 1550 1551deferImageDelivery(type: DeferredDeliveryImageType): void 1552 1553开启相关类型分段式能力。 1554 1555**系统接口:** 此接口为系统接口。 1556 1557**系统能力:** SystemCapability.Multimedia.Camera.Core 1558 1559**参数:** 1560 1561| 参数名 | 类型 | 必填 | 说明 | 1562| -------- | -------------------- | ---- | ------------------- | 1563| type | [DeferredDeliveryImageType](#deferreddeliveryimagetype11) | 是 | 分段式能力类型。 | 1564 1565**错误码:** 1566 1567以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1568 1569| 错误码ID | 错误信息 | 1570| --------------- | --------------- | 1571| 7400101 | Parameter missing or parameter type incorrect. | 1572| 7400104 | Session not running. | 1573| 7400201 | Camera service fatal error. | 1574| 202 | Not System Application. | 1575 1576**示例:** 1577 1578```ts 1579function deferImageDelivery(photoOutput: camera.PhotoOutput, type: camera.DeferredDeliveryImageType): void { 1580 photoOutput.deferImageDelivery(type); 1581} 1582``` 1583 1584### isAutoHighQualityPhotoSupported<sup>12+</sup> 1585 1586isAutoHighQualityPhotoSupported(): boolean 1587 1588判断当前是否支持自动高画质。 1589 1590**系统接口:** 此接口为系统接口。 1591 1592**系统能力:** SystemCapability.Multimedia.Camera.Core 1593 1594**返回值:** 1595 1596| 类型 | 说明 | 1597| -------------- | ----------------------- | 1598| boolean | 是否支持自动高画质。| 1599 1600**错误码:** 1601 1602以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1603 1604| 错误码ID | 错误信息 | 1605| --------------- | --------------- | 1606| 202 | Not System Application. | 1607| 7400104 | Session not running. | 1608| 7400201 | Camera service fatal error. | 1609 1610**示例:** 1611 1612```ts 1613import { BusinessError } from '@kit.BasicServicesKit'; 1614 1615function isAutoHighQualityPhotoSupported(photoOutput: camera.PhotoOutput): boolean { 1616 return photoOutput.isAutoHighQualityPhotoSupported(); 1617} 1618``` 1619 1620### enableAutoHighQualityPhoto<sup>12+</sup> 1621 1622enableAutoHighQualityPhoto(enabled: boolean): void 1623 1624使能拍照自动高画质。设置拍照自动高画质之前,需要调用[isAutoHighQualityPhotoSupported](#isautohighqualityphotosupported12)判断当前是否支持。 1625 1626**系统接口:** 此接口为系统接口。 1627 1628**系统能力:** SystemCapability.Multimedia.Camera.Core 1629 1630**参数:** 1631 1632| 参数名 | 类型 | 必填 | 说明 | 1633| -------- | -------------------- | ---- | ------------------- | 1634| enabled | boolean | 是 | 是否使能拍照自动高画质。 | 1635 1636**错误码:** 1637 1638以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1639 1640| 错误码ID | 错误信息 | 1641| --------------- | --------------- | 1642| 202 | Not System Application. | 1643| 7400101 | Parameter missing or parameter type incorrect. | 1644| 7400104 | Session not running. | 1645| 7400201 | Camera service fatal error. | 1646 1647**示例:** 1648 1649```ts 1650import { BusinessError } from '@kit.BasicServicesKit'; 1651 1652function enableAutoHighQualityPhoto(photoOutput: camera.PhotoOutput): void { 1653 return photoOutput.enableAutoHighQualityPhoto(true); 1654} 1655``` 1656 1657### on('deferredPhotoProxyAvailable')<sup>11+</sup> 1658 1659on(type: 'deferredPhotoProxyAvailable', callback: AsyncCallback\<DeferredPhotoProxy\>): void 1660 1661注册监听缩略图上报。使用callback异步回调。 1662 1663**系统接口:** 此接口为系统接口。 1664 1665**系统能力:** SystemCapability.Multimedia.Camera.Core 1666 1667**参数:** 1668 1669| 参数名 | 类型 | 必填 | 说明 | 1670| -------- | ---------- | --- | ------------------------------------ | 1671| type | string | 是 | 监听事件,固定为'deferredPhotoProxyAvailable',photoOutput创建成功后可监听。 | 1672| callback | AsyncCallback\<[DeferredPhotoProxy](#deferredphotoproxy11)\> | 是 | 回调函数,用于获取相关信息。用于监听缩略图上报。| 1673 1674**错误码:** 1675 1676以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1677 1678| 错误码ID | 错误信息 | 1679| --------------- | --------------- | 1680| 202 | Not System Application. | 1681 1682**示例:** 1683 1684```ts 1685import { BusinessError } from '@kit.BasicServicesKit'; 1686import { image } from '@kit.ImageKit'; 1687 1688function callback(err: BusinessError, proxyObj: camera.DeferredPhotoProxy): void { 1689 if (err !== undefined && err.code !== 0) { 1690 console.error(`Callback Error, errorCode: ${err.code}`); 1691 return; 1692 } 1693 proxyObj.getThumbnail().then((thumbnail: image.PixelMap) => { 1694 AppStorage.setOrCreate('proxyThumbnail', thumbnail); 1695 }); 1696} 1697 1698function registerPhotoOutputDeferredPhotoProxyAvailable(photoOutput: camera.PhotoOutput): void { 1699 photoOutput.on('deferredPhotoProxyAvailable', callback); 1700} 1701``` 1702 1703### off('deferredPhotoProxyAvailable')<sup>11+</sup> 1704 1705off(type: 'deferredPhotoProxyAvailable', callback?: AsyncCallback\<DeferredPhotoProxy\>): void 1706 1707注销监听缩略图上报。 1708 1709**系统接口:** 此接口为系统接口。 1710 1711**系统能力:** SystemCapability.Multimedia.Camera.Core 1712 1713**参数:** 1714 1715| 参数名 | 类型 | 必填 | 说明 | 1716| -------- | ---------------------- | ---- | ------------------------------------------ | 1717| type | string | 是 | 监听事件,固定为'deferredPhotoProxyAvailable',photoOutput创建成功后可监听。 | 1718| callback | AsyncCallback\<[DeferredPhotoProxy](#deferredphotoproxy11)\> | 否 | 回调函数,可选,有就是匹配on('deferredPhotoProxyAvailable') callback(callback对象不可是匿名函数)。 | 1719 1720**错误码:** 1721 1722以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1723 1724| 错误码ID | 错误信息 | 1725| --------------- | --------------- | 1726| 202 | Not System Application. | 1727 1728**示例:** 1729 1730```ts 1731import { BusinessError } from '@kit.BasicServicesKit'; 1732import { image } from '@kit.ImageKit'; 1733 1734function callback(err: BusinessError, proxyObj: camera.DeferredPhotoProxy): void { 1735 proxyObj.getThumbnail().then((thumbnail: image.PixelMap) => { 1736 AppStorage.setOrCreate('proxyThumbnail', thumbnail); 1737 }); 1738} 1739 1740function unRegisterPhotoOutputDeferredPhotoProxyAvailable(photoOutput: camera.PhotoOutput): void { 1741 photoOutput.off('deferredPhotoProxyAvailable', callback); 1742} 1743``` 1744 1745### isQuickThumbnailSupported 1746 1747isQuickThumbnailSupported(): boolean 1748 1749是否支持输出快速缩略图。 1750 1751在[addOutput](js-apis-camera.md#addoutput11)、[addInput](js-apis-camera.md#addinput11)之后,[commitConfig](js-apis-camera.md#commitconfig11-1)之前生效。 1752 1753**系统接口:** 此接口为系统接口。 1754 1755**系统能力:** SystemCapability.Multimedia.Camera.Core 1756 1757**返回值:** 1758 1759| 类型 | 说明 | 1760| --------- | ------ | 1761| boolean | 返回支持情况,如果返回true表示支持,否则不支持。 | 1762 1763**错误码:** 1764 1765以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1766 1767| 错误码ID | 错误信息 | 1768| --------------- | --------------- | 1769| 202 | Not System Application. | 1770| 7400104 | session is not running. | 1771 1772**示例:** 1773 1774```ts 1775import { common } from '@kit.AbilityKit'; 1776 1777async function isQuickThumbnailSupported(context: common.BaseContext, mode: camera.SceneMode, photoProfile: camera.Profile): Promise<boolean> { 1778 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 1779 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 1780 // 创建CaptureSession实例 1781 let session: camera.Session = cameraManager.createSession(mode); 1782 // 开始配置会话 1783 session.beginConfig(); 1784 // 把CameraInput加入到会话 1785 let cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameras[0]); 1786 await cameraInput.open(); 1787 session.addInput(cameraInput); 1788 // 把photoOutput加入到会话 1789 let photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 1790 session.addOutput(photoOutput); 1791 let isSupported: boolean = photoOutput.isQuickThumbnailSupported(); 1792 return isSupported; 1793} 1794``` 1795 1796### enableQuickThumbnail 1797 1798enableQuickThumbnail(enabled: boolean): void 1799 1800启用/禁用快速缩略图。 1801 1802在[addOutput](js-apis-camera.md#addoutput11)、[addInput](js-apis-camera.md#addinput11)之后,[commitConfig](js-apis-camera.md#commitconfig11-1)之前生效。 1803 1804**系统接口:** 此接口为系统接口。 1805 1806**系统能力:** SystemCapability.Multimedia.Camera.Core 1807 1808**参数:** 1809 1810| 参数名 | 类型 | 必填 | 说明 | 1811| -------- | ------------- | ---- | ----------------------------------- | 1812| enabled | boolean | 是 | true:使能快速缩略图;false:去使能快速缩略图。 | 1813 1814**错误码:** 1815 1816以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1817 1818| 错误码ID | 错误信息 | 1819| --------------- | --------------- | 1820| 202 | Not System Application. | 1821| 7400101 | Parameter missing or parameter type incorrect. | 1822| 7400104 | session is not running. | 1823| 7400201 | Camera service fatal error. | 1824 1825**示例:** 1826 1827```ts 1828import { common } from '@kit.AbilityKit'; 1829import { BusinessError } from '@kit.BasicServicesKit'; 1830 1831async function enableQuickThumbnail(context: common.BaseContext, mode: camera.SceneMode, photoProfile: camera.Profile): Promise<void> { 1832 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 1833 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 1834 // 创建CaptureSession实例 1835 let session: camera.Session = cameraManager.createSession(mode); 1836 // 开始配置会话 1837 session.beginConfig(); 1838 // 把CameraInput加入到会话 1839 let cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameras[0]); 1840 await cameraInput.open(); 1841 session.addInput(cameraInput); 1842 // 把PhotoOutPut加入到会话 1843 let photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 1844 session.addOutput(photoOutput); 1845 let isSupported: boolean = photoOutput.isQuickThumbnailSupported(); 1846 if (!isSupported) { 1847 console.info('Quick Thumbnail is not supported to be turned on.'); 1848 return; 1849 } 1850 try { 1851 photoOutput.enableQuickThumbnail(true); 1852 } catch (error) { 1853 let err = error as BusinessError; 1854 console.error(`The enableQuickThumbnail call failed. error code: ${err.code}`); 1855 } 1856} 1857``` 1858 1859### on('quickThumbnail') 1860 1861on(type: 'quickThumbnail', callback: AsyncCallback\<image.PixelMap>): void 1862 1863监听快速缩略图输出事件。使用callback异步回调。 1864 1865在enableQuickThumbnail(true)使能快速缩略图之后监听生效。 1866 1867**系统接口:** 此接口为系统接口。 1868 1869**系统能力:** SystemCapability.Multimedia.Camera.Core 1870 1871**参数:** 1872 1873| 参数名 | 类型 | 必填 | 说明 | 1874| -------- | ------------- | ---- | ----------------------------------- | 1875| type | string | 是 | 监听事件,固定为'quickThumbnail'。 | 1876| callback | AsyncCallback\<[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)> | 是 | 回调返回PixelMap。 | 1877 1878**示例:** 1879 1880```ts 1881import { common } from '@kit.AbilityKit'; 1882import { BusinessError } from '@kit.BasicServicesKit'; 1883import { image } from '@kit.ImageKit'; 1884 1885function callback(err: BusinessError, pixelMap: image.PixelMap): void { 1886 if (err || pixelMap === undefined) { 1887 console.error('photoOutput on thumbnail failed'); 1888 return; 1889 } 1890 // 显示或保存pixelMap 1891 // do something 1892} 1893 1894async function registerQuickThumbnail(context: common.BaseContext, mode: camera.SceneMode, photoProfile: camera.Profile): Promise<void> { 1895 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 1896 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 1897 // 创建CaptureSession实例 1898 let session: camera.Session = cameraManager.createSession(mode); 1899 // 开始配置会话 1900 session.beginConfig(); 1901 // 把CameraInput加入到会话 1902 let cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameras[0]); 1903 await cameraInput.open(); 1904 session.addInput(cameraInput); 1905 // 把PhotoOutPut加入到会话 1906 let photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 1907 session.addOutput(photoOutput); 1908 let isSupported: boolean = photoOutput.isQuickThumbnailSupported(); 1909 if (!isSupported) { 1910 console.info('Quick Thumbnail is not supported to be turned on.'); 1911 return; 1912 } 1913 try { 1914 photoOutput.enableQuickThumbnail(true); 1915 } catch (error) { 1916 let err = error as BusinessError; 1917 console.error(`The enableQuickThumbnail call failed. error code: ${err.code}`); 1918 } 1919 1920 photoOutput.on('quickThumbnail', callback); 1921} 1922``` 1923 1924### off('quickThumbnail') 1925 1926off(type: 'quickThumbnail', callback?: AsyncCallback\<image.PixelMap>): void 1927 1928注销监听快速缩略图输出事件。 1929 1930**系统接口:** 此接口为系统接口。 1931 1932**系统能力:** SystemCapability.Multimedia.Camera.Core 1933 1934**参数:** 1935 1936| 参数名 | 类型 | 必填 | 说明 | 1937| -------- | ------------- | ---- | ----------------------------------- | 1938| type | string | 是 | 监听事件,固定为'quickThumbnail'。 | 1939| callback | AsyncCallback\<[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)> | 否 | 回调函数,可选,有就是匹配on('quickThumbnail') callback(callback对象不可是匿名函数)。 | 1940 1941**示例:** 1942 1943```ts 1944function unregisterQuickThumbnail(photoOutput: camera.PhotoOutput): void { 1945 photoOutput.off('quickThumbnail'); 1946} 1947``` 1948 1949## VideoOutput 1950 1951录像会话中使用的输出信息,继承[CameraOutput](js-apis-camera.md#cameraoutput)。 1952 1953### isMirrorSupported<sup>12+</sup> 1954 1955isMirrorSupported(): boolean 1956 1957查询当前设备是否支持视频镜像。 1958 1959**系统接口:** 此接口为系统接口。 1960 1961**系统能力:** SystemCapability.Multimedia.Camera.Core 1962 1963**返回值:** 1964 1965| 类型 | 说明 | 1966| -------------- | ----------------------- | 1967| boolean | 是否支持视频镜像。| 1968 1969**错误码:** 1970 1971以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1972 1973| 错误码ID | 错误信息 | 1974| --------------- | --------------- | 1975| 202 | Not System Application. | 1976 1977**示例:** 1978 1979```ts 1980import { BusinessError } from '@kit.BasicServicesKit'; 1981 1982function isMirrorSupported(videoOutput: camera.VideoOutput): boolean { 1983 return videoOutput.isMirrorSupported(); 1984} 1985``` 1986 1987### enableMirror<sup>12+</sup> 1988 1989enableMirror(enabled: boolean): void 1990 1991使能视频镜像。使能视频镜像之前,需要调用[isMirrorSupported](#ismirrorsupported12)判断当前是否支持。 1992 1993**系统接口:** 此接口为系统接口。 1994 1995**系统能力:** SystemCapability.Multimedia.Camera.Core 1996 1997**参数:** 1998 1999| 参数名 | 类型 | 必填 | 说明 | 2000| -------- | -------------------- | ---- | ------------------- | 2001| enabled | boolean | 是 | 是否使能视频镜像。 | 2002 2003**错误码:** 2004 2005以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2006 2007| 错误码ID | 错误信息 | 2008| --------------- | --------------- | 2009| 202 | Not System Application. | 2010| 7400101 | Parameter missing or parameter type incorrect. | 2011| 7400103 | Session not config. | 2012 2013**示例:** 2014 2015```ts 2016import { BusinessError } from '@kit.BasicServicesKit'; 2017 2018function enableMirror(videoOutput: camera.VideoOutput): void { 2019 return videoOutput.enableMirror(true); 2020} 2021``` 2022 2023## MetadataOutput 2024 2025metadata流。继承[CameraOutput](js-apis-camera.md#cameraoutput)。 2026 2027### addMetadataObjectTypes<sup>13+</sup> 2028 2029addMetadataObjectTypes(types: Array\<MetadataObjectType\>): void 2030 2031新增需要上报的检测对象类型。 2032 2033**系统能力:** SystemCapability.Multimedia.Camera.Core 2034 2035**参数:** 2036 2037| 参数名 | 类型 | 必填 | 说明 | 2038| -------------------- | -------------------------------------------------- | --- | ---------------------------- | 2039| metadataObjectTypes | Array\<[MetadataObjectType](#metadataobjecttype)\> | 是 | metadata流类型信息,通过getSupportedOutputCapability接口获取。 | 2040 2041**错误码:** 2042 2043以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2044 2045| 错误码ID | 错误信息 | 2046| --------------- | --------------- | 2047| 202 | Not system application. | 2048| 7400101 | Parameter missing or parameter type incorrect. | 2049| 7400103 | Session not config. | 2050| 7400201 | Camera service fatal error. | 2051 2052**示例:** 2053 2054```ts 2055import { BusinessError } from '@kit.BasicServicesKit'; 2056 2057function addMetadataObjectTypes(metadataOutput: camera.MetadataOutput, types: Array<camera.MetadataObjectType>): void { 2058 try { 2059 metadataOutput.addMetadataObjectTypes(types); 2060 } catch (error) { 2061 // 失败返回错误码error.code并处理 2062 let err = error as BusinessError; 2063 console.error(`addMetadataObjectTypes error. error code: ${err.code}`); 2064 } 2065} 2066``` 2067 2068### removeMetadataObjectTypes<sup>13+</sup> 2069 2070removeMetadataObjectTypes(types: Array\<MetadataObjectType\>): void 2071 2072删除需要上报的检测对象类型。 2073 2074**系统能力:** SystemCapability.Multimedia.Camera.Core 2075 2076**参数:** 2077 2078| 参数名 | 类型 | 必填 | 说明 | 2079| -------------------- | -------------------------------------------------- | --- | ---------------------------- | 2080| metadataObjectTypes | Array\<[MetadataObjectType](#metadataobjecttype)\> | 是 | metadata流类型信息,通过getSupportedOutputCapability接口获取。 | 2081 2082**错误码:** 2083 2084以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2085 2086| 错误码ID | 错误信息 | 2087| --------------- | --------------- | 2088| 202 | Not system application. | 2089| 7400101 | Parameter missing or parameter type incorrect. | 2090| 7400103 | Session not config. | 2091| 7400201 | Camera service fatal error. | 2092 2093**示例:** 2094 2095```ts 2096import { BusinessError } from '@kit.BasicServicesKit'; 2097 2098function removeMetadataObjectTypes(metadataOutput: camera.MetadataOutput, types: Array<camera.MetadataObjectType>): void { 2099 try { 2100 metadataOutput.removeMetadataObjectTypes(types); 2101 } catch (error) { 2102 // 失败返回错误码error.code并处理 2103 let err = error as BusinessError; 2104 console.error(`removeMetadataObjectTypes error. error code: ${err.code}`); 2105 } 2106} 2107``` 2108 2109## MetadataObjectType 2110 2111枚举,metadata元数据检测类型。 2112 2113**系统能力:** SystemCapability.Multimedia.Camera.Core 2114 2115| 名称 | 值 | 说明 | 2116| -------------------------- | ---- | ----------------- | 2117| HUMAN_BODY<sup>13+</sup> | 1 | 用于检测人体的metadata类型。 | 2118| CAT_FACE<sup>13+</sup> | 2 | 用于检测猫脸的metadata类型。 | 2119| CAT_BODY<sup>13+</sup> | 3 | 用于检测猫的身体的metadata类型。 | 2120| DOG_FACE<sup>13+</sup> | 4 | 用于检测狗脸的metadata类型。 | 2121| DOG_BODY<sup>13+</sup> | 5 | 用于检测狗的身体的metadata类型。 | 2122| SALIENT_DETECTION<sup>13+</sup> | 6 | 用于显著性检测。 | 2123 2124## Emotion<sup>13+</sup> 2125枚举,人脸检测信息中的情绪类型。 2126 2127**系统能力:** SystemCapability.Multimedia.Camera.Core 2128 2129| 名称 | 值 | 说明 | 2130| -------------------------- | ---- | ----------------- | 2131| NEUTRAL | 0 | 平静。 | 2132| SADNESS | 1 | 悲伤。 | 2133| SMILE | 2 | 微笑。 | 2134| SURPRISE | 3 | 惊讶。 | 2135 2136## MetadataObject 2137 2138相机检测元数据信息的基础类型,[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.on('metadataObjectsAvailable')接口获取。 2139 2140**系统能力:** SystemCapability.Multimedia.Camera.Core 2141 2142| 名称 | 类型 | 只读 | 可选 |说明 | 2143| ----------- | ------------------------------------------- | ---- | ---- | ----------------- | 2144| objectId<sup>13+</sup> | number | 是 | 否 | metadataObject Id序号。| 2145| confidence<sup>13+</sup> | number | 是 | 否 | 检测置信度,取值范围[0,1]。| 2146 2147## MetadataFaceObject<sup>13+</sup> 2148 2149相机检测到的人脸元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.on('metadataObjectsAvailable')接口获取。 2150 2151**系统能力:** SystemCapability.Multimedia.Camera.Core 2152 2153| 名称 | 类型 | 只读 | 可选 |说明 | 2154| ---------------------- | --------------------------------- | ---- | ---- | --------------------- | 2155| leftEyeBoundingBox | [Rect](js-apis-camera.md#rect) | 是 | 否 | 左眼区域框| 2156| rightEyeBoundingBox | [Rect](js-apis-camera.md#rect) | 是 | 否 | 右眼区域框。| 2157| emotion | [Emotion](#emotion13) | 是 | 否 | 检测到的情绪类型。| 2158| emotionConfidence | number | 是 | 否 | 情绪检测置信度,取值范围[0,1]。| 2159| pitchAngle | number | 是 | 否 | 俯仰角度,取值范围[-90, 90],以向下为正。| 2160| yawAngle | number | 是 | 否 | 左右旋转角度,取值范围[-90, 90],以向右为正。| 2161| rollAngle | number | 是 | 否 | 平面内旋转角度,取值范围[-180, 180],以顺时针方向为正。| 2162 2163## MetadataHumanBodyObject<sup>13+</sup> 2164 2165相机检测到的人体元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.on('metadataObjectsAvailable')接口获取。 2166 2167**系统能力:** SystemCapability.Multimedia.Camera.Core 2168 2169## MetadataCatFaceObject<sup>13+</sup> 2170 2171相机检测到的猫脸元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.on('metadataObjectsAvailable')接口获取。 2172 2173**系统能力:** SystemCapability.Multimedia.Camera.Core 2174 2175| 名称 | 类型 | 只读 | 可选 |说明 | 2176| ---------------------- | --------------------------------- | ---- | ---- | --------------------- | 2177| leftEyeBoundingBox | [Rect](js-apis-camera.md#rect) | 是 | 否 | 左眼区域框。| 2178| rightEyeBoundingBox | [Rect](js-apis-camera.md#rect) | 是 | 否 | 右眼区域框。| 2179 2180## MetadataCatBodyObject<sup>13+</sup> 2181 2182相机检测到的猫的身体元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.on('metadataObjectsAvailable')接口获取。 2183 2184**系统能力:** SystemCapability.Multimedia.Camera.Core 2185 2186## MetadataDogFaceObject<sup>13+</sup> 2187 2188相机检测到的狗脸元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.on('metadataObjectsAvailable')接口获取。 2189 2190**系统能力:** SystemCapability.Multimedia.Camera.Core 2191 2192| 名称 | 类型 | 只读 | 可选 |说明 | 2193| ---------------------- | --------------------------------- | ---- | ---- | --------------------- | 2194| leftEyeBoundingBox | [Rect](js-apis-camera.md#rect) | 是 | 否 | 左眼区域框。| 2195| rightEyeBoundingBox | [Rect](js-apis-camera.md#rect) | 是 | 否 | 右眼区域框。| 2196 2197## MetadataDogBodyObject<sup>13+</sup> 2198 2199相机检测到的狗的身体元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.on('metadataObjectsAvailable')接口获取。 2200 2201**系统能力:** SystemCapability.Multimedia.Camera.Core 2202 2203## MetadataSalientDetectionObject<sup>13+</sup> 2204 2205相机检测到的显著性元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.on('metadataObjectsAvailable')接口获取。 2206 2207**系统能力:** SystemCapability.Multimedia.Camera.Core 2208 2209## PortraitEffect 2210 2211人像效果类型。 2212 2213**系统接口:** 此接口为系统接口。 2214 2215**系统能力:** SystemCapability.Multimedia.Camera.Core 2216 2217| 名称 | 值 | 说明 | 2218| ----------------| ---- | ---------| 2219| OFF | 0 | 关闭。 | 2220| CIRCLES | 1 | 圆形。 | 2221| HEART<sup>11+</sup> | 2 | 心形。 | 2222| ROTATED<sup>11+</sup> | 3 | 旋焦。 | 2223| STUDIO<sup>11+</sup> | 4 | 影棚光。 | 2224| THEATER<sup>11+</sup> | 5 | 剧场光。 | 2225 2226## BeautyQuery<sup>12+</sup> 2227 2228提供了获取和设置美颜效果的方法。 2229 2230### getSupportedBeautyTypes<sup>12+</sup> 2231 2232getSupportedBeautyTypes(): Array\<BeautyType\> 2233 2234获取当前支持的美颜效果列表。 2235 2236**系统接口:** 此接口为系统接口。 2237 2238**系统能力:** SystemCapability.Multimedia.Camera.Core 2239 2240**返回值:** 2241 2242| 类型 | 说明 | 2243| ---------- | ----------------------------- | 2244| Array\<[BeautyType](#beautytype)\>| 返回当前支持的美颜效果列表。 | 2245 2246**错误码:** 2247 2248以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2249 2250| 错误码ID | 错误信息 | 2251| --------------- | --------------- | 2252| 202 | Not System Application. | 2253| 7400103 | Session not config. | 2254 2255**示例:** 2256 2257```ts 2258function getSupportedBeautyTypes(portraitPhotoSession: camera.PortraitPhotoSession): Array<camera.BeautyType> { 2259 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2260 return beautyTypes; 2261} 2262``` 2263 2264### getSupportedBeautyRange<sup>12+</sup> 2265 2266getSupportedBeautyRange(type: BeautyType): Array\<number\> 2267 2268获取指定美颜效果的范围值。在不同设备返回的美颜强度有所不同,下表仅做示例。 2269 2270| 传入参数 | 示例返回值 | 返回值说明 | 2271| ----------------| ---- | ---------| 2272| AUTO | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |美颜类型为自动时支持的美颜强度,0表明关闭美颜,其余正值表明自动的美颜强度。 | 2273| SKIN_SMOOTH | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | 美颜类型为光滑时支持的美颜强度,0表明关闭光滑,其余正值表明光滑的美颜强度。 | 2274| FACE_SLENDER | [0, 1, 2, 3, 4, 5] | 美颜类型为瘦脸时支持的美颜强度,0表明关闭瘦脸,其余正值表明瘦脸的美颜强度。 | 2275| SKIN_TONE | [-1, 16242611] | 美颜类型为美肤时支持的美颜强度,-1表明关闭美肤,其余非负值为使用RGB表示的美肤美颜强度,<br> 16242611转化为16进制为0xF7D7B3,F7为R通道值,D7为G通道值,B3位B通道值。 | 2276 2277**系统接口:** 此接口为系统接口。 2278 2279**系统能力:** SystemCapability.Multimedia.Camera.Core 2280 2281**参数:** 2282 2283| 参数名 | 类型 | 必填 | 说明 | 2284| -------- | --------------------------| ---- | ----------| 2285| type | [BeautyType](#beautytype) | 是 | 美颜类型。 | 2286 2287**返回值:** 2288 2289| 类型 | 说明 | 2290| ---------- | ----------------------------- | 2291| Array\<number\> | 当前美颜类型所支持的美颜强度。 | 2292 2293**错误码:** 2294 2295以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2296 2297| 错误码ID | 错误信息 | 2298| --------------- | --------------- | 2299| 202 | Not System Application. | 2300| 7400103 | Session not config. | 2301 2302**示例:** 2303 2304```ts 2305function getSupportedBeautyRange(portraitPhotoSession: camera.PortraitPhotoSession): Array<number> { 2306 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2307 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2308 return []; 2309 } 2310 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2311 return beautyLevels; 2312} 2313``` 2314 2315## BeautyType 2316 2317美颜类型。 2318 2319**系统接口:** 此接口为系统接口。 2320 2321**系统能力:** SystemCapability.Multimedia.Camera.Core 2322 2323| 名称 | 值 | 说明 | 2324| ----------------| ---- | ---------| 2325| AUTO | 0 | 自动。 | 2326| SKIN_SMOOTH | 1 | 光滑。 | 2327| FACE_SLENDER | 2 | 瘦脸。 | 2328| SKIN_TONE | 3 | 肤色。 | 2329 2330## ManualExposureQuery<sup>12+</sup> 2331 2332此接口提供了查询设备对手动曝光范围支持的功能。 2333 2334### getSupportedExposureRange<sup>12+</sup> 2335 2336getSupportedExposureRange(): Array\<number\> 2337 2338获取当前支持的手动曝光时长,单位ms。 2339 2340**系统接口:** 此接口为系统接口。 2341 2342**系统能力:** SystemCapability.Multimedia.Camera.Core 2343 2344**返回值:** 2345 2346| 类型 | 说明 | 2347| ---------- | ----------------------------- | 2348| Array\<number\>| 返回当前支持的手动曝光时长,单位ms。 | 2349 2350**错误码:** 2351 2352以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2353 2354| 错误码ID | 错误信息 | 2355| --------------- | --------------- | 2356| 202 | Not System Application. | 2357| 7400101 | Parameter missing or parameter type incorrect. | 2358| 7400103 | Session not config, only throw in session usage. | 2359 2360 **示例:** 2361 2362```ts 2363function getSupportedExposureRange(nightPhotoSession: camera.NightPhotoSession): Array<number> { 2364 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2365 return exposureRange; 2366} 2367``` 2368 2369## ManualExposure<sup>11+</sup> 2370 2371ManualExposure extends [ManualExposureQuery](#manualexposurequery12) 2372 2373提供了获取和设置曝光值的功能。 2374 2375### getExposure<sup>11+</sup> 2376 2377getExposure(): number 2378 2379查询当前已设置的手动曝光时长,单位为ms。 2380 2381**系统接口:** 此接口为系统接口。 2382 2383**系统能力:** SystemCapability.Multimedia.Camera.Core 2384 2385**返回值:** 2386| 参数名 | 类型 | 必填 | 说明 | 2387| -------- | ------------------------------------------------- | ---- | --------------------- | 2388| value | number | 是 | 手动曝光时长,单位为ms。 | 2389 2390**错误码:** 2391 2392以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2393 2394| 错误码ID | 错误信息 | 2395| --------------- | --------------- | 2396| 202 | Not System Application. | 2397| 7400101 | Parameter missing or parameter type incorrect. | 2398| 7400103 | Session not config. | 2399 2400**示例:** 2401 2402```ts 2403function getExposure(nightPhotoSession: camera.NightPhotoSession): number | undefined { 2404 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2405 if (exposureRange === undefined || exposureRange.length <= 0) { 2406 return undefined; 2407 } 2408 let exposure: number = nightPhotoSession.getExposure(); 2409 return exposure; 2410} 2411``` 2412 2413### setExposure<sup>11+</sup> 2414 2415setExposure(exposure: number): void 2416 2417设置手动曝光时长。[getSupportedExposureRange](#getsupportedexposurerange12)获取得到支持的手动曝光时长列表选取用户所需的时长下发,单位ms。 2418 2419**系统接口:** 此接口为系统接口。 2420 2421**系统能力:** SystemCapability.Multimedia.Camera.Core 2422 2423**参数:** 2424 2425| 参数名 | 类型 | 必填 | 说明 | 2426| -------- | --------------------------| ---- |-------------------------------------------------------------------------| 2427| value | number | 是 | 手动曝光时长,通过[getSupportedExposureRange](#getsupportedexposurerange12)接口获取。 | 2428 2429 **错误码:** 2430 2431| 错误码ID | 错误信息 | 2432| --------------- | --------------- | 2433| 202 | Not System Application. | 2434| 7400102 | Operation not allowed. | 2435| 7400103 | Session not config. | 2436 2437```ts 2438function setExposure(nightPhotoSession: camera.NightPhotoSession): void { 2439 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2440 if (exposureRange === undefined || exposureRange.length <= 0) { 2441 return; 2442 } 2443 nightPhotoSession.setExposure(exposureRange[0]); 2444} 2445``` 2446 2447## MacroQuery<sup>12+</sup> 2448 2449提供用于查询设备是否支持相机微距拍摄的方法。 2450 2451### isMacroSupported<sup>12+</sup> 2452 2453isMacroSupported(): boolean 2454 2455检测当前状态下是否支持微距能力,需要在CaptureSession调用[commitConfig](js-apis-camera.md#commitconfig11-1)之后进行调用。 2456 2457**系统接口:** 此接口为系统接口。 2458 2459**系统能力:** SystemCapability.Multimedia.Camera.Core 2460 2461**返回值:** 2462 2463| 类型 | 说明 | 2464| ---------- | ----------------------------- | 2465| boolean | 返回是否支持微距能力。 | 2466 2467**错误码:** 2468 2469以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2470 2471| 错误码ID | 错误信息 | 2472|---------|--------------------------| 2473| 202 | Not System Application. | 2474 2475**示例:** 2476 2477```ts 2478function isMacroSupported(photoSession: camera.PhotoSessionForSys): boolean { 2479 let isSupported: boolean = photoSession.isMacroSupported(); 2480 return isSupported; 2481} 2482``` 2483 2484## Macro<sup>11+</sup> 2485 2486Macro extends [MacroQuery](#macroquery12) 2487 2488提供了使能微距能力的接口。 2489 2490### enableMacro<sup>11+</sup> 2491 2492enableMacro(enabled: boolean): void 2493 2494使能当前的微距能力,需要在支持微距能力的情况下进行调用。 2495 2496**系统接口:** 此接口为系统接口。 2497 2498**系统能力:** SystemCapability.Multimedia.Camera.Core 2499 2500**参数:** 2501 2502| 参数名 | 类型 | 必填 | 说明 | 2503| -------- | -------------------- | ---- | -------------------- | 2504| enabled | boolean | 是 | true:开启微距能力,false:关闭微距能力。 | 2505 2506**错误码:** 2507 2508以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2509 2510| 错误码ID | 错误信息 | 2511|----------|--------------------------| 2512| 202 | Not System Application. | 2513| 7400102 | Operation not allowed. | 2514| 7400103 | Session not config. | 2515 2516**示例:** 2517 2518```ts 2519function enableMacro(photoSession: camera.PhotoSessionForSys): void { 2520 let isSupported: boolean = photoSession.isMacroSupported(); 2521 if (isSupported) { 2522 photoSession.enableMacro(true); 2523 } 2524} 2525``` 2526 2527## SceneFeatureType<sup>12+</sup> 2528 2529枚举,场景特性枚举。 2530 2531**系统能力:** SystemCapability.Multimedia.Camera.Core 2532 2533| 名称 | 值 | 说明 | 2534| ----------------------- | --------- | ------------ | 2535| MOON_CAPTURE_BOOST | 0 | 月亮场景。**系统接口:** 此接口为系统接口。 | 2536 2537## SceneFeatureDetectionResult<sup>12+</sup> 2538 2539场景检测结果信息。 2540 2541**系统能力:** SystemCapability.Multimedia.Camera.Core 2542 2543| 名称 | 类型 | 只读 | 必填 | 说明 | 2544| -------- | ---------- | -------- | -------- | ---------- | 2545| featureType | [SceneFeatureType](#scenefeaturetype12) | 是 | 是 | 特性类型。 | 2546| detected | boolean | 是 | 是 | 检测结果。true为检测到指定特性场景。 | 2547 2548## SceneDetection<sup>12+</sup> 2549 2550场景检测能力。 2551 2552### isSceneFeatureSupported<sup>12+</sup> 2553 2554isSceneFeatureSupported(type: SceneFeatureType): boolean 2555 2556查询是否支持指定特性。 2557 2558**系统接口:** 此接口为系统接口。 2559 2560**系统能力:** SystemCapability.Multimedia.Camera.Core 2561 2562**参数:** 2563 2564| 参数名 | 类型 | 必填 | 说明 | 2565|-------|-------------------------------------------|-----|-------------| 2566| type | [SceneFeatureType](#scenefeaturetype12) | 是 | 指定对应的场景特性。 | 2567 2568**返回值:** 2569 2570| 类型 | 说明 | 2571|-----------|--------------| 2572| boolean | 返回是否支持指定特性。 | 2573 2574**错误码:** 2575 2576以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2577 2578| 错误码ID | 错误信息 | 2579|---------|------------------------------------------------| 2580| 202 | Not System Application. | 2581| 7400101 | Parameter missing or parameter type incorrect. | 2582 2583**示例:** 2584 2585```ts 2586function isSceneFeatureSupported(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): boolean { 2587 let isSupported: boolean = photoSession.isSceneFeatureSupported(featureType); 2588 return isSupported; 2589} 2590``` 2591 2592### enableSceneFeature<sup>12+</sup> 2593 2594enableSceneFeature(type: SceneFeatureType, enabled: boolean): void 2595 2596使能指定特性,该接口应当在收到对应场景检测回调结果[SceneFeatureDetectionResult](#scenefeaturedetectionresult12)之后调用。 2597 2598**系统接口:** 此接口为系统接口。 2599 2600**系统能力:** SystemCapability.Multimedia.Camera.Core 2601 2602**参数:** 2603 2604| 参数名 | 类型 | 必填 | 说明 | 2605|---------|-------------------------------------------|-----|-----------------------------| 2606| type | [SceneFeatureType](#scenefeaturetype12) | 是 | 指定需要开启或关闭的特性。 | 2607| enabled | boolean | 是 | true表明开启指定特性,false表明关闭指定特性。 | 2608 2609**错误码:** 2610 2611以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2612 2613| 错误码ID | 错误信息 | 2614|---------|------------------------------------------------| 2615| 202 | Not System Application. | 2616| 7400101 | Parameter missing or parameter type incorrect. | 2617 2618**示例:** 2619 2620```ts 2621import { BusinessError } from '@kit.BasicServicesKit'; 2622 2623function enableSceneFeature(photoSession: camera.PhotoSessionForSys, cameraInput: camera.CameraInput, previewOutput: camera.PreviewOutput): void { 2624 photoSession.beginConfig(); 2625 photoSession.addInput(cameraInput); 2626 photoSession.addOutput(previewOutput); 2627 photoSession.commitConfig(); 2628 2629 photoSession.on('featureDetection', camera.SceneFeatureType.MOON_CAPTURE_BOOST, 2630 (err: BusinessError, statusObject: camera.SceneFeatureDetectionResult) => { 2631 if (err !== undefined && err.code !== 0) { 2632 console.error(`Callback Error, errorCode: ${err.code}`); 2633 return; 2634 } 2635 console.info( 2636 `on featureDetectionStatus featureType:${statusObject.featureType} detected:${statusObject.detected}`); 2637 if (statusObject.featureType === camera.SceneFeatureType.MOON_CAPTURE_BOOST) { 2638 try { 2639 photoSession.enableSceneFeature(statusObject.featureType, statusObject.detected); 2640 } catch (error) { 2641 let err = error as BusinessError; 2642 console.error(`The enableSceneFeature call failed. error code: ${err.code}`); 2643 } 2644 } 2645 }); 2646} 2647``` 2648 2649## ZoomPointInfo<sup>12+</sup> 2650 2651等效焦距信息。 2652 2653**系统接口:** 此接口为系统接口。 2654 2655**系统能力:** SystemCapability.Multimedia.Camera.Core 2656 2657| 名称 | 类型 | 只读 | 可选 | 说明 | 2658| -------- | ---------- | -------- |-----| ---------- | 2659| zoomRatio | number | 是 | 否 | 可变焦距比。 | 2660| equivalentFocalLength | number | 是 | 否 | 当前焦距比对应的等效焦距值。 | 2661 2662## ZoomQuery<sup>12+</sup> 2663 2664提供获取当前模式的等效焦距信息列表的方法。 2665 2666### getZoomPointInfos<sup>12+</sup> 2667 2668getZoomPointInfos(): Array\<ZoomPointInfo\> 2669 2670获取当前模式的等效焦距信息列表。 2671 2672**系统接口:** 此接口为系统接口。 2673 2674**系统能力:** SystemCapability.Multimedia.Camera.Core 2675 2676**返回值:** 2677 2678| 类型 | 说明 | 2679| ---------- | ----------------------------- | 2680| Array\<[ZoomPointInfo](#zoompointinfo12)\>| 获取当前模式的等效焦距信息列表。 | 2681 2682**错误码:** 2683 2684以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2685 2686| 错误码ID | 错误信息 | 2687| --------------- | --------------- | 2688| 202 | Not System Application. | 2689| 7400103 | Session not config. | 2690 2691**示例:** 2692 2693```ts 2694import { BusinessError } from '@kit.BasicServicesKit'; 2695 2696function getZoomPointInfos(): Array<ZoomPointInfo> { 2697 try { 2698 let zoomPointInfos: Array<ZoomPointInfo> = sessionExtendsZoom.getZoomPointInfos(); 2699 return zoomPointInfos; 2700 } catch (error) { 2701 // 失败返回错误码error.code并处理 2702 let err = error as BusinessError; 2703 console.error(`The getZoomPointInfos call failed. error code: ${err.code}`); 2704 } 2705} 2706``` 2707 2708## Zoom<sup>11+</sup> 2709 2710Zoom extend [ZoomQuery](#zoomquery12) 2711 2712提供了处理设备变焦效果的相关方法,包括获取当前的变焦比,设置变焦比率,以及通过平滑方法设置目标变焦比,以及一些开启和结束变焦的函数。 2713 2714### prepareZoom<sup>11+</sup> 2715 2716prepareZoom(): void 2717 2718通知底层准备变焦,如sensor上电。 2719 2720**系统接口:** 此接口为系统接口。 2721 2722**系统能力:** SystemCapability.Multimedia.Camera.Core 2723 2724**错误码:** 2725 2726以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2727 2728| 错误码ID | 错误信息 | 2729| --------------- | --------------- | 2730| 202 | Not System Application. | 2731| 7400103 | Session not config. | 2732 2733**示例:** 2734 2735```ts 2736import { BusinessError } from '@kit.BasicServicesKit'; 2737 2738function prepareZoom(sessionExtendsZoom: camera.Zoom): void { 2739 try { 2740 sessionExtendsZoom.prepareZoom(); 2741 } catch (error) { 2742 // 失败返回错误码error.code并处理 2743 let err = error as BusinessError; 2744 console.error(`The prepareZoom call failed. error code: ${err.code}`); 2745 } 2746} 2747``` 2748 2749### unprepareZoom<sup>11+</sup> 2750 2751unprepareZoom(): void 2752 2753通知底层离开变焦准备状态。 2754 2755**系统接口:** 此接口为系统接口。 2756 2757**系统能力:** SystemCapability.Multimedia.Camera.Core 2758 2759**错误码:** 2760 2761以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2762 2763| 错误码ID | 错误信息 | 2764| --------------- | --------------- | 2765| 202 | Not System Application. | 2766| 7400103 | Session not config. | 2767 2768**示例:** 2769 2770```ts 2771import { BusinessError } from '@kit.BasicServicesKit'; 2772 2773function unprepareZoom(sessionExtendsZoom: camera.Zoom): void { 2774 try { 2775 sessionExtendsZoom.unprepareZoom(); 2776 } catch (error) { 2777 // 失败返回错误码error.code并处理 2778 let err = error as BusinessError; 2779 console.error(`The unprepareZoom call failed. error code: ${err.code}`); 2780 } 2781} 2782``` 2783 2784## ZoomRange<sup>11+</sup> 2785 2786获取支持的变焦范围。变焦范围为[min, max),即包括最小值,不包括最大值。 2787 2788**系统接口:** 此接口为系统接口。 2789 2790**系统能力:** SystemCapability.Multimedia.Camera.Core 2791 2792| 名称 | 类型 | 只读 | 必填 | 说明 | 2793| -------- | ------------- |---- | ---- | -------------| 2794| min | number | 是 | N/A | 获取的可变焦距范围的最小值 | 2795| max | number | 是 | N/A | 获取的可变焦距范围的最大值。 | 2796 2797## Beauty<sup>11+</sup> 2798 2799Beauty extends [BeautyQuery](#beautyquery12) 2800 2801提供了获取和设置美颜效果的方法。 2802 2803### setBeauty<sup>11+</sup> 2804 2805setBeauty(type: BeautyType, value: number): void 2806 2807设置美颜类型以及对应的美颜强度。将通过[getSupportedBeautyTypes](#getsupportedbeautytypes12)获取得到的[BeautyType](#beautytype)都关闭,表明当前美颜关闭;若有一种美颜类型未关闭,表明当前美颜打开。 2808 2809**系统接口:** 此接口为系统接口。 2810 2811**系统能力:** SystemCapability.Multimedia.Camera.Core 2812 2813**参数:** 2814 2815| 参数名 | 类型 | 必填 | 说明 | 2816| -------- | --------------------------| ---- |-------------------------------------------------------------------| 2817| type | [BeautyType](#beautytype) | 是 | 美颜类型。 | 2818| value | number | 是 | 美颜强度,通过[getSupportedBeautyRange](#getsupportedbeautyrange12)接口获取。 | 2819 2820**错误码:** 2821 2822以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2823 2824| 错误码ID | 错误信息 | 2825| --------------- | --------------- | 2826| 202 | Not System Application. | 2827| 7400103 | Session not config. | 2828 2829**示例:** 2830 2831```ts 2832function setBeauty(portraitPhotoSession: camera.PortraitPhotoSession): void { 2833 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2834 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2835 return; 2836 } 2837 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2838 if (beautyLevels === undefined || beautyLevels.length <= 0) { 2839 return; 2840 } 2841 portraitPhotoSession.setBeauty(beautyTypes[0], beautyLevels[0]); 2842} 2843``` 2844 2845### getBeauty<sup>11+</sup> 2846 2847getBeauty(type: BeautyType): number 2848 2849查询当前已设置的美颜效果对应的美颜强度。 2850 2851**系统接口:** 此接口为系统接口。 2852 2853**系统能力:** SystemCapability.Multimedia.Camera.Core 2854 2855**参数:** 2856 2857| 参数名 | 类型 | 必填 | 说明 | 2858| -------- | ------------------------------------------------- | ---- | --------------------- | 2859| type | [BeautyType](#beautytype) | 是 | 美颜类型。 | 2860 2861**返回值:** 2862| 参数名 | 类型 | 必填 | 说明 | 2863| -------- | ------------------------------------------------- | ---- | --------------------- | 2864| value | number | 是 | 美颜强度。 | 2865 2866**错误码:** 2867 2868以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2869 2870| 错误码ID | 错误信息 | 2871| --------------- | --------------- | 2872| 202 | Not System Application. | 2873| 7400103 | Session not config. | 2874 2875**示例:** 2876 2877```ts 2878function getBeauty(portraitPhotoSession: camera.PortraitPhotoSession): number { 2879 const invalidValue: number = -1; 2880 let beautyTypes = portraitPhotoSession.getSupportedBeautyTypes(); 2881 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2882 return invalidValue; 2883 } 2884 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2885 if (beautyLevels === undefined || beautyLevels.length <= 0) { 2886 return invalidValue; 2887 } 2888 portraitPhotoSession.setBeauty(beautyTypes[0], beautyLevels[0]); 2889 let beautyLevel: number = portraitPhotoSession.getBeauty(beautyTypes[0]); 2890 return beautyLevel; 2891} 2892``` 2893 2894## ColorEffectQuery<sup>12+</sup> 2895 2896提供了一个查询设备支持的颜色效果类型的方法。 2897 2898### getSupportedColorEffects<sup>12+</sup> 2899 2900getSupportedColorEffects(): Array\<ColorEffectType\> 2901 2902获取支持的色彩效果类型列表。 2903 2904**系统接口:** 此接口为系统接口。 2905 2906**系统能力:** SystemCapability.Multimedia.Camera.Core 2907 2908**返回值:** 2909 2910| 类型 | 说明 | 2911| ----------------------------------------------- | ---------------------------- | 2912| Array<[ColorEffectType](#coloreffecttype11)> | 支持的色彩效果类型列表。 | 2913 2914**错误码:** 2915 2916以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2917 2918| 错误码ID | 错误信息 | 2919| --------------- | --------------- | 2920| 7400103 | Session not config. | 2921| 202 | Not System Application. | 2922 2923**示例:** 2924 2925```ts 2926function getSupportedColorEffects(session: camera.PhotoSessionForSys): Array<camera.ColorEffectType> { 2927 let colorEffects: Array<camera.ColorEffectType> = session.getSupportedColorEffects(); 2928 return colorEffects; 2929} 2930``` 2931 2932## ColorEffect<sup>11+</sup> 2933 2934ColorEffect extends [ColorEffectQuery](#coloreffectquery12) 2935 2936提供了获取和设置镜头色彩效果的相关功能。 2937 2938### setColorEffect<sup>11+</sup> 2939 2940setColorEffect(type: ColorEffectType): void 2941 2942设置色彩效果类型。可以先通过[getSupportedColorEffects](#getsupportedcoloreffects12)获取当前设备所支持的ColorEffects。 2943 2944**系统接口:** 此接口为系统接口。 2945 2946**系统能力:** SystemCapability.Multimedia.Camera.Core 2947 2948**参数:** 2949 2950| 参数名 | 类型 | 必填 | 说明 | 2951| ------------ |--------------------------------------------------------------- | -- | -------------------------- | 2952| type | [ColorEffectType](#coloreffecttype11) | 是 | 色彩效果类型,通过[getSupportedColorEffects](#getsupportedcoloreffects12)接口获取。 | 2953 2954**错误码:** 2955 2956以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2957 2958| 错误码ID | 错误信息 | 2959| --------------- | --------------- | 2960| 7400103 | Session not config. | 2961| 202 | Not System Application. | 2962 2963**示例:** 2964 2965```ts 2966function setColorEffect(session: camera.PhotoSessionForSys, colorEffect: camera.ColorEffectType): void { 2967 session.setColorEffect(colorEffect); 2968} 2969``` 2970 2971### getColorEffect<sup>11+</sup> 2972 2973getColorEffect(): ColorEffectType 2974 2975获取当前设置的色彩效果类型。 2976 2977**系统接口:** 此接口为系统接口。 2978 2979**系统能力:** SystemCapability.Multimedia.Camera.Core 2980 2981**返回值:** 2982 2983| 类型 | 说明 | 2984| ----------------------------------------------- | ---------------------------- | 2985| [ColorEffectType](#coloreffecttype11) | 当前设置的色彩效果类型。 | 2986 2987**错误码:** 2988 2989以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2990 2991| 错误码ID | 错误信息 | 2992| --------------- | --------------- | 2993| 7400103 | Session not config. | 2994| 202 | Not System Application. | 2995 2996**示例:** 2997 2998```ts 2999function getColorEffect(session: camera.PhotoSessionForSys): camera.ColorEffectType { 3000 let colorEffect: camera.ColorEffectType = session.getColorEffect(); 3001 return colorEffect; 3002} 3003``` 3004 3005## ColorEffectType<sup>11+</sup> 3006 3007枚举,色彩效果类型。 3008 3009**系统接口:** 此接口为系统接口。 3010 3011**系统能力:** SystemCapability.Multimedia.Camera.Core 3012 3013| 名称 | 值 | 说明 | 3014| --------------------- | ---- | --------- | 3015| NORMAL | 0 | 常规的色彩效果。 | 3016| BRIGHT | 1 | 明艳的色彩效果。 | 3017| SOFT | 2 | 柔和的色彩效果。 | 3018| BLACK_WHITE<sup>12+</sup> | 3 | 黑白色彩效果。 | 3019 3020## Portrait<sup>11+</sup> 3021 3022人像类,用于设置人像参数。 3023 3024### getSupportedPortraitEffects<sup>10+</sup> 3025 3026getSupportedPortraitEffects(): Array\<PortraitEffect\> 3027 3028获取支持的人像虚化效果列表。 3029 3030**系统接口:** 此接口为系统接口。 3031 3032**系统能力:** SystemCapability.Multimedia.Camera.Core 3033 3034**返回值:** 3035 3036| 类型 | 说明 | 3037| ----------------------------------------------- | ---------------------------- | 3038| Array<[PortraitEffect](#portraiteffect)> | 支持的人像虚化效果列表。 | 3039 3040**错误码:** 3041 3042以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3043 3044| 错误码ID | 错误信息 | 3045| --------------- | --------------- | 3046| 7400103 | Session not config. | 3047| 202 | Not System Application. | 3048 3049**示例:** 3050 3051```ts 3052function getSupportedPortraitEffects(portraitPhotoSession: camera.PortraitPhotoSession): Array<camera.PortraitEffect> { 3053 let portraitEffects: Array<camera.PortraitEffect> = portraitPhotoSession.getSupportedPortraitEffects(); 3054 return portraitEffects; 3055} 3056``` 3057 3058### setPortraitEffect<sup>10+</sup> 3059 3060setPortraitEffect(effect: PortraitEffect): void 3061 3062设置人像虚化效果。需要先检查设备是否支持人像虚化模式,可以通过[getSupportedPortraitEffects](#getsupportedportraiteffects10)获取当前设备所支持的PortraitEffects。 3063 3064**系统接口:** 此接口为系统接口。 3065 3066**系统能力:** SystemCapability.Multimedia.Camera.Core 3067 3068**参数:** 3069 3070| 参数名 | 类型 | 必填 | 说明 | 3071| ------------ |----------------------------- | -- | -------------------------- | 3072| effect | [PortraitEffect](#portraiteffect) | 是 | 人像虚化效果,通过[getSupportedPortraitEffects](#getsupportedportraiteffects10)接口获取。 | 3073 3074**错误码:** 3075 3076以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3077 3078| 错误码ID | 错误信息 | 3079| --------------- | --------------- | 3080| 7400103 | Session not config. | 3081| 202 | Not System Application. | 3082 3083**示例:** 3084 3085```ts 3086import { BusinessError } from '@kit.BasicServicesKit'; 3087 3088function setPortraitEffect(portraitPhotoSession: camera.PortraitPhotoSession, portraitEffects: Array<camera.PortraitEffect>): void { 3089 if (portraitEffects === undefined || portraitEffects.length <= 0) { 3090 return; 3091 } 3092 try { 3093 portraitPhotoSession.setPortraitEffect(portraitEffects[0]); 3094 } catch (error) { 3095 let err = error as BusinessError; 3096 console.error(`The setPortraitEffect call failed. error code: ${err.code}`); 3097 } 3098} 3099``` 3100 3101### getPortraitEffect<sup>10+</sup> 3102 3103getPortraitEffect(): PortraitEffect 3104 3105获取当前设置的人像虚化效果。 3106 3107**系统接口:** 此接口为系统接口。 3108 3109**系统能力:** SystemCapability.Multimedia.Camera.Core 3110 3111**返回值:** 3112 3113| 类型 | 说明 | 3114| ----------------------------------------------- | ---------------------------- | 3115| [PortraitEffect](#portraiteffect) | 当前设置的人像虚化效果。 | 3116 3117**错误码:** 3118 3119以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3120 3121| 错误码ID | 错误信息 | 3122| --------------- | --------------- | 3123| 7400103 | Session not config. | 3124| 202 | Not System Application. | 3125 3126**示例:** 3127 3128```ts 3129function getPortraitEffect(portraitPhotoSession: camera.PortraitPhotoSession): camera.PortraitEffect { 3130 let portraitEffect: camera.PortraitEffect = portraitPhotoSession.getPortraitEffect(); 3131 return portraitEffect; 3132} 3133``` 3134 3135## PhysicalAperture<sup>11+</sup> 3136 3137物理光圈信息。 3138 3139**系统接口:** 此接口为系统接口。 3140 3141**系统能力:** SystemCapability.Multimedia.Camera.Core 3142 3143| 名称 | 类型 | 只读 | 可选 | 说明 | 3144| ---------- | ------------------------- | ----- |-----| ----------------- | 3145| zoomRange | [ZoomRange](#zoomrange11) | 否 | 否 | 特定物理光圈的变焦范围。 | 3146| apertures | Array\<number\> | 否 | 否 | 支持的物理光圈列表。 | 3147 3148## Aperture<sup>11+</sup> 3149 3150光圈类,用于设置光圈参数。 3151 3152### getSupportedVirtualApertures<sup>11+</sup> 3153 3154getSupportedVirtualApertures(): Array\<number\> 3155 3156获取支持的虚拟光圈列表。 3157 3158**系统接口:** 此接口为系统接口。 3159 3160**系统能力:** SystemCapability.Multimedia.Camera.Core 3161 3162**返回值:** 3163 3164| 类型 | 说明 | 3165| ----------------------------------------------- | ---------------------------- | 3166| Array\<number\> | 支持的虚拟光圈列表。 | 3167 3168**错误码:** 3169 3170以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3171 3172| 错误码ID | 错误信息 | 3173| --------------- | --------------- | 3174| 7400103 | Session not config. | 3175| 202 | Not System Application. | 3176 3177**示例:** 3178 3179```ts 3180function getSupportedVirtualApertures(session: camera.PortraitPhotoSession): Array<number> { 3181 let virtualApertures: Array<number> = session.getSupportedVirtualApertures(); 3182 return virtualApertures; 3183} 3184``` 3185 3186### getVirtualAperture<sup>11+</sup> 3187 3188getVirtualAperture(): number 3189 3190获取当前设置的虚拟光圈值。 3191 3192**系统接口:** 此接口为系统接口。 3193 3194**系统能力:** SystemCapability.Multimedia.Camera.Core 3195 3196**返回值:** 3197 3198| 类型 | 说明 | 3199| ----------------------------------------------- | ---------------------------- | 3200| number | 当前设置的虚拟光圈值。 | 3201 3202**错误码:** 3203 3204以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3205 3206| 错误码ID | 错误信息 | 3207| --------------- | --------------- | 3208| 7400103 | Session not config. | 3209| 202 | Not System Application. | 3210 3211**示例:** 3212 3213```ts 3214function getVirtualAperture(session: camera.PortraitPhotoSession): number { 3215 let virtualAperture: number = session.getVirtualAperture(); 3216 return virtualAperture; 3217} 3218``` 3219 3220### setVirtualAperture<sup>11+</sup> 3221 3222setVirtualAperture(aperture: number): void 3223 3224设置虚拟光圈。可以线通过[getSupportedVirtualApertures](#getsupportedvirtualapertures11)获取当前设备所支持的虚拟光圈列表。 3225 3226**系统接口:** 此接口为系统接口。 3227 3228**系统能力:** SystemCapability.Multimedia.Camera.Core 3229 3230**参数:** 3231 3232| 参数名 | 类型 | 必填 | 说明 | 3233| ------------ |------------------------- | -- | -------------------------- | 3234| aperture | number | 是 | 虚拟光圈值,通过[getSupportedVirtualApertures](#getsupportedvirtualapertures11)接口获取。 | 3235 3236**错误码:** 3237 3238以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3239 3240| 错误码ID | 错误信息 | 3241| --------------- | --------------- | 3242| 7400103 | Session not config. | 3243| 202 | Not System Application. | 3244 3245**示例:** 3246 3247```ts 3248function setVirtualAperture(session: camera.PortraitPhotoSession, virtualAperture: number): void { 3249 session.setVirtualAperture(virtualAperture); 3250} 3251``` 3252 3253### getSupportedPhysicalApertures<sup>11+</sup> 3254 3255getSupportedPhysicalApertures(): Array\<PhysicalAperture\> 3256 3257获取支持的物理光圈列表。 3258 3259**系统接口:** 此接口为系统接口。 3260 3261**系统能力:** SystemCapability.Multimedia.Camera.Core 3262 3263**返回值:** 3264 3265| 类型 | 说明 | 3266| ----------------------------------------------- | ---------------------------- | 3267| Array<[PhysicalAperture](#physicalaperture11)> | 支持的物理光圈列表。 | 3268 3269**错误码:** 3270 3271以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3272 3273| 错误码ID | 错误信息 | 3274| --------------- | --------------- | 3275| 7400103 | Session not config. | 3276| 202 | Not System Application. | 3277 3278**示例:** 3279 3280```ts 3281function getSupportedPhysicalApertures(session: camera.PortraitPhotoSession): Array<camera.PhysicalAperture> { 3282 let physicalApertures: Array<camera.PhysicalAperture> = session.getSupportedPhysicalApertures(); 3283 return physicalApertures; 3284} 3285``` 3286 3287### getPhysicalAperture<sup>11+</sup> 3288 3289getPhysicalAperture(): number 3290 3291获取当前设置的物理光圈值。 3292 3293**系统接口:** 此接口为系统接口。 3294 3295**系统能力:** SystemCapability.Multimedia.Camera.Core 3296 3297**返回值:** 3298 3299| 类型 | 说明 | 3300| -------------------- | ---------------------------- | 3301| number | 当前设置的物理光圈值。 | 3302 3303**错误码:** 3304 3305以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3306 3307| 错误码ID | 错误信息 | 3308| --------------- | --------------- | 3309| 7400103 | Session not config. | 3310| 202 | Not System Application. | 3311 3312**示例:** 3313 3314```ts 3315function getPhysicalAperture(session: camera.PortraitPhotoSession): number { 3316 let physicalAperture: number = session.getPhysicalAperture(); 3317 return physicalAperture; 3318} 3319``` 3320 3321### setPhysicalAperture<sup>11+</sup> 3322 3323setPhysicalAperture(aperture: number): void 3324 3325设置物理光圈。可以线通过[getSupportedPhysicalApertures](#getsupportedphysicalapertures11)获取当前设备所支持的物理光圈列表。 3326 3327**系统接口:** 此接口为系统接口。 3328 3329**系统能力:** SystemCapability.Multimedia.Camera.Core 3330 3331**参数:** 3332 3333| 参数名 | 类型 | 必填 | 说明 | 3334| ------------ |------------------------- | -- | -------------------------- | 3335| aperture | number | 是 | 物理光圈值,通过[getSupportedPhysicalApertures](#getsupportedphysicalapertures11)接口获取。 | 3336 3337**错误码:** 3338 3339以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3340 3341| 错误码ID | 错误信息 | 3342| --------------- | --------------- | 3343| 7400103 | Session not config. | 3344| 202 | Not System Application. | 3345 3346**示例:** 3347 3348```ts 3349function setPhysicalAperture(session: camera.PortraitPhotoSession, physicalAperture: number): void { 3350 session.setPhysicalAperture(physicalAperture); 3351} 3352``` 3353 3354## CaptureSession<sup>(deprecated)</sup> 3355 3356拍照会话类,保存一次相机运行所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput),并向相机设备申请完成相机功能(录像,拍照)。 3357 3358> **说明:** 3359>从 API version 10开始支持,从API version 11开始废弃。建议使用[PhotoSession](#photosession11)、[VideoSession](#videosession11)替代。 3360 3361### getSupportedBeautyTypes<sup>(deprecated)</sup> 3362 3363getSupportedBeautyTypes(): Array\<BeautyType> 3364 3365获取当前支持的美颜效果列表。 3366 3367> **说明:** 3368>从 API version 10开始支持,从API version 11开始废弃。建议使用[Beauty.getSupportedBeautyTypes](#getsupportedbeautytypes12)替代。 3369 3370**系统接口:** 此接口为系统接口。 3371 3372**系统能力:** SystemCapability.Multimedia.Camera.Core 3373 3374**返回值:** 3375 3376| 类型 | 说明 | 3377| ---------- | ----------------------------- | 3378| Array\<[BeautyType](#beautytype)\>| 返回当前支持的美颜效果列表。 | 3379 3380**错误码:** 3381 3382以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3383 3384| 错误码ID | 错误信息 | 3385| --------------- | --------------- | 3386| 7400103 | Session not config. | 3387 3388**示例:** 3389 3390```ts 3391function getSupportedBeautyTypes(captureSession: camera.CaptureSession): Array<camera.BeautyType> { 3392 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3393 return beautyTypes; 3394} 3395``` 3396 3397### getSupportedBeautyRange<sup>(deprecated)</sup> 3398 3399getSupportedBeautyRange(type: BeautyType): Array\<number\> 3400 3401获取指定美颜效果的范围值。在不同设备返回的美颜强度有所不同,下表仅做示例。 3402 3403| 传入参数 | 示例返回值 | 返回值说明 | 3404| ----------------| ---- | ---------| 3405| AUTO | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |美颜类型为自动时支持的美颜强度,0表明关闭美颜,其余正值表明自动的美颜强度。 | 3406| SKIN_SMOOTH | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | 美颜类型为光滑时支持的美颜强度,0表明关闭光滑,其余正值表明光滑的美颜强度。 | 3407| FACE_SLENDER | [0, 1, 2, 3, 4, 5] | 美颜类型为瘦脸时支持的美颜强度,0表明关闭瘦脸,其余正值表明瘦脸的美颜强度。 | 3408| SKIN_TONE | [-1, 16242611] | 美颜类型为美肤时支持的美颜强度,-1表明关闭美肤,其余非负值为使用RGB表示的美肤美颜强度,<br> 16242611转化为16进制为0xF7D7B3,F7为R通道值,D7为G通道值,B3位B通道值。 | 3409 3410> **说明:** 3411>从 API version 10开始支持,从API version 11开始废弃。建议使用[Beauty.getSupportedBeautyRange](#getsupportedbeautyrange12)替代。 3412 3413**系统接口:** 此接口为系统接口。 3414 3415**系统能力:** SystemCapability.Multimedia.Camera.Core 3416 3417**参数:** 3418 3419| 参数名 | 类型 | 必填 | 说明 | 3420| -------- | --------------------------| ---- | ----------| 3421| type | [BeautyType](#beautytype) | 是 | 美颜类型。 | 3422 3423**返回值:** 3424 3425| 类型 | 说明 | 3426| ---------- | ----------------------------- | 3427| Array\<number\> | 当前美颜类型所支持的美颜强度。 | 3428 3429**错误码:** 3430 3431以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3432 3433| 错误码ID | 错误信息 | 3434| --------------- | --------------- | 3435| 7400103 | Session not config. | 3436 3437**示例:** 3438 3439```ts 3440function getSupportedBeautyRange(captureSession: camera.CaptureSession): Array<number> { 3441 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3442 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3443 return []; 3444 } 3445 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3446 return beautyLevels; 3447} 3448``` 3449 3450### setBeauty<sup>(deprecated)</sup> 3451 3452setBeauty(type: BeautyType, value: number): void 3453 3454设置美颜类型以及对应的美颜强度。将通过[getSupportedBeautyTypes](#getsupportedbeautytypesdeprecated)获取得到的[BeautyType](#beautytype)都关闭,表明当前美颜关闭;若有一种美颜类型未关闭,表明当前美颜打开。 3455 3456> **说明:** 3457>从 API version 10开始支持,从API version 11开始废弃。建议使用[Beauty.setBeauty](#setbeauty11)替代。 3458 3459**系统接口:** 此接口为系统接口。 3460 3461**系统能力:** SystemCapability.Multimedia.Camera.Core 3462 3463**参数:** 3464 3465| 参数名 | 类型 | 必填 | 说明 | 3466| -------- | --------------------------| ---- | --------------------- | 3467| type | [BeautyType](#beautytype) | 是 | 美颜类型 。 | 3468| value | number | 是 | 美颜强度,通过[getSupportedBeautyRange](#getsupportedbeautyrangedeprecated)接口获取。| 3469 3470**错误码:** 3471 3472以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3473 3474| 错误码ID | 错误信息 | 3475| --------------- | --------------- | 3476| 7400103 | Session not config. | 3477 3478**示例:** 3479 3480```ts 3481function setBeauty(captureSession: camera.CaptureSession): void { 3482 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3483 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3484 return; 3485 } 3486 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3487 if (beautyLevels === undefined || beautyLevels.length <= 0) { 3488 return; 3489 } 3490 captureSession.setBeauty(beautyTypes[0], beautyLevels[0]); 3491} 3492``` 3493 3494### getBeauty<sup>(deprecated)</sup> 3495 3496getBeauty(type: BeautyType): number 3497 3498查询当前已设置的美颜效果对应的美颜强度。 3499 3500> **说明:** 3501>从 API version 10开始支持,从API version 11开始废弃。建议使用[Beauty.getBeauty](#getbeauty11)替代。 3502 3503**系统接口:** 此接口为系统接口。 3504 3505**系统能力:** SystemCapability.Multimedia.Camera.Core 3506 3507**参数:** 3508 3509| 参数名 | 类型 | 必填 | 说明 | 3510| -------- | ------------------------------------------------- | ---- | --------------------- | 3511| type | [BeautyType](#beautytype) | 是 | 美颜类型。 | 3512 3513**返回值:** 3514| 参数名 | 类型 | 必填 | 说明 | 3515| -------- | ------------------------------------------------- | ---- | --------------------- | 3516| value | number | 是 | 美颜强度。 | 3517 3518**错误码:** 3519 3520以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3521 3522| 错误码ID | 错误信息 | 3523| --------------- | --------------- | 3524| 7400103 | Session not config. | 3525 3526**示例:** 3527 3528```ts 3529function getBeauty(captureSession: camera.CaptureSession): number { 3530 const invalidValue: number = -1; 3531 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3532 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3533 return invalidValue; 3534 } 3535 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3536 if (beautyLevels === undefined || beautyLevels.length <= 0) { 3537 return invalidValue; 3538 } 3539 captureSession.setBeauty(beautyTypes[0], beautyLevels[0]); 3540 let beautyLevel: number = captureSession.getBeauty(beautyTypes[0]); 3541 return beautyLevel; 3542} 3543``` 3544 3545## PhotoSessionForSys<sup>11+</sup> 3546 3547PhotoSessionForSys extends PhotoSession, Beauty, ColorEffect, ColorManagement, Macro, SceneDetection 3548 3549提供给系统应用的PhotoSession,普通拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置普通拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 3550 3551**系统接口:** 此接口为系统接口。 3552 3553**系统能力:** SystemCapability.Multimedia.Camera.Core 3554 3555## PhotoSession<sup>11+</sup> 3556 3557PhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorManagement 3558 3559普通拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置普通拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 3560 3561### on('macroStatusChanged')<sup>11+</sup> 3562 3563on(type: 'macroStatusChanged', callback: AsyncCallback\<boolean\>): void 3564 3565监听相机微距状态变化,通过注册回调函数获取结果。使用callback异步回调。 3566 3567**系统接口:** 此接口为系统接口。 3568 3569**系统能力:** SystemCapability.Multimedia.Camera.Core 3570 3571**参数:** 3572 3573| 参数名 | 类型 | 必填 | 说明 | 3574| -------- | ----------------------------------------- | ---- | ------------------------ | 3575| type | string | 是 | 监听事件,固定为'macroStatusChanged',session创建成功可监听。 | 3576| callback | AsyncCallback\<boolean\> | 是 | 回调函数,用于获取当前微距状态。 | 3577 3578**错误码:** 3579 3580以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3581 3582| 错误码ID | 错误信息 | 3583|-------|---------------------------| 3584| 202 | Not System Application. | 3585 3586**示例:** 3587 3588```ts 3589import { BusinessError } from '@kit.BasicServicesKit'; 3590 3591function callback(err: BusinessError, macroStatus: boolean): void { 3592 if (err !== undefined && err.code !== 0) { 3593 console.error(`Callback Error, errorCode: ${err.code}`); 3594 return; 3595 } 3596 console.info(`Macro state: ${macroStatus}`); 3597} 3598 3599function registerMacroStatusChanged(photoSession: camera.PhotoSession): void { 3600 photoSession.on('macroStatusChanged', callback); 3601} 3602``` 3603 3604### off('macroStatusChanged')<sup>11+</sup> 3605 3606off(type: 'macroStatusChanged', callback?: AsyncCallback\<boolean\>): void 3607 3608注销监听相机微距状态变化。 3609 3610**系统接口:** 此接口为系统接口。 3611 3612**系统能力:** SystemCapability.Multimedia.Camera.Core 3613 3614**参数:** 3615 3616| 参数名 | 类型 | 必填 | 说明 | 3617| -------- | ------------------------ | ---- | ------------------------ | 3618| type | string | 是 | 监听事件,固定为'macroStatusChanged',session创建成功可监听。| 3619| callback | AsyncCallback\<boolean\> | 否 | 回调函数,可选,有就是匹配on('macroStatusChanged') callback(callback对象不可是匿名函数)。 | 3620 3621**错误码:** 3622 3623以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3624 3625| 错误码ID | 错误信息 | 3626|-------|---------------------------| 3627| 202 | Not System Application. | 3628 3629**示例:** 3630 3631```ts 3632function unregisterMacroStatusChanged(photoSession: camera.PhotoSession): void { 3633 photoSession.off('macroStatusChanged'); 3634} 3635``` 3636 3637### on('featureDetection')<sup>12+</sup> 3638 3639on(type: 'featureDetection', featureType: SceneFeatureType, callback: AsyncCallback\<SceneFeatureDetectionResult\>): void 3640 3641监听相机特性检测状态变化。使用callback异步回调。 3642 3643**系统接口:** 此接口为系统接口。 3644 3645**系统能力:** SystemCapability.Multimedia.Camera.Core 3646 3647**参数:** 3648 3649| 参数名 | 类型 | 必填 | 说明 | 3650| -------- | ----------------------------------------- | ---- | ------------------------ | 3651| type | string | 是 | 监听事件,固定为'featureDetection',photoSession创建成功可监听。 | 3652| featureType | [SceneFeatureType](#scenefeaturetype12) | 是 | 监听指定特性。 | 3653| callback | AsyncCallback\<[SceneFeatureDetectionResult](#scenefeaturedetectionresult12)\> | 是 | 回调函数,用于获取当前监听的特性的状态。 | 3654 3655**错误码:** 3656 3657以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3658 3659| 错误码ID | 错误信息 | 3660|-------|---------------------------| 3661| 202 | Not System Application. | 3662 3663**示例:** 3664 3665```ts 3666import { BusinessError } from '@kit.BasicServicesKit'; 3667 3668function callback(err: BusinessError, result: camera.SceneFeatureDetectionResult): void { 3669 if (err !== undefined && err.code !== 0) { 3670 console.error(`Callback Error, errorCode: ${err.code}`); 3671 return; 3672 } 3673 console.info(`feature type: ${result.featureType}`); 3674 console.info(`feature status: ${result.detected}`); 3675} 3676 3677function registerFeatureDetectionStatus(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): void { 3678 photoSession.on('featureDetection', featureType, callback); 3679} 3680``` 3681 3682### off('featureDetection')<sup>12+</sup> 3683 3684off(type: 'featureDetection', featureType: SceneFeatureType, callback?: AsyncCallback\<SceneFeatureDetectionResult\>): void 3685 3686注销监听相机特性检测状态变化。 3687 3688**系统接口:** 此接口为系统接口。 3689 3690**系统能力:** SystemCapability.Multimedia.Camera.Core 3691 3692**参数:** 3693 3694| 参数名 | 类型 | 必填 | 说明 | 3695| -------- | ------------------------ | ---- | ------------------------ | 3696| type | string | 是 | 监听事件,固定为'featureDetection',session创建成功可取消监听。| 3697| featureType | [SceneFeatureType](#scenefeaturetype12) | 是 | 指定特性。 | 3698| callback | AsyncCallback\<[SceneFeatureDetectionResult](#scenefeaturedetectionresult12)\> | 否 | 回调函数,可选,有就是匹配on('featureDetection') callback(callback对象不可是匿名函数)。 | 3699 3700**错误码:** 3701 3702以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3703 3704| 错误码ID | 错误信息 | 3705|-------|---------------------------| 3706| 202 | Not System Application. | 3707 3708**示例:** 3709 3710```ts 3711function unregisterFeatureDetectionStatus(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): void { 3712 photoSession.off('featureDetection', featureType); 3713} 3714``` 3715 3716## VideoSessionForSys<sup>11+</sup> 3717 3718VideoSessionForSys extends VideoSession, Beauty, ColorEffect, ColorManagement, Macro 3719 3720提供给系统应用的VideoSession,普通录像模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置普通录像模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 3721 3722**系统接口:** 此接口为系统接口。 3723 3724**系统能力:** SystemCapability.Multimedia.Camera.Core 3725 3726## VideoSession<sup>11+</sup> 3727 3728VideoSession extends Session, Flash, AutoExposure, Focus, Zoom, Stabilization, ColorManagement 3729 3730普通录像模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置普通录像模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 3731 3732### on('macroStatusChanged')<sup>11+</sup> 3733 3734on(type: 'macroStatusChanged', callback: AsyncCallback\<boolean\>): void 3735 3736监听相机微距状态变化,通过注册回调函数获取结果。使用callback异步回调。 3737 3738**系统接口:** 此接口为系统接口。 3739 3740**系统能力:** SystemCapability.Multimedia.Camera.Core 3741 3742**参数:** 3743 3744| 参数名 | 类型 | 必填 | 说明 | 3745| -------- | ----------------------------------------- | ---- | ------------------------ | 3746| type | string | 是 | 监听事件,固定为'macroStatusChanged',session创建成功可监听。 | 3747| callback | AsyncCallback\<boolean\> | 是 | 回调函数,用于获取当前微距状态。 | 3748 3749**错误码:** 3750 3751以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3752 3753| 错误码ID | 错误信息 | 3754|-------|---------------------------| 3755| 202 | Not System Application. | 3756 3757**示例:** 3758 3759```ts 3760import { BusinessError } from '@kit.BasicServicesKit'; 3761 3762function callback(err: BusinessError, macroStatus: boolean): void { 3763 if (err !== undefined && err.code !== 0) { 3764 console.error(`Callback Error, errorCode: ${err.code}`); 3765 return; 3766 } 3767 console.info(`Macro state: ${macroStatus}`); 3768} 3769 3770function registerMacroStatusChanged(videoSession: camera.VideoSession): void { 3771 videoSession.on('macroStatusChanged', callback); 3772} 3773``` 3774 3775### off('macroStatusChanged')<sup>11+</sup> 3776 3777off(type: 'macroStatusChanged', callback?: AsyncCallback\<boolean\>): void 3778 3779注销监听相机微距状态变化。 3780 3781**系统接口:** 此接口为系统接口。 3782 3783**系统能力:** SystemCapability.Multimedia.Camera.Core 3784 3785**参数:** 3786 3787| 参数名 | 类型 | 必填 | 说明 | 3788| -------- | ------------------------ | ---- | ------------------------ | 3789| type | string | 是 | 监听事件,固定为'macroStatusChanged',session创建成功可监听。| 3790| callback | AsyncCallback\<boolean\> | 否 | 回调函数,可选,有就是匹配on('macroStatusChanged') callback(callback对象不可是匿名函数)。 | 3791 3792**错误码:** 3793 3794以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3795 3796| 错误码ID | 错误信息 | 3797|-------|---------------------------| 3798| 202 | Not System Application. | 3799 3800**示例:** 3801 3802```ts 3803function unregisterMacroStatusChanged(videoSession: camera.VideoSession): void { 3804 videoSession.off('macroStatusChanged'); 3805} 3806``` 3807 3808## PortraitPhotoSession<sup>11+</sup> 3809 3810PortraitPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, Beauty, ColorEffect, ColorManagement, Portrait, Aperture 3811 3812人像拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置人像拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 3813 3814### on('error')<sup>11+</sup> 3815 3816on(type: 'error', callback: ErrorCallback): void 3817 3818监听人像拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 3819 3820**系统接口:** 此接口为系统接口。 3821 3822**系统能力:** SystemCapability.Multimedia.Camera.Core 3823 3824**参数:** 3825 3826| 参数名 | 类型 | 必填 | 说明 | 3827| -------- | --------------------------------- | ---- | ------------------------------ | 3828| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 3829| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 3830 3831**示例:** 3832 3833```ts 3834import { BusinessError } from '@kit.BasicServicesKit'; 3835 3836function callback(err: BusinessError): void { 3837 console.error(`Portrait photo session error code: ${err.code}`); 3838} 3839 3840function registerSessionError(portraitPhotoSession: camera.PortraitPhotoSession): void { 3841 portraitPhotoSession.on('error', callback); 3842} 3843``` 3844 3845### off('error')<sup>11+</sup> 3846 3847off(type: 'error', callback?: ErrorCallback): void 3848 3849注销监听人像拍照会话的错误事件,通过注册回调函数获取结果。 3850 3851**系统接口:** 此接口为系统接口。 3852 3853**系统能力:** SystemCapability.Multimedia.Camera.Core 3854 3855**参数:** 3856 3857| 参数名 | 类型 | 必填 | 说明 | 3858| -------- | -------------------------- | ---- | ------------------------------ | 3859| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 3860| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匹配on('error') callback(callback对象不可是匿名函数)。 | 3861 3862**示例:** 3863 3864```ts 3865function unregisterSessionError(portraitPhotoSession: camera.PortraitPhotoSession): void { 3866 portraitPhotoSession.off('error'); 3867} 3868``` 3869 3870### on('focusStateChange')<sup>11+</sup> 3871 3872on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 3873 3874监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 3875 3876**系统接口:** 此接口为系统接口。 3877 3878**系统能力:** SystemCapability.Multimedia.Camera.Core 3879 3880**参数:** 3881 3882| 参数名 | 类型 | 必填 | 说明 | 3883| -------- | ---------------- | ---- | ------------------------ | 3884| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 3885| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 3886 3887**示例:** 3888 3889```ts 3890import { BusinessError } from '@kit.BasicServicesKit'; 3891 3892function callback(err: BusinessError, focusState: camera.FocusState): void { 3893 if (err !== undefined && err.code !== 0) { 3894 console.error(`Callback Error, errorCode: ${err.code}`); 3895 return; 3896 } 3897 console.info(`Focus state: ${focusState}`); 3898} 3899 3900function registerFocusStateChange(portraitPhotoSession: camera.PortraitPhotoSession): void { 3901 portraitPhotoSession.on('focusStateChange', callback); 3902} 3903``` 3904 3905### off('focusStateChange')<sup>11+</sup> 3906 3907off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 3908 3909注销监听相机对焦的状态变化。 3910 3911**系统接口:** 此接口为系统接口。 3912 3913**系统能力:** SystemCapability.Multimedia.Camera.Core 3914 3915**参数:** 3916 3917| 参数名 | 类型 | 必填 | 说明 | 3918| -------- | ----------------------------------------- | ---- | ------------------------ | 3919| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 3920| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 3921 3922**示例:** 3923 3924```ts 3925function unregisterFocusStateChange(portraitPhotoSession: camera.PortraitPhotoSession): void { 3926 portraitPhotoSession.off('focusStateChange'); 3927} 3928``` 3929 3930### on('smoothZoomInfoAvailable')<sup>11+</sup> 3931 3932on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 3933 3934监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 3935 3936**系统接口:** 此接口为系统接口。 3937 3938**系统能力:** SystemCapability.Multimedia.Camera.Core 3939 3940**参数:** 3941 3942| 参数名 | 类型 | 必填 | 说明 | 3943| -------- | ----------------------- | ---- | ------------------------ | 3944| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 3945| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 3946 3947**示例:** 3948 3949```ts 3950import { BusinessError } from '@kit.BasicServicesKit'; 3951 3952function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 3953 if (err !== undefined && err.code !== 0) { 3954 console.error(`Callback Error, errorCode: ${err.code}`); 3955 return; 3956 } 3957 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 3958} 3959 3960function registerSmoothZoomInfo(portraitPhotoSession: camera.PortraitPhotoSession): void { 3961 portraitPhotoSession.on('smoothZoomInfoAvailable', callback); 3962} 3963``` 3964 3965### off('smoothZoomInfoAvailable')<sup>11+</sup> 3966 3967off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 3968 3969注销监听相机平滑变焦的状态变化。 3970 3971**系统接口:** 此接口为系统接口。 3972 3973**系统能力:** SystemCapability.Multimedia.Camera.Core 3974 3975**参数:** 3976 3977| 参数名 | 类型 | 必填 | 说明 | 3978| -------- | ----------------------------------------- | ---- | ------------------------ | 3979| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 3980| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,可选,有就是匹配on('smoothZoomInfoAvailable') callback(callback对象不可是匿名函数)。 | 3981 3982**示例:** 3983 3984```ts 3985function unregisterSmoothZoomInfo(portraitPhotoSession: camera.PortraitPhotoSession): void { 3986 portraitPhotoSession.off('smoothZoomInfoAvailable'); 3987} 3988``` 3989 3990## NightPhotoSession<sup>11+</sup> 3991 3992NightPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ColorManagement, ManualExposure 3993 3994夜景拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置夜景拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 3995 3996### on('error')<sup>11+</sup> 3997 3998on(type: 'error', callback: ErrorCallback): void 3999 4000监听夜景拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 4001 4002**系统接口:** 此接口为系统接口。 4003 4004**系统能力:** SystemCapability.Multimedia.Camera.Core 4005 4006**参数:** 4007 4008| 参数名 | 类型 | 必填 | 说明 | 4009| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 4010| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 4011| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 4012 4013**示例:** 4014 4015```ts 4016import { BusinessError } from '@kit.BasicServicesKit'; 4017 4018function callback(err: BusinessError): void { 4019 console.error(`Night photo session error code: ${err.code}`); 4020} 4021 4022function registerSessionError(nightPhotoSession: camera.NightPhotoSession): void { 4023 nightPhotoSession.on('error', callback); 4024} 4025``` 4026 4027### off('error')<sup>11+</sup> 4028 4029off(type: 'error', callback?: ErrorCallback): void 4030 4031注销监听夜景拍照会话的错误事件,通过注册回调函数获取结果。 4032 4033**系统接口:** 此接口为系统接口。 4034 4035**系统能力:** SystemCapability.Multimedia.Camera.Core 4036 4037**参数:** 4038 4039| 参数名 | 类型 | 必填 | 说明 | 4040| -------- | ------------------------ | ---- | ------------------------------ | 4041| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 4042| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匹配on('error') callback(callback对象不可是匿名函数)。 | 4043 4044**示例:** 4045 4046```ts 4047function unregisterSessionError(nightPhotoSession: camera.NightPhotoSession): void { 4048 nightPhotoSession.off('error'); 4049} 4050``` 4051 4052### on('focusStateChange')<sup>11+</sup> 4053 4054on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4055 4056监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4057 4058**系统接口:** 此接口为系统接口。 4059 4060**系统能力:** SystemCapability.Multimedia.Camera.Core 4061 4062**参数:** 4063 4064| 参数名 | 类型 | 必填 | 说明 | 4065| -------- | ---------------- | ---- | ------------------------ | 4066| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 4067| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 4068 4069**示例:** 4070 4071```ts 4072import { BusinessError } from '@kit.BasicServicesKit'; 4073 4074function callback(err: BusinessError, focusState: camera.FocusState): void { 4075 if (err !== undefined && err.code !== 0) { 4076 console.error(`Callback Error, errorCode: ${err.code}`); 4077 return; 4078 } 4079 console.info(`Focus state: ${focusState}`); 4080} 4081 4082function registerFocusStateChange(nightPhotoSession: camera.NightPhotoSession): void { 4083 nightPhotoSession.on('focusStateChange', callback); 4084} 4085``` 4086 4087### off('focusStateChange')<sup>11+</sup> 4088 4089off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4090 4091注销监听相机对焦的状态变化。 4092 4093**系统接口:** 此接口为系统接口。 4094 4095**系统能力:** SystemCapability.Multimedia.Camera.Core 4096 4097**参数:** 4098 4099| 参数名 | 类型 | 必填 | 说明 | 4100| -------- | ----------------------------------------- | ---- | ------------------------ | 4101| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 4102| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 4103 4104**示例:** 4105 4106```ts 4107function unregisterFocusStateChange(nightPhotoSession: camera.NightPhotoSession): void { 4108 nightPhotoSession.off('focusStateChange'); 4109} 4110``` 4111 4112### on('smoothZoomInfoAvailable')<sup>11+</sup> 4113 4114on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 4115 4116监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4117 4118**系统接口:** 此接口为系统接口。 4119 4120**系统能力:** SystemCapability.Multimedia.Camera.Core 4121 4122**参数:** 4123 4124| 参数名 | 类型 | 必填 | 说明 | 4125| -------- | ----------------------- | ---- | ------------------------ | 4126| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4127| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 4128 4129**示例:** 4130 4131```ts 4132import { BusinessError } from '@kit.BasicServicesKit'; 4133 4134function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 4135 if (err !== undefined && err.code !== 0) { 4136 console.error(`Callback Error, errorCode: ${err.code}`); 4137 return; 4138 } 4139 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 4140} 4141 4142function registerSmoothZoomInfo(nightPhotoSession: camera.NightPhotoSession): void { 4143 nightPhotoSession.on('smoothZoomInfoAvailable', callback); 4144} 4145``` 4146 4147### off('smoothZoomInfoAvailable')<sup>11+</sup> 4148 4149off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 4150 4151注销监听相机平滑变焦的状态变化。 4152 4153**系统接口:** 此接口为系统接口。 4154 4155**系统能力:** SystemCapability.Multimedia.Camera.Core 4156 4157**参数:** 4158 4159| 参数名 | 类型 | 必填 | 说明 | 4160| -------- | ----------------------------------------- | ---- | ------------------------ | 4161| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4162| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,可选,有就是匹配on('smoothZoomInfoAvailable') callback(callback对象不可是匿名函数)。 | 4163 4164**示例:** 4165 4166```ts 4167function unregisterSmoothZoomInfo(nightPhotoSession: camera.NightPhotoSession): void { 4168 nightPhotoSession.off('smoothZoomInfoAvailable'); 4169} 4170``` 4171 4172### on('lcdFlashStatus')<sup>12+</sup> 4173 4174on(type: 'lcdFlashStatus', callback: AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\>): void 4175 4176监听lcd flash状态,通过注册回调函数获取结果。使用callback异步回调。 4177 4178**系统接口:** 此接口为系统接口。 4179 4180**系统能力:** SystemCapability.Multimedia.Camera.Core 4181 4182**参数:** 4183 4184| 参数名 | 类型 | 必填 | 说明 | 4185| -------- | ----------------------- | ---- | ------------------------ | 4186| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可监听。| 4187| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 是 | 回调函数,用于获取当前lcd flash状态。 | 4188 4189**错误码:** 4190 4191以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4192 4193| 错误码ID | 错误信息 | 4194|-------|---------------------------| 4195| 202 | Not System Application. | 4196 4197**示例:** 4198 4199```ts 4200import { BusinessError } from '@kit.BasicServicesKit'; 4201 4202function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 4203 if (err !== undefined && err.code !== 0) { 4204 console.error(`Callback Error, errorCode: ${err.code}`); 4205 return; 4206 } 4207 console.info(`lcdFlashStatus: ${lcdFlashStatus}`); 4208} 4209 4210function registerLcdFlashStatus(nightPhotoSession: camera.NightPhotoSession): void { 4211 nightPhotoSession.on('lcdFlashStatus', callback); 4212} 4213``` 4214 4215### off('lcdFlashStatus')<sup>12+</sup> 4216 4217off(type: 'lcdFlashStatus', callback?: AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\>): void 4218 4219注销lcd flash状态,通过注册回调函数获取结果。 4220 4221**系统接口:** 此接口为系统接口。 4222 4223**系统能力:** SystemCapability.Multimedia.Camera.Core 4224 4225**参数:** 4226 4227| 参数名 | 类型 | 必填 | 说明 | 4228| -------- | ----------------------------------------- | ---- | ------------------------ | 4229| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可监听。| 4230| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 否 | 回调函数,可选,有就是匹配on('lcdFlashStatus') callback(callback对象不可是匿名函数)。 | 4231 4232**错误码:** 4233 4234以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4235 4236| 错误码ID | 错误信息 | 4237|-------|---------------------------| 4238| 202 | Not System Application. | 4239 4240**示例:** 4241 4242```ts 4243function unregisterLcdFlashStatus(nightPhotoSession: camera.NightPhotoSession): void { 4244 nightPhotoSession.off('lcdFlashStatus'); 4245} 4246``` 4247 4248## HighResolutionPhotoSession<sup>12+</sup> 4249 4250HighResolutionPhotoSession extends Session, AutoExposure, Focus 4251 4252高像素拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置高像素拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 4253 4254### on('error')<sup>12+</sup> 4255 4256on(type: 'error', callback: ErrorCallback): void 4257 4258监听高像素拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 4259 4260**系统接口:** 此接口为系统接口。 4261 4262**系统能力:** SystemCapability.Multimedia.Camera.Core 4263 4264**参数:** 4265 4266| 参数名 | 类型 | 必填 | 说明 | 4267| -------- | --------------------------------- | ---- | ------------------------------ | 4268| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 4269| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 4270 4271**错误码:** 4272 4273以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4274 4275| 错误码ID | 错误信息 | 4276| --------------- | --------------- | 4277| 202 | Not System Application. | 4278 4279**示例:** 4280 4281```ts 4282import { BusinessError } from '@kit.BasicServicesKit'; 4283 4284function callback(err: BusinessError): void { 4285 console.error(`High resolution photo session error code: ${err.code}`); 4286} 4287 4288function registerSessionError(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4289 highResolutionPhotoSession.on('error', callback); 4290} 4291``` 4292### off('error')<sup>12+</sup> 4293 4294off(type: 'error', callback?: ErrorCallback): void 4295 4296注销监听高像素拍照会话的错误事件,通过注册回调函数获取结果。 4297 4298**系统接口:** 此接口为系统接口。 4299 4300**系统能力:** SystemCapability.Multimedia.Camera.Core 4301 4302**参数:** 4303 4304| 参数名 | 类型 | 必填 | 说明 | 4305| -------- | ------------------------ | ---- | ------------------------------ | 4306| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 4307| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匹配on('error') callback(callback对象不可是匿名函数)。 | 4308 4309**错误码:** 4310 4311以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4312 4313| 错误码ID | 错误信息 | 4314| --------------- | --------------- | 4315| 202 | Not System Application. | 4316 4317**示例:** 4318 4319```ts 4320function unregisterSessionError(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4321 highResolutionPhotoSession.off('error'); 4322} 4323``` 4324 4325### on('focusStateChange')<sup>12+</sup> 4326 4327on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4328 4329监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4330 4331**系统接口:** 此接口为系统接口。 4332 4333**系统能力:** SystemCapability.Multimedia.Camera.Core 4334 4335**参数:** 4336 4337| 参数名 | 类型 | 必填 | 说明 | 4338| -------- | ---------------- | ---- | ------------------------ | 4339| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 4340| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 4341 4342**错误码:** 4343 4344以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4345 4346| 错误码ID | 错误信息 | 4347| --------------- | --------------- | 4348| 202 | Not System Application. | 4349 4350**示例:** 4351 4352```ts 4353import { BusinessError } from '@kit.BasicServicesKit'; 4354 4355function callback(err: BusinessError, focusState: camera.FocusState): void { 4356 if (err !== undefined && err.code !== 0) { 4357 console.error(`Callback Error, errorCode: ${err.code}`); 4358 return; 4359 } 4360 console.info(`Focus state: ${focusState}`); 4361} 4362 4363function registerFocusStateChange(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4364 highResolutionPhotoSession.on('focusStateChange', callback); 4365} 4366``` 4367 4368### off('focusStateChange')<sup>12+</sup> 4369 4370off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4371 4372注销监听相机对焦的状态变化。 4373 4374**系统接口:** 此接口为系统接口。 4375 4376**系统能力:** SystemCapability.Multimedia.Camera.Core 4377 4378**错误码:** 4379 4380以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4381 4382| 错误码ID | 错误信息 | 4383| --------------- | --------------- | 4384| 202 | Not System Application. | 4385 4386**参数:** 4387 4388| 参数名 | 类型 | 必填 | 说明 | 4389| -------- | ----------------------------------------- | ---- | ------------------------ | 4390| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 4391| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 4392 4393**示例:** 4394 4395```ts 4396function unregisterFocusStateChange(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4397 highResolutionPhotoSession.off('focusStateChange'); 4398} 4399``` 4400 4401## SketchStatusData<sup>11+</sup> 4402 4403画中画状态返回数据。 4404 4405**系统接口:** 此接口为系统接口。 4406 4407**系统能力:** SystemCapability.Multimedia.Camera.Core 4408 4409| 名称 | 类型 | 只读 | 必填 | 说明 | 4410| ------------- | -------- | ---- | ---- | ---------- | 4411| status | number | 否 | 是 | 画中画当前的状态。0:已停止,1:已启动,2:停止中,3:启动中。| 4412| sketchRatio | number | 否 | 是 | 画中画画面的Zoom倍率。| 4413 4414## SlowMotionVideoSession<sup>12+</sup> 4415 4416SlowMotionVideoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect 4417 4418慢动作录像模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置慢动作录像模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 4419 4420> **说明:** 4421> 慢动作模式下只能添加预览流和录像流。 4422### on('error')<sup>12+</sup> 4423 4424on(type: 'error', callback: ErrorCallback): void 4425 4426监听慢动作录像模式会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 4427 4428**系统接口:** 此接口为系统接口。 4429 4430**系统能力:** SystemCapability.Multimedia.Camera.Core 4431 4432**参数:** 4433 4434| 参数名 | 类型 | 必填 | 说明 | 4435| -------- | --------------------------------- | ---- | ------------------------------ | 4436| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 4437| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 4438 4439**错误码:** 4440 4441以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4442 4443| 错误码ID | 错误信息 | 4444|---------| --------------- | 4445| 202 | Not System Application. | 4446 4447**示例:** 4448 4449```ts 4450import { BusinessError } from '@kit.BasicServicesKit'; 4451 4452function callback(err: BusinessError): void { 4453 console.error(`Portrait photo session error code: ${err.code}`); 4454} 4455 4456function registerSessionError(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4457 slowMotionVideoSession.on('error', callback); 4458} 4459``` 4460 4461### off('error')<sup>12+</sup> 4462 4463off(type: 'error', callback?: ErrorCallback): void 4464 4465注销慢动作录像模式会话的错误事件,通过注册回调函数获取结果。 4466 4467**系统接口:** 此接口为系统接口。 4468 4469**系统能力:** SystemCapability.Multimedia.Camera.Core 4470 4471**参数:** 4472 4473| 参数名 | 类型 | 必填 | 说明 | 4474| -------- | -------------------------- | ---- | ------------------------------ | 4475| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 4476| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匹配on('error') callback(callback对象不可是匿名函数)。 | 4477 4478**错误码:** 4479 4480以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4481 4482| 错误码ID | 错误信息 | 4483|---------| --------------- | 4484| 202 | Not System Application. | 4485 4486**示例:** 4487 4488```ts 4489function unregisterSessionError(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4490 slowMotionVideoSession.off('error'); 4491} 4492``` 4493 4494### on('focusStateChange')<sup>12+</sup> 4495 4496on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4497 4498监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4499 4500**系统接口:** 此接口为系统接口。 4501 4502**系统能力:** SystemCapability.Multimedia.Camera.Core 4503 4504**参数:** 4505 4506| 参数名 | 类型 | 必填 | 说明 | 4507| -------- | ---------------- | ---- | ------------------------ | 4508| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 4509| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 4510 4511**错误码:** 4512 4513以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4514 4515| 错误码ID | 错误信息 | 4516|---------| --------------- | 4517| 202 | Not System Application. | 4518 4519**示例:** 4520 4521```ts 4522import { BusinessError } from '@kit.BasicServicesKit'; 4523 4524function callback(err: BusinessError, focusState: camera.FocusState): void { 4525 if (err !== undefined && err.code !== 0) { 4526 console.error(`Callback Error, errorCode: ${err.code}`); 4527 return; 4528 } 4529 console.info(`Focus state: ${focusState}`); 4530} 4531 4532function registerFocusStateChange(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4533 slowMotionVideoSession.on('focusStateChange', callback); 4534} 4535``` 4536 4537### off('focusStateChange')<sup>12+</sup> 4538 4539off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4540 4541注销监听相机对焦的状态变化。 4542 4543**系统接口:** 此接口为系统接口。 4544 4545**系统能力:** SystemCapability.Multimedia.Camera.Core 4546 4547**参数:** 4548 4549| 参数名 | 类型 | 必填 | 说明 | 4550| -------- | ----------------------------------------- | ---- | ------------------------ | 4551| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 4552| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 4553 4554**错误码:** 4555 4556以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4557 4558| 错误码ID | 错误信息 | 4559|---------| --------------- | 4560| 202 | Not System Application. | 4561 4562**示例:** 4563 4564```ts 4565function unregisterFocusStateChange(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4566 slowMotionVideoSession.off('focusStateChange'); 4567} 4568``` 4569 4570### on('smoothZoomInfoAvailable')<sup>12+</sup> 4571 4572on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 4573 4574监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4575 4576**系统接口:** 此接口为系统接口。 4577 4578**系统能力:** SystemCapability.Multimedia.Camera.Core 4579 4580**参数:** 4581 4582| 参数名 | 类型 | 必填 | 说明 | 4583| -------- | ----------------------- | ---- | ------------------------ | 4584| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4585| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 4586 4587**错误码:** 4588 4589以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4590 4591| 错误码ID | 错误信息 | 4592|---------| --------------- | 4593| 202 | Not System Application. | 4594 4595**示例:** 4596 4597```ts 4598import { BusinessError } from '@kit.BasicServicesKit'; 4599 4600function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 4601 if (err !== undefined && err.code !== 0) { 4602 console.error(`Callback Error, errorCode: ${err.code}`); 4603 return; 4604 } 4605 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 4606} 4607 4608function registerSmoothZoomInfo(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4609 slowMotionVideoSession.on('smoothZoomInfoAvailable', callback); 4610} 4611``` 4612 4613### off('smoothZoomInfoAvailable')<sup>12+</sup> 4614 4615off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 4616 4617注销监听相机平滑变焦的状态变化。 4618 4619**系统接口:** 此接口为系统接口。 4620 4621**系统能力:** SystemCapability.Multimedia.Camera.Core 4622 4623**参数:** 4624 4625| 参数名 | 类型 | 必填 | 说明 | 4626| -------- | ----------------------------------------- | ---- | ------------------------ | 4627| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4628| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,可选,有就是匹配on('smoothZoomInfoAvailable') callback(callback对象不可是匿名函数)。 | 4629 4630**错误码:** 4631 4632以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4633 4634| 错误码ID | 错误信息 | 4635|---------| --------------- | 4636| 202 | Not System Application. | 4637 4638**示例:** 4639 4640```ts 4641function unregisterSmoothZoomInfo(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4642 slowMotionVideoSession.off('smoothZoomInfoAvailable'); 4643} 4644``` 4645 4646### on('slowMotionStatus')<sup>12+</sup> 4647 4648on(type: 'slowMotionStatus', callback: AsyncCallback\<SlowMotionStatus\>): void 4649 4650监听慢动作状态变化,通过注册回调函数获取结果。使用callback异步回调。 4651 4652**系统接口:** 此接口为系统接口。 4653 4654**系统能力:** SystemCapability.Multimedia.Camera.Core 4655 4656**参数:** 4657 4658| 参数名 | 类型 | 必填 | 说明 | 4659| -------- |---------------------------------------------------------------------------| ---- |--------------------------------------------| 4660| type | string | 是 | 监听事件,固定为'slowMotionStatus',session创建成功可监听。 | 4661| callback | AsyncCallback\<[SlowMotionStatus](#slowmotionstatus12)\> | 是 | 回调函数,用于获取当前慢动作状态。当慢动作状态发生变动时,此回调函数也会被执行。 | 4662 4663**错误码:** 4664 4665以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4666 4667| 错误码ID | 错误信息 | 4668|---------| --------------- | 4669| 202 | Not System Application. | 4670 4671**示例:** 4672 4673```ts 4674import { BusinessError } from '@kit.BasicServicesKit'; 4675 4676function callback(err: BusinessError, slowMotionStatus: camera.SlowMotionStatus): void { 4677 if (err !== undefined && err.code !== 0) { 4678 console.error(`Callback Error, errorCode: ${err.code}`); 4679 return; 4680 } 4681 console.info(`The slow motion status: ${slowMotionStatus}`); 4682} 4683 4684function registerSlowMotionStatus(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4685 slowMotionVideoSession.on('slowMotionStatus', callback); 4686} 4687``` 4688 4689### off('slowMotionStatus')<sup>12+</sup> 4690 4691off(type: 'slowMotionStatus', callback?: AsyncCallback\<SlowMotionStatus\>): void 4692 4693注销慢动作状态变化。 4694 4695**系统接口:** 此接口为系统接口。 4696 4697**系统能力:** SystemCapability.Multimedia.Camera.Core 4698 4699**参数:** 4700 4701| 参数名 | 类型 | 必填 | 说明 | 4702| -------- | ----------------------------------------- | ---- | ------------------------ | 4703| type | string | 是 | 监听事件,固定为'slowMotionStatus',session创建成功可监听。| 4704| callback | AsyncCallback\<[SlowMotionStatus](#slowmotionstatus12)\> | 否 | 回调函数,可选,有就是匹配on('slowMotionStatus') callback(callback对象不可是匿名函数)。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 4705 4706**错误码:** 4707 4708以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4709 4710| 错误码ID | 错误信息 | 4711|---------| --------------- | 4712| 202 | Not System Application. | 4713 4714**示例:** 4715 4716```ts 4717function unregisterSlowMotionStatus(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4718 slowMotionVideoSession.off('slowMotionStatus'); 4719} 4720``` 4721### isSlowMotionDetectionSupported<sup>12+</sup> 4722 4723isSlowMotionDetectionSupported(): boolean 4724 4725查询当前设备是否支持慢动作检测功能。 4726 4727> **说明:** 4728> 该接口需要在[commitConfig](js-apis-camera.md#commitconfig11-1)之后调用。 4729 4730**系统接口:** 此接口为系统接口。 4731 4732**系统能力:** SystemCapability.Multimedia.Camera.Core 4733 4734**返回值:** 4735 4736| 类型 | 说明 | 4737| ---------- |----------------------------------------------------------------------------------------| 4738| boolean | 返回true表示支持慢动作检测功能,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 4739 4740**错误码:** 4741 4742以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4743 4744| 错误码ID | 错误信息 | 4745|---------| --------------- | 4746| 202 | Not System Application. | 4747| 7400103 | Session not config. | 4748 4749**示例:** 4750 4751```ts 4752import { BusinessError } from '@kit.BasicServicesKit'; 4753 4754function isSlowMotionDetectionSupported(slowMotionVideoSession: camera.SlowMotionVideoSession): boolean { 4755 let isSupported: boolean = false; 4756 try { 4757 isSupported = slowMotionVideoSession.isSlowMotionDetectionSupported(); 4758 } catch (error) { 4759 // 失败返回错误码error.code并处理 4760 let err = error as BusinessError; 4761 console.error(`The isFocusModeSupported call failed. error code: ${err.code}`); 4762 } 4763 return isSupported; 4764} 4765``` 4766 4767### setSlowMotionDetectionArea<sup>12+</sup> 4768 4769setSlowMotionDetectionArea(area: Rect): void 4770 4771设置一个进行慢动作检测的区域。 4772 4773> **说明:** 4774> 在调用该方法之前,先调用[isSlowMotionDetectionSupported](#isslowmotiondetectionsupported12)确认设备是否支持慢动作检测功能, 才能保证其他相关方法的正常运行。 4775该接口需要在[commitConfig](js-apis-camera.md#commitconfig11-1)之后调用。 4776 4777**系统接口:** 此接口为系统接口。 4778 4779**系统能力:** SystemCapability.Multimedia.Camera.Core 4780 4781**参数:** 4782 4783| 参数名 | 类型 | 必填 | 说明 | 4784| -------- | ---------------------------------------------- | ---- | --------------------------- | 4785| area | [Rect](js-apis-camera.md#rect) | 是 | 矩形定义。 | 4786 4787**错误码:** 4788 4789以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4790 4791| 错误码ID | 错误信息 | 4792|---------| --------------- | 4793| 202 | Not System Application. | 4794| 7400101 | Parameter missing or parameter type incorrect. | 4795| 7400103 | Session not config. | 4796 4797**示例:** 4798 4799```ts 4800import { BusinessError } from '@kit.BasicServicesKit'; 4801 4802function setSlowMotionDetectionArea(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4803 try { 4804 slowMotionVideoSession.setSlowMotionDetectionArea({topLeftX: 0.1, topLeftY: 0.1, width: 0.8, height: 0.8}); 4805 } catch (error) { 4806 // 失败返回错误码error.code并处理 4807 let err = error as BusinessError; 4808 console.error(`The setSlowMotionDetectionArea call failed. error code: ${err.code}`); 4809 } 4810} 4811``` 4812 4813## PanoramaPhotoSession<sup>12+</sup> 4814 4815PanoramaPhotoSession extends Session, Focus, AutoExposure, WhiteBalance, ColorEffect 4816 4817全景拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置全景拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 4818 4819### on('error')<sup>12+</sup> 4820 4821on(type: 'error', callback: ErrorCallback): void 4822 4823监听全景拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 4824 4825**系统接口:** 此接口为系统接口。 4826 4827**系统能力:** SystemCapability.Multimedia.Camera.Core 4828 4829**参数:** 4830 4831| 参数名 | 类型 | 必填 | 说明 | 4832| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 4833| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 4834| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 4835 4836**示例:** 4837 4838```ts 4839import { BusinessError } from '@kit.BasicServicesKit'; 4840 4841function callback(err: BusinessError): void { 4842 console.error(`Panorama photo session error code: ${err.code}`); 4843} 4844 4845function registerSessionError(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 4846 panoramaPhotoSession.on('error', callback); 4847} 4848``` 4849 4850### off('error')<sup>11+</sup> 4851 4852off(type: 'error', callback?: ErrorCallback): void 4853 4854注销监听全景拍照会话的错误事件,通过注册回调函数获取结果。 4855 4856**系统接口:** 此接口为系统接口。 4857 4858**系统能力:** SystemCapability.Multimedia.Camera.Core 4859 4860**参数:** 4861 4862| 参数名 | 类型 | 必填 | 说明 | 4863| -------- | ------------------------ | ---- | ------------------------------ | 4864| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 4865| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匹配on('error') callback(callback对象不可是匿名函数)。 | 4866 4867**示例:** 4868 4869```ts 4870function unregisterSessionError(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 4871 panoramaPhotoSession.off('error'); 4872} 4873``` 4874 4875### on('focusStateChange')<sup>11+</sup> 4876 4877on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4878 4879监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4880 4881**系统接口:** 此接口为系统接口。 4882 4883**系统能力:** SystemCapability.Multimedia.Camera.Core 4884 4885**参数:** 4886 4887| 参数名 | 类型 | 必填 | 说明 | 4888| -------- | ---------------- | ---- | ------------------------ | 4889| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 4890| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 4891 4892**示例:** 4893 4894```ts 4895import { BusinessError } from '@kit.BasicServicesKit'; 4896 4897function callback(err: BusinessError, focusState: camera.FocusState): void { 4898 if (err !== undefined && err.code !== 0) { 4899 console.error(`Callback Error, errorCode: ${err.code}`); 4900 return; 4901 } 4902 console.info(`Focus state: ${focusState}`); 4903} 4904 4905function registerFocusStateChange(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 4906 panoramaPhotoSession.on('focusStateChange', callback); 4907} 4908``` 4909 4910### off('focusStateChange')<sup>11+</sup> 4911 4912off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4913 4914注销监听相机对焦的状态变化。 4915 4916**系统接口:** 此接口为系统接口。 4917 4918**系统能力:** SystemCapability.Multimedia.Camera.Core 4919 4920**参数:** 4921 4922| 参数名 | 类型 | 必填 | 说明 | 4923| -------- | ----------------------------------------- | ---- | ------------------------ | 4924| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 4925| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 4926 4927**示例:** 4928 4929```ts 4930function unregisterFocusStateChange(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 4931 panoramaPhotoSession.off('focusStateChange'); 4932} 4933``` 4934 4935## IsoInfo<sup>12+</sup> 4936 4937ISO参数信息。 4938 4939**系统接口:** 此接口为系统接口。 4940 4941**系统能力:** SystemCapability.Multimedia.Camera.Core 4942 4943| 名称 | 类型 | 只读 | 可选 | 说明 | 4944| ---- | ------- | ---- |--| -------------- | 4945| iso | number | 是 | 是 | ISO值。 | 4946 4947--- 4948 4949## ExposureInfo<sup>12+</sup> 4950 4951曝光参数信息。 4952 4953**系统接口:** 此接口为系统接口。 4954 4955**系统能力:** SystemCapability.Multimedia.Camera.Core 4956 4957| 名称 | 类型 | 只读 | 可选 | 说明 | 4958| ----------------- | ------- | ---- |-----| ------------------ | 4959| exposureTime | number | 是 | 是 | 曝光时间值,单位为毫秒。 | 4960 4961--- 4962 4963## ApertureInfo<sup>12+</sup> 4964 4965光圈参数信息。 4966 4967**系统接口:** 此接口为系统接口。 4968 4969**系统能力:** SystemCapability.Multimedia.Camera.Core 4970 4971| 名称 | 类型 | 只读 | 可选 | 说明 | 4972| --------- | ------- | ---- |-----| ---------- | 4973| aperture | number | 是 | 是 | 光圈值。 | 4974 4975--- 4976 4977## LuminationInfo<sup>12+</sup> 4978 4979光照参数信息。 4980 4981**系统接口:** 此接口为系统接口。 4982 4983**系统能力:** SystemCapability.Multimedia.Camera.Core 4984 4985| 名称 | 类型 | 只读 | 可选 | 说明 | 4986| ----------- | ------- | ---- |-----| ---------- | 4987| lumination | number | 是 | 是 | 范围[0,1],光照值归一化数值| 4988 4989## CameraFormat 4990 4991枚举,输出格式。 4992 4993**系统能力:** SystemCapability.Multimedia.Camera.Core 4994 4995| 名称 | 值 | 说明 | 4996| ----------------------- | --------- | ------------ | 4997| CAMERA_FORMAT_DNG<sup>12+</sup> | 4 | DNG格式的RAW图片。**系统接口:** 此接口为系统接口。 | 4998 4999## ExposureMeteringMode<sup>12+</sup> 5000 5001枚举,测光模式。 5002 5003**系统接口:** 此接口为系统接口。 5004 5005**系统能力:** SystemCapability.Multimedia.Camera.Core 5006 5007| 名称 | 值 | 说明 | 5008| ----------------------------- | ---- | ----------- | 5009| MATRIX | 0 | 对画面广泛区域进行测光。 | 5010| CENTER | 1 | 对整个画面进行测光,但最大比重分配给中央区域。 | 5011| SPOT | 2 | 对画面测光点周围约2.5%进行测光 | 5012 5013## AutoExposureQuery<sup>12+</sup> 5014 5015提供了查询设备是否支持特定曝光模式,曝光补偿的范围,以及是否支持特定的曝光测光模式的方法。 5016 5017### isExposureMeteringModeSupported<sup>12+</sup> 5018 5019isExposureMeteringModeSupported(aeMeteringMode: ExposureMeteringMode): boolean 5020 5021检测传入的测光模式是否支持。 5022 5023**系统接口:** 此接口为系统接口。 5024 5025**系统能力:** SystemCapability.Multimedia.Camera.Core 5026 5027**参数:** 5028 5029| 参数名 | 类型 | 必填 | 说明 | 5030| -------- | -------------------------------| ---- | ----------------------------- | 5031| aeMeteringMode | [ExposureMeteringMode](#exposuremeteringmode12) | 是 | 测光模式。 | 5032 5033**返回值:** 5034 5035| 类型 | 说明 | 5036| ---------- | ----------------------------- | 5037| boolean | 获取是否支持传入的测光模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5038 5039**错误码:** 5040 5041以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5042 5043| 错误码ID | 错误信息 | 5044| --------------- | --------------- | 5045| 202 | Not System Application. | 5046| 7400101 | Parameter missing or parameter type incorrect. | 5047| 7400103 | Session not config. | 5048 5049 5050**示例:** 5051 5052```ts 5053import { BusinessError } from '@kit.BasicServicesKit'; 5054 5055function isExposureMeteringModeSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5056 let isSupported: boolean = false; 5057 try { 5058 isSupported = professionalPhotoSession.isExposureModeSupported(camera.ExposureMeteringMode.CENTER); 5059 } catch (error) { 5060 // 失败返回错误码error.code并处理 5061 let err = error as BusinessError; 5062 console.error(`The isExposureMeteringModeSupported call failed. error code: ${err.code}`); 5063 } 5064 return isSupported; 5065} 5066``` 5067 5068## AutoExposure 5069 5070AutoExposure extends [AutoExposureQuery](#autoexposurequery12) 5071 5072提供了处理设备自动曝光的相关功能,包括获取和设置曝光模式、测量点,查询补偿范围,设定曝光补偿,和获取设置曝光的测光模式。 5073 5074### getExposureMeteringMode<sup>12+</sup> 5075 5076getExposureMeteringMode(): ExposureMeteringMode 5077 5078获取当前测光模式。 5079 5080**系统接口:** 此接口为系统接口。 5081 5082**系统能力:** SystemCapability.Multimedia.Camera.Core 5083 5084**返回值:** 5085 5086| 类型 | 说明 | 5087| ---------- | ----------------------------- | 5088| [ExposureMeteringMode](#exposuremeteringmode12) | 获取当前测光模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5089 5090**错误码:** 5091 5092以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5093 5094| 错误码ID | 错误信息 | 5095| --------------- | --------------- | 5096| 7400103 | Session not config. | 5097| 202 | Not System Application. | 5098 5099**示例:** 5100 5101```ts 5102import { BusinessError } from '@kit.BasicServicesKit'; 5103 5104function getExposureMeteringMode(professionalPhotoSession: camera.ProfessionalPhotoSession): camera.ExposureMeteringMode | undefined { 5105 let exposureMeteringMode: camera.ExposureMeteringMode | undefined = undefined; 5106 try { 5107 exposureMeteringMode = professionalPhotoSession.getExposureMeteringMode(); 5108 } catch (error) { 5109 // 失败返回错误码error.code并处理 5110 let err = error as BusinessError; 5111 console.error(`The getExposureMeteringMode call failed. error code: ${err.code}`); 5112 } 5113 return exposureMeteringMode; 5114} 5115``` 5116 5117### setExposureMeteringMode<sup>12+</sup> 5118 5119setExposureMeteringMode(aeMeteringMode: ExposureMeteringMode): void 5120 5121设置测光模式。进行设置之前,需要先检查设备是否支持指定的测光模式,可使用方法[isExposureMeteringModeSupported](#isexposuremeteringmodesupported12)。 5122 5123**系统接口:** 此接口为系统接口。 5124 5125**系统能力:** SystemCapability.Multimedia.Camera.Core 5126 5127**参数:** 5128 5129| 参数名 | 类型 | 必填 | 说明 | 5130| -------- | -------------------------------| ---- | ----------------------- | 5131| aeMeteringMode | [ExposureMeteringMode](#exposuremeteringmode12) | 是 | 测光模式。 | 5132 5133**错误码:** 5134 5135以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5136 5137| 错误码ID | 错误信息 | 5138| --------------- | --------------- | 5139| 202 | Not System Application. | 5140| 7400101 | Parameter missing or parameter type incorrect. | 5141| 7400103 | Session not config. | 5142 5143**示例:** 5144 5145```ts 5146import { BusinessError } from '@kit.BasicServicesKit'; 5147 5148function setExposureMeteringMode(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5149 try { 5150 professionalPhotoSession.setExposureMeteringMode(camera.ExposureMeteringMode.CENTER); 5151 } catch (error) { 5152 // 失败返回错误码error.code并处理 5153 let err = error as BusinessError; 5154 console.error(`The setExposureMeteringMode call failed. error code: ${err.code}`); 5155 } 5156} 5157``` 5158 5159## FocusQuery<sup>12+</sup> 5160 5161提供了查询是否支持对焦辅助的方法。 5162 5163### isFocusAssistSupported<sup>12+</sup> 5164 5165isFocusAssistSupported(): boolean 5166 5167检测是否支持对焦辅助灯。 5168 5169**系统接口:** 此接口为系统接口。 5170 5171**系统能力:** SystemCapability.Multimedia.Camera.Core 5172 5173**返回值:** 5174 5175| 类型 | 说明 | 5176| ---------- | ----------------------------- | 5177| boolean | 返回true表示支持对焦辅助灯,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5178 5179**错误码:** 5180 5181以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5182 5183| 错误码ID | 错误信息 | 5184| --------------- | --------------- | 5185| 7400103 | Session not config. | 5186| 202 | Not System Application. | 5187 5188**示例:** 5189 5190```ts 5191import { BusinessError } from '@kit.BasicServicesKit'; 5192 5193function isFocusAssistSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5194 let status: boolean = false; 5195 try { 5196 status = professionalPhotoSession.isFocusAssistSupported(); 5197 } catch (error) { 5198 // 失败返回错误码error.code并处理 5199 let err = error as BusinessError; 5200 console.error(`The isFocusAssistSupported call failed. error code: ${err.code}`); 5201 } 5202 return status; 5203} 5204``` 5205 5206## Focus 5207 5208Focus extends [FocusQuery](#focusquery12) 5209 5210提供了获取和设置相机对焦模式和对焦点位置的方法。 5211 5212### setFocusAssist<sup>12+</sup> 5213 5214setFocusAssist(enabled: boolean): void 5215 5216设置对焦辅助灯。进行设置之前,需要先检查设备是否支持对焦辅助灯,可使用方法[isFocusAssistSupported](#isfocusassistsupported12)。 5217 5218**系统接口:** 此接口为系统接口。 5219 5220**系统能力:** SystemCapability.Multimedia.Camera.Core 5221 5222**参数:** 5223 5224| 参数名 | 类型 | 必填 | 说明 | 5225| -------- | ----------------------- | ---- | ------------------- | 5226| enabled | boolean | 是 | true:开启对焦辅助灯,false:关闭对焦辅助灯。 | 5227 5228**错误码:** 5229 5230以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5231 5232| 错误码ID | 错误信息 | 5233| --------------- | --------------- | 5234| 202 | Not System Application. | 5235| 7400101 | Parameter missing or parameter type incorrect. | 5236| 7400103 | Session not config. | 5237 5238 5239**示例:** 5240 5241```ts 5242import { BusinessError } from '@kit.BasicServicesKit'; 5243 5244function setFocusAssist(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5245 try { 5246 professionalPhotoSession.setFocusAssist(false); 5247 } catch (error) { 5248 // 失败返回错误码error.code并处理 5249 let err = error as BusinessError; 5250 console.error(`The setFocusAssist call failed. error code: ${err.code}`); 5251 } 5252} 5253``` 5254 5255### getFocusAssist<sup>12+</sup> 5256 5257getFocusAssist(): boolean 5258 5259获取对焦辅助灯是否开启。 5260 5261**系统接口:** 此接口为系统接口。 5262 5263**系统能力:** SystemCapability.Multimedia.Camera.Core 5264 5265**返回值:** 5266 5267| 类型 | 说明 | 5268| ---------- | ----------------------------- | 5269| boolean | 返回true表示相机已打开对焦辅助灯,返回false表示相机已关闭对焦辅助灯。 | 5270 5271**错误码:** 5272 5273以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5274 5275| 错误码ID | 错误信息 | 5276| --------------- | --------------- | 5277| 7400103 | Session not config. | 5278| 202 | Not System Application. | 5279 5280**示例:** 5281 5282```ts 5283import { BusinessError } from '@kit.BasicServicesKit'; 5284 5285function getFocusAssist(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5286 let isFocusAssistOpened: boolean; 5287 try { 5288 isFocusAssistOpened = professionalPhotoSession.getFocusAssist(); 5289 } catch (error) { 5290 // 失败返回错误码error.code并处理 5291 let err = error as BusinessError; 5292 console.error(`The getFocusAssist call failed. error code: ${err.code}`); 5293 } 5294 return isFocusAssistOpened; 5295} 5296``` 5297 5298## ManualFocus<sup>12+</sup> 5299 5300手动对焦类,对设备手动设置对焦操作。 5301 5302### setFocusDistance<sup>12+</sup> 5303 5304setFocusDistance(distance: number): void 5305 5306手动设置对焦距离,可设置范围为[0,1]之间的浮点数,0表现为近景,1表现为远景。 5307 5308**系统接口:** 此接口为系统接口。 5309 5310**系统能力:** SystemCapability.Multimedia.Camera.Core 5311 5312**参数:** 5313 5314| 参数名 | 类型 | 必填 | 说明 | 5315| -------- | ----------------------- | ---- | ------------------- | 5316| distance | number | 是 | 范围0-1:该值为归一化值,0为近景,1为远景,<br>可在该范围内调节 | 5317 5318**错误码:** 5319 5320以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5321 5322| 错误码ID | 错误信息 | 5323| --------------- | --------------- | 5324| 202 | Not System Application. | 5325| 7400101 | Parameter missing or parameter type incorrect. | 5326| 7400103 | Session not config. | 5327 5328**示例:** 5329 5330```ts 5331import { BusinessError } from '@kit.BasicServicesKit'; 5332 5333function setFocusDistance(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5334 try { 5335 let distance: number = 0.5; 5336 professionalPhotoSession.setFocusDistance(distance); 5337 } catch (error) { 5338 // 失败返回错误码error.code并处理 5339 let err = error as BusinessError; 5340 console.error(`The setFocusDistance call failed. error code: ${err.code}`); 5341 } 5342} 5343``` 5344 5345### getFocusDistance<sup>12+</sup> 5346 5347getFocusDistance(): number 5348 5349获取当前的对焦距离。 5350 5351**系统接口:** 此接口为系统接口。 5352 5353**系统能力:** SystemCapability.Multimedia.Camera.Core 5354 5355**返回值:** 5356 5357| 类型 | 说明 | 5358| ---------- | ----------------------------- | 5359| number | 返回当前对焦距离的归一化值。 | 5360 5361**错误码:** 5362 5363以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5364 5365| 错误码ID | 错误信息 | 5366| --------------- | --------------- | 5367| 7400103 | Session not config. | 5368| 202 | Not System Application. | 5369 5370**示例:** 5371 5372```ts 5373import { BusinessError } from '@kit.BasicServicesKit'; 5374 5375function getFocusDistance(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 5376 let distance: number = 0; 5377 try { 5378 distance = professionalPhotoSession.getFocusDistance(); 5379 } catch (error) { 5380 // 失败返回错误码error.code并处理 5381 let err = error as BusinessError; 5382 console.error(`The getFocusDistance call failed. error code: ${err.code}`); 5383 } 5384 return distance; 5385} 5386``` 5387 5388## ManualIsoQuery<sup>12+</sup> 5389 5390提供了查询设备是否支持手动设置ISO和获取设备支持的ISO范围的方法。 5391 5392### isManualIsoSupported<sup>12+</sup> 5393 5394isManualIsoSupported(): boolean 5395 5396检测是否支持手动ISO。 5397 5398**系统接口:** 此接口为系统接口。 5399 5400**系统能力:** SystemCapability.Multimedia.Camera.Core 5401 5402**返回值:** 5403 5404| 类型 | 说明 | 5405| ---------- | ----------------------------- | 5406| boolean | 返回true表示支持手动调节ISO,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5407 5408**错误码:** 5409 5410以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5411 5412| 错误码ID | 错误信息 | 5413| --------------- | --------------- | 5414| 7400103 | Session not config. | 5415| 202 | Not System Application. | 5416 5417**示例:** 5418 5419```ts 5420import { BusinessError } from '@kit.BasicServicesKit'; 5421 5422function isManualIsoSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5423 let status: boolean = false; 5424 try { 5425 status = professionalPhotoSession.isManualIsoSupported(); 5426 } catch (error) { 5427 // 失败返回错误码error.code并处理 5428 let err = error as BusinessError; 5429 console.error(`The isManualIsoSupported call failed. error code: ${err.code}`); 5430 } 5431 return status; 5432} 5433``` 5434 5435### getIsoRange<sup>12+</sup> 5436 5437getIsoRange(): Array\<number\> 5438 5439获取支持的ISO范围。 5440 5441**系统接口:** 此接口为系统接口。 5442 5443**系统能力:** SystemCapability.Multimedia.Camera.Core 5444 5445**返回值:** 5446 5447| 类型 | 说明 | 5448| ---------- | ----------------------------- | 5449| Array\<number\> | 用于获取ISO范围,范围为[50,100,...,6400],实际根据底层能力返回为准,接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5450 5451**错误码:** 5452 5453以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5454 5455| 错误码ID | 错误信息 | 5456| --------------- | --------------- | 5457| 202 | Not System Application. | 5458| 7400103 | Session not config. | 5459 5460**示例:** 5461 5462```ts 5463import { BusinessError } from '@kit.BasicServicesKit'; 5464 5465function getIsoRange(professionalPhotoSession: camera.ProfessionalPhotoSession): Array<number> { 5466 let isoRange: Array<number> = []; 5467 try { 5468 isoRange = professionalPhotoSession.getIsoRange(); 5469 } catch (error) { 5470 // 失败返回错误码error.code并处理 5471 let err = error as BusinessError; 5472 console.error(`The getIsoRange call failed. error code: ${err.code}`); 5473 } 5474 return isoRange; 5475} 5476``` 5477 5478## ManualIso<sup>12+</sup> 5479 5480ManualIso extends [ManualIsoQuery](#manualisoquery12) 5481 5482提供了获取和设置设备手动ISO(感光度)的功能。 5483 5484### setIso<sup>12+</sup> 5485setIso(iso: number): void 5486 5487设置ISO值。**注意:当ISO值设置为0时,表示设置自动ISO** 5488 5489**系统接口:** 此接口为系统接口。 5490 5491**系统能力:** SystemCapability.Multimedia.Camera.Core 5492 5493**参数:** 5494 5495| 参数名 | 类型 | 必填 | 说明 | 5496| -------- | ----------------------- | ---- | ------------------- | 5497| iso | number | 是 | 设置ISO值, | 5498 5499**错误码:** 5500 5501以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5502 5503| 错误码ID | 错误信息 | 5504| --------------- | --------------- | 5505| 202 | Not System Application. | 5506| 7400101 | Parameter missing or parameter type incorrect. | 5507| 7400103 | Session not config. | 5508 5509**示例:** 5510 5511```ts 5512import { BusinessError } from '@kit.BasicServicesKit'; 5513 5514function setIso(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5515 try { 5516 let iso: number = 200; 5517 professionalPhotoSession.setIso(iso); 5518 } catch (error) { 5519 // 失败返回错误码error.code并处理 5520 let err = error as BusinessError; 5521 console.error(`The setIso call failed. error code: ${err.code}`); 5522 } 5523} 5524``` 5525 5526### getIso<sup>12+</sup> 5527 5528getIso(): number 5529 5530获取当前的ISO值。 5531 5532**系统接口:** 此接口为系统接口。 5533 5534**系统能力:** SystemCapability.Multimedia.Camera.Core 5535 5536**返回值:** 5537 5538| 类型 | 说明 | 5539| ---------- | ----------------------------- | 5540| number | 返回当前ISO值。 | 5541 5542**错误码:** 5543 5544以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5545 5546| 错误码ID | 错误信息 | 5547| --------------- | --------------- | 5548| 202 | Not System Application. | 5549| 7400103 | Session not config. | 5550 5551**示例:** 5552 5553```ts 5554import { BusinessError } from '@kit.BasicServicesKit'; 5555 5556function getIso(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 5557 let iso: number = 0; 5558 try { 5559 iso = professionalPhotoSession.getIso(); 5560 } catch (error) { 5561 // 失败返回错误码error.code并处理 5562 let err = error as BusinessError; 5563 console.error(`The getIso call failed. error code: ${err.code}`); 5564 } 5565 return iso; 5566} 5567``` 5568 5569## WhiteBalanceMode<sup>12+</sup> 5570 5571枚举,白平衡模式。 5572 5573**系统接口:** 此接口为系统接口。 5574 5575**系统能力:** SystemCapability.Multimedia.Camera.Core 5576 5577| 名称 | 值 | 说明 | 5578| ----------------------------- | ---- | ----------- | 5579| AUTO | 0 | 自动 | 5580| CLOUDY | 1 | 阴天 | 5581| INCANDESCENT | 2 | 白炽光 | 5582| FLUORESCENT | 3 | 荧光 | 5583| DAYLIGHT | 4 | 日光 | 5584| MANUAL | 5 | 手动 | 5585 5586## WhiteBalanceQuery<sup>12+</sup> 5587 5588提供了查询设备对指定的白平衡模式是否支持,以及获取设备支持的白平衡模式范围的方法。 5589 5590### isWhiteBalanceModeSupported<sup>12+</sup> 5591 5592isWhiteBalanceModeSupported(mode: WhiteBalanceMode): boolean 5593 5594检测是否支持当前传入的白平衡模式。 5595 5596**系统接口:** 此接口为系统接口。 5597 5598**系统能力:** SystemCapability.Multimedia.Camera.Core 5599**参数:** 5600 5601| 参数名 | 类型 | 必填 | 说明 | 5602| -------- | -------------------------------| ---- | ----------------------------- | 5603| mode | [WhiteBalanceMode](#whitebalancemode12) | 是 | 白平衡模式。 | 5604 5605**返回值:** 5606 5607| 类型 | 说明 | 5608| ---------- | ----------------------------- | 5609| boolean | 返回true表示支持该白平衡模式,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5610 5611**错误码:** 5612 5613以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5614 5615| 错误码ID | 错误信息 | 5616| --------------- | --------------- | 5617| 202 | Not System Application. | 5618| 7400101 | Parameter missing or parameter type incorrect. | 5619| 7400103 | Session not config. | 5620 5621**示例:** 5622 5623```ts 5624import { BusinessError } from '@kit.BasicServicesKit'; 5625 5626function isWhiteBalanceModeSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5627 let status: boolean = false; 5628 try { 5629 let mode: WhiteBalanceMode = camera.WhiteBalanceMode.DAYLIGHT; 5630 status = professionalPhotoSession.isWhiteBalanceModeSupported(mode); 5631 } catch (error) { 5632 // 失败返回错误码error.code并处理 5633 let err = error as BusinessError; 5634 console.error(`The isWhiteBalanceModeSupported call failed. error code: ${err.code}`); 5635 } 5636 return status; 5637} 5638``` 5639 5640### getWhiteBalanceRange<sup>12+</sup> 5641 5642getWhiteBalanceRange(): Array\<number\> 5643 5644获取手动白平衡的调节范围。 5645 5646**系统接口:** 此接口为系统接口。 5647 5648**系统能力:** SystemCapability.Multimedia.Camera.Core 5649 5650**返回值:** 5651 5652| 类型 | 说明 | 5653| ---------- | ----------------------------- | 5654| Array\<number\> | 用于获取手动白平衡值可调范围,如[2800,...,10000],单位为K(Kelvin,温度单位),实际情况根据底层能力返回为准。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5655 5656**错误码:** 5657 5658以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5659 5660| 错误码ID | 错误信息 | 5661| --------------- | --------------- | 5662| 202 | Not System Application. | 5663| 7400103 | Session not config. | 5664 5665**示例:** 5666 5667```ts 5668import { BusinessError } from '@kit.BasicServicesKit'; 5669 5670function getWhiteBalanceRange(professionalPhotoSession: camera.ProfessionalPhotoSession): Array<number> { 5671 let range: Array<number> = []; 5672 try { 5673 range = professionalPhotoSession.getWhiteBalanceRange(); 5674 } catch (error) { 5675 // 失败返回错误码error.code并处理 5676 let err = error as BusinessError; 5677 console.error(`The getWhiteBalanceRange call failed. error code: ${err.code}`); 5678 } 5679 return range; 5680} 5681``` 5682 5683## WhiteBalance<sup>12+</sup> 5684 5685WhiteBalance extends [WhiteBalanceQuery](#whitebalancequery12) 5686 5687提供了处理设备白平衡的相关功能,包括获取和设置白平衡模式和白平衡值。 5688 5689### setWhiteBalanceMode<sup>12+</sup> 5690 5691setWhiteBalanceMode(mode: WhiteBalanceMode): void 5692 5693设置白平衡模式。进行设置之前,需要先检查设备是否支持指定的白平衡模式,可使用方法[isWhiteBalanceModeSupported](#iswhitebalancemodesupported12)。 5694 5695**系统接口:** 此接口为系统接口。 5696 5697**系统能力:** SystemCapability.Multimedia.Camera.Core 5698 5699**参数:** 5700 5701| 参数名 | 类型 | 必填 | 说明 | 5702| -------- | -------------------------------| ---- | ----------------------- | 5703| mode | [WhiteBalanceMode](#whitebalancemode12) | 是 | 白平衡模式。 | 5704 5705**错误码:** 5706 5707以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5708 5709| 错误码ID | 错误信息 | 5710| --------------- | --------------- | 5711| 202 | Not System Application. | 5712| 7400101 | Parameter missing or parameter type incorrect. | 5713| 7400103 | Session not config. | 5714 5715**示例:** 5716 5717```ts 5718import { BusinessError } from '@kit.BasicServicesKit'; 5719 5720function setWhiteBalanceMode(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5721 try { 5722 professionalPhotoSession.setWhiteBalanceMode(camera.WhiteBalanceMode.DAYLIGHT); 5723 } catch (error) { 5724 // 失败返回错误码error.code并处理 5725 let err = error as BusinessError; 5726 console.error(`The setWhiteBalanceMode call failed. error code: ${err.code}`); 5727 } 5728} 5729``` 5730 5731### getWhiteBalanceMode<sup>12+</sup> 5732 5733getWhiteBalanceMode(): WhiteBalanceMode 5734 5735获取当前白平衡模式。 5736 5737**系统接口:** 此接口为系统接口。 5738 5739**系统能力:** SystemCapability.Multimedia.Camera.Core 5740 5741**返回值:** 5742 5743| 类型 | 说明 | 5744| ---------- | ----------------------------- | 5745| [WhiteBalanceMode](#whitebalancemode12) | 获取当前白平衡模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5746 5747**错误码:** 5748 5749以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5750 5751| 错误码ID | 错误信息 | 5752| --------------- | --------------- | 5753| 202 | Not System Application. | 5754| 7400103 | Session not config. | 5755 5756**示例:** 5757 5758```ts 5759import { BusinessError } from '@kit.BasicServicesKit'; 5760 5761function getWhiteBalanceMode(professionalPhotoSession: camera.ProfessionalPhotoSession): camera.WhiteBalanceMode | undefined { 5762 let whiteBalanceMode: camera.WhiteBalanceMode | undefined = undefined; 5763 try { 5764 whiteBalanceMode = professionalPhotoSession.getWhiteBalanceMode(); 5765 } catch (error) { 5766 // 失败返回错误码error.code并处理 5767 let err = error as BusinessError; 5768 console.error(`The getWhiteBalanceMode call failed. error code: ${err.code}`); 5769 } 5770 return whiteBalanceMode; 5771} 5772``` 5773 5774### setWhiteBalance<sup>12+</sup> 5775setWhiteBalance(whiteBalance: number): void 5776 5777设置手动白平衡值。 5778 5779**系统接口:** 此接口为系统接口。 5780 5781**系统能力:** SystemCapability.Multimedia.Camera.Core 5782 5783**参数:** 5784 5785| 参数名 | 类型 | 必填 | 说明 | 5786| -------- | ----------------------- | ---- | ------------------- | 5787| whiteBalance | number | 是 | 设置手动白平衡值 | 5788 5789**错误码:** 5790 5791以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5792 5793| 错误码ID | 错误信息 | 5794| --------------- | --------------- | 5795| 202 | Not System Application. | 5796| 7400101 | Parameter missing or parameter type incorrect. | 5797| 7400103 | Session not config. | 5798 5799**示例:** 5800 5801```ts 5802import { BusinessError } from '@kit.BasicServicesKit'; 5803 5804function setWhiteBalance(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5805 try { 5806 let whiteBalance: number = 1000; 5807 professionalPhotoSession.setWhiteBalance(whiteBalance); 5808 } catch (error) { 5809 // 失败返回错误码error.code并处理 5810 let err = error as BusinessError; 5811 console.error(`The setWhiteBalance call failed. error code: ${err.code}`); 5812 } 5813} 5814``` 5815 5816### getWhiteBalance<sup>12+</sup> 5817 5818getWhiteBalance(): number 5819 5820获取当前手动白平衡的值。 5821 5822**系统接口:** 此接口为系统接口。 5823 5824**系统能力:** SystemCapability.Multimedia.Camera.Core 5825 5826**返回值:** 5827 5828| 类型 | 说明 | 5829| ---------- | ----------------------------- | 5830| number | 返回当前白平衡值。 | 5831 5832**错误码:** 5833 5834以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5835 5836| 错误码ID | 错误信息 | 5837| --------------- | --------------- | 5838| 202 | Not System Application. | 5839| 7400103 | Session not config. | 5840 5841**示例:** 5842 5843```ts 5844import { BusinessError } from '@kit.BasicServicesKit'; 5845 5846function getWhiteBalance(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 5847 let whiteBalance: number = 0; 5848 try { 5849 whiteBalance = professionalPhotoSession.getWhiteBalance(); 5850 } catch (error) { 5851 // 失败返回错误码error.code并处理 5852 let err = error as BusinessError; 5853 console.error(`The getWhiteBalance call failed. error code: ${err.code}`); 5854 } 5855 return whiteBalance; 5856} 5857``` 5858 5859## ProfessionalPhotoSession<sup>12+</sup> 5860 5861ProfessionalPhotoSession extends Session, AutoExposure, ManualExposure, Focus, ManualFocus, WhiteBalance, ManualIso, Flash, Zoom, ColorEffect, Aperture 5862 5863专业拍照会话类,继承自[Session](js-apis-camera.md#session12),用于设置专业拍照会话的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 5864 5865### on('error')<sup>12+</sup> 5866 5867on(type: 'error', callback: ErrorCallback): void 5868 5869监听专业拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 5870 5871**系统接口:** 此接口为系统接口。 5872 5873**系统能力:** SystemCapability.Multimedia.Camera.Core 5874 5875**参数:** 5876 5877| 参数名 | 类型 | 必填 | 说明 | 5878| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 5879| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 5880| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5881 5882**错误码:** 5883 5884以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5885 5886| 错误码ID | 错误信息 | 5887|---------| --------------- | 5888| 202 | Not System Application. | 5889 5890**示例:** 5891 5892```ts 5893import { BusinessError } from '@kit.BasicServicesKit'; 5894 5895function callback(err: BusinessError): void { 5896 console.error(`Professional photo session error code: ${err.code}`); 5897} 5898 5899function registerSessionError(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5900 professionalPhotoSession.on('error', callback); 5901} 5902``` 5903 5904### off('error')<sup>12+</sup> 5905 5906off(type: 'error', callback?: ErrorCallback): void 5907 5908注销监听专业拍照会话的错误事件,通过注册回调函数获取结果。 5909 5910**系统接口:** 此接口为系统接口。 5911 5912**系统能力:** SystemCapability.Multimedia.Camera.Core 5913 5914**参数:** 5915 5916| 参数名 | 类型 | 必填 | 说明 | 5917| -------- | ------------------------ | ---- | ------------------------------ | 5918| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 5919| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匿名函数。 | 5920 5921**错误码:** 5922 5923以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5924 5925| 错误码ID | 错误信息 | 5926|---------| --------------- | 5927| 202 | Not System Application. | 5928 5929**示例:** 5930 5931```ts 5932function unregisterSessionError(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5933 professionalPhotoSession.off('error'); 5934} 5935``` 5936 5937### on('focusStateChange')<sup>12+</sup> 5938 5939on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 5940 5941监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 5942 5943**系统接口:** 此接口为系统接口。 5944 5945**系统能力:** SystemCapability.Multimedia.Camera.Core 5946 5947**参数:** 5948 5949| 参数名 | 类型 | 必填 | 说明 | 5950| -------- | ---------------- | ---- | ------------------------ | 5951| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 5952| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 5953 5954**错误码:** 5955 5956以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5957 5958| 错误码ID | 错误信息 | 5959|---------| --------------- | 5960| 202 | Not System Application. | 5961 5962**示例:** 5963 5964```ts 5965import { BusinessError } from '@kit.BasicServicesKit'; 5966 5967function callback(err: BusinessError, focusState: camera.FocusState): void { 5968 if (err !== undefined && err.code !== 0) { 5969 console.error(`Callback Error, errorCode: ${err.code}`); 5970 return; 5971 } 5972 console.info(`Focus state: ${focusState}`); 5973} 5974 5975function registerFocusStateChange(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5976 professionalPhotoSession.on('focusStateChange', callback); 5977} 5978``` 5979 5980### off('focusStateChange')<sup>12+</sup> 5981 5982off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 5983 5984注销监听相机对焦的状态变化。 5985 5986**系统接口:** 此接口为系统接口。 5987 5988**系统能力:** SystemCapability.Multimedia.Camera.Core 5989 5990**参数:** 5991 5992| 参数名 | 类型 | 必填 | 说明 | 5993| -------- | ----------------------------------------- | ---- | ------------------------ | 5994| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 5995| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 5996 5997**错误码:** 5998 5999以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6000 6001| 错误码ID | 错误信息 | 6002|---------| --------------- | 6003| 202 | Not System Application. | 6004 6005**示例:** 6006 6007```ts 6008function unregisterFocusStateChange(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6009 professionalPhotoSession.off('focusStateChange'); 6010} 6011``` 6012 6013### on('smoothZoomInfoAvailable')<sup>12+</sup> 6014 6015on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 6016 6017监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 6018 6019**系统接口:** 此接口为系统接口。 6020 6021**系统能力:** SystemCapability.Multimedia.Camera.Core 6022 6023**参数:** 6024 6025| 参数名 | 类型 | 必填 | 说明 | 6026| -------- | ----------------------- | ---- | ------------------------ | 6027| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 6028| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 6029 6030**错误码:** 6031 6032以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6033 6034| 错误码ID | 错误信息 | 6035|---------| --------------- | 6036| 202 | Not System Application. | 6037 6038**示例:** 6039 6040```ts 6041import { BusinessError } from '@kit.BasicServicesKit'; 6042 6043function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 6044 if (err !== undefined && err.code !== 0) { 6045 console.error(`Callback Error, errorCode: ${err.code}`); 6046 return; 6047 } 6048 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 6049} 6050 6051function registerSmoothZoomInfo(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6052 professionalPhotoSession.on('smoothZoomInfoAvailable', callback); 6053} 6054``` 6055 6056### off('smoothZoomInfoAvailable')<sup>12+</sup> 6057 6058off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 6059 6060注销监听相机平滑变焦的状态变化。 6061 6062**系统接口:** 此接口为系统接口。 6063 6064**系统能力:** SystemCapability.Multimedia.Camera.Core 6065 6066**参数:** 6067 6068| 参数名 | 类型 | 必填 | 说明 | 6069| -------- | ----------------------------------------- | ---- | ------------------------ | 6070| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 6071| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,可选,有就是匹配on('smoothZoomInfoAvailable') callback(callback对象不可是匿名函数)。 | 6072 6073**错误码:** 6074 6075以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6076 6077| 错误码ID | 错误信息 | 6078|---------| --------------- | 6079| 202 | Not System Application. | 6080 6081**示例:** 6082 6083```ts 6084function unregisterSmoothZoomInfo(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6085 professionalPhotoSession.off('smoothZoomInfoAvailable'); 6086} 6087``` 6088 6089### on('isoInfoChange')<sup>12+</sup> 6090 6091on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 6092 6093监听自动ISO变化事件,通过注册回调函数获取实时ISO信息。使用callback异步回调。 6094 6095**系统接口:** 此接口为系统接口。 6096 6097**系统能力:** SystemCapability.Multimedia.Camera.Core 6098 6099**参数:** 6100 6101| 参数名 | 类型 | 必填 | 说明 | 6102| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6103| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 6104| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 是 | 回调函数,用于获取ISO信息。 | 6105 6106**错误码:** 6107 6108| 错误码ID | 错误信息 | 6109| ------- | ---------------------- | 6110| 202 | Not System Application. | 6111 6112**示例:** 6113 6114```ts 6115import { BusinessError } from '@kit.BasicServicesKit'; 6116 6117function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 6118 if (err !== undefined && err.code !== 0) { 6119 console.error(`Callback Error, errorCode: ${err.code}`); 6120 return; 6121 } 6122 console.log(`ISO value: ${info.iso}`); 6123} 6124 6125function registerIsoInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6126 professionalPhotoSession.on('isoInfoChange', isoInfoCallback); 6127} 6128``` 6129 6130### off('isoInfoChange')<sup>12+</sup> 6131 6132off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 6133 6134注销监听ISO信息事件,通过注册回调函数来注销。 6135 6136**系统接口:** 此接口为系统接口。 6137 6138**系统能力:** SystemCapability.Multimedia.Camera.Core 6139 6140**参数:** 6141 6142| 参数名 | 类型 | 必填 | 说明 | 6143| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6144| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 6145| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 否 | 回调函数,可选,用于匹配on('isoInfoChange')的callback。 | 6146 6147**错误码:** 6148 6149| 错误码ID | 错误信息 | 6150| ------- | ---------------------- | 6151| 202 | Not System Application. | 6152 6153**示例:** 6154 6155```ts 6156function unregisterIsoInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6157 professionalPhotoSession.off('isoInfoChange'); 6158} 6159``` 6160 6161### on('exposureInfoChange')<sup>12+</sup> 6162 6163on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 6164 6165监听曝光信息事件,通过注册回调函数获取曝光信息。使用callback异步回调。 6166 6167**系统接口:** 此接口为系统接口。 6168 6169**系统能力:** SystemCapability.Multimedia.Camera.Core 6170 6171**参数:** 6172 6173| 参数名 | 类型 | 必填 | 说明 | 6174| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6175| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 6176| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 是 | 回调函数,用于获取曝光信息。 | 6177 6178**错误码:** 6179 6180| 错误码ID | 错误信息 | 6181| ------- | ---------------------- | 6182| 202 | Not System Application. | 6183 6184**示例:** 6185 6186```ts 6187import { BusinessError } from '@kit.BasicServicesKit'; 6188 6189function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 6190 if (err !== undefined && err.code !== 0) { 6191 console.error(`Callback Error, errorCode: ${err.code}`); 6192 return; 6193 } 6194 console.log(`exposureTimeValue: ${info.exposureTime}`); 6195} 6196 6197function registerExposureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6198 professionalPhotoSession.on('exposureInfoChange', exposureInfoCallback); 6199} 6200``` 6201 6202### off('exposureInfoChange')<sup>12+</sup> 6203 6204off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 6205 6206注销监听曝光信息事件,通过注册回调函数来注销。 6207 6208**系统接口:** 此接口为系统接口。 6209 6210**系统能力:** SystemCapability.Multimedia.Camera.Core 6211 6212**参数:** 6213 6214| 参数名 | 类型 | 必填 | 说明 | 6215| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6216| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 6217| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 否 | 回调函数,可选,用于匹配on('exposureInfoChange')的callback。 | 6218 6219**错误码:** 6220 6221| 错误码ID | 错误信息 | 6222| ------- | ---------------------- | 6223| 202 | Not System Application. | 6224 6225**示例:** 6226 6227```ts 6228function unregisterExposureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6229 professionalPhotoSession.off('exposureInfoChange'); 6230} 6231``` 6232 6233### on('apertureInfoChange')<sup>12+</sup> 6234 6235on(type: 'apertureInfoChange', callback: AsyncCallback\<ApertureInfo\>): void 6236 6237监听物理光圈变化事件,通过注册回调函数获取实时物理光圈信息。使用callback异步回调。 6238 6239**系统接口:** 此接口为系统接口。 6240 6241**系统能力:** SystemCapability.Multimedia.Camera.Core 6242 6243**参数:** 6244 6245| 参数名 | 类型 | 必填 | 说明 | 6246| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6247| type | string | 是 | 监听事件,固定为'apertureInfoChange'。 | 6248| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| 是 | 回调函数,用于获取物理光圈信息。 | 6249 6250**错误码:** 6251 6252| 错误码ID | 错误信息 | 6253| ------- | ---------------------- | 6254| 202 | Not System Application. | 6255 6256**示例:** 6257 6258```ts 6259import { BusinessError } from '@kit.BasicServicesKit'; 6260 6261function apertureInfoCallback(err: BusinessError, info: camera.ApertureInfo): void { 6262 if (err !== undefined && err.code !== 0) { 6263 console.error(`Callback Error, errorCode: ${err.code}`); 6264 return; 6265 } 6266 console.log(`Aperture value: ${info.aperture}`); 6267} 6268 6269function registerApertureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6270 professionalPhotoSession.on('apertureInfoChange', apertureInfoCallback); 6271} 6272``` 6273 6274### off('apertureInfoChange')<sup>12+</sup> 6275 6276off(type: 'apertureInfoChange', callback?: AsyncCallback\<ApertureInfo\>): void 6277 6278注销监听物理光圈变化事件,通过注册回调函数来注销。 6279 6280**系统接口:** 此接口为系统接口。 6281 6282**系统能力:** SystemCapability.Multimedia.Camera.Core 6283 6284**参数:** 6285 6286| 参数名 | 类型 | 必填 | 说明 | 6287| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6288| type | string | 是 | 监听事件,固定为'apertureInfoChange'。 | 6289| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| 否 | 回调函数,可选,用于匹配on('apertureInfoChange')的callback。 | 6290 6291**错误码:** 6292 6293| 错误码ID | 错误信息 | 6294| ------- | ---------------------- | 6295| 202 | Not System Application. | 6296 6297**示例:** 6298 6299```ts 6300function unregisterApertureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6301 professionalPhotoSession.off('apertureInfoChange'); 6302} 6303``` 6304 6305### on('luminationInfoChange')<sup>12+</sup> 6306 6307on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 6308 6309监听光照变化事件,通过注册回调函数获取实时光照参数。使用callback异步回调。 6310 6311**系统接口:** 此接口为系统接口。 6312 6313**系统能力:** SystemCapability.Multimedia.Camera.Core 6314 6315**参数:** 6316 6317| 参数名 | 类型 | 必填 | 说明 | 6318| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6319| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 6320| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 是 | 回调函数,用于获取光照参数。 | 6321 6322**错误码:** 6323 6324| 错误码ID | 错误信息 | 6325| ------- | ---------------------- | 6326| 202 | Not System Application. | 6327 6328**示例:** 6329 6330```ts 6331import { BusinessError } from '@kit.BasicServicesKit'; 6332 6333function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 6334 if (err !== undefined && err.code !== 0) { 6335 console.error(`Callback Error, errorCode: ${err.code}`); 6336 return; 6337 } 6338 console.log(`Lumination: ${info.lumination}`); 6339} 6340 6341function registerLuminationInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6342 professionalPhotoSession.on('luminationInfoChange', luminationInfoCallback); 6343} 6344``` 6345 6346### off('luminationInfoChange')<sup>12+</sup> 6347 6348off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 6349 6350注销监听光照变化事件,通过注册回调函数来注销。 6351 6352**系统接口:** 此接口为系统接口。 6353 6354**系统能力:** SystemCapability.Multimedia.Camera.Core 6355 6356**参数:** 6357 6358| 参数名 | 类型 | 必填 | 说明 | 6359| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6360| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 6361| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 否 | 回调函数,可选,用于匹配on('luminationInfoChange')的callback。 | 6362 6363**错误码:** 6364 6365| 错误码ID | 错误信息 | 6366| ------- | ---------------------- | 6367| 202 | Not System Application. | 6368 6369**示例:** 6370 6371```ts 6372function unregisterLuminationInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6373 professionalPhotoSession.off('luminationInfoChange'); 6374} 6375``` 6376 6377## ProfessionalVideoSession<sup>12+</sup> 6378 6379ProfessionalVideoSession extends Session, AutoExposure, ManualExposure, Focus, ManualFocus, WhiteBalance, ManualIso, Flash, Zoom, ColorEffect, Aperture 6380 6381专业录像模式会话类,继承自[Session](js-apis-camera.md#session12),用于设置专业录像模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 6382 6383### on('error')<sup>12+</sup> 6384 6385on(type: 'error', callback: ErrorCallback): void 6386 6387监听专业录像会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 6388 6389**系统接口:** 此接口为系统接口。 6390 6391**系统能力:** SystemCapability.Multimedia.Camera.Core 6392 6393**参数:** 6394 6395| 参数名 | 类型 | 必填 | 说明 | 6396| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 6397| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 6398| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 6399 6400**错误码:** 6401 6402以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6403 6404| 错误码ID | 错误信息 | 6405|---------| --------------- | 6406| 202 | Not System Application. | 6407 6408**示例:** 6409 6410```ts 6411import { BusinessError } from '@kit.BasicServicesKit'; 6412 6413function callback(err: BusinessError): void { 6414 console.error(`Professional video session error code: ${err.code}`); 6415} 6416 6417function registerSessionError(professionalVideoSession: camera.ProfessionalVideoSession): void { 6418 professionalVideoSession.on('error', callback); 6419} 6420``` 6421 6422### off('error')<sup>12+</sup> 6423 6424off(type: 'error', callback?: ErrorCallback): void 6425 6426注销监听专业录像会话的错误事件,通过注册回调函数获取结果。 6427 6428**系统接口:** 此接口为系统接口。 6429 6430**系统能力:** SystemCapability.Multimedia.Camera.Core 6431 6432**参数:** 6433 6434| 参数名 | 类型 | 必填 | 说明 | 6435| -------- | ------------------------ | ---- | ------------------------------ | 6436| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 6437| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匿名函数。 | 6438 6439**错误码:** 6440 6441以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6442 6443| 错误码ID | 错误信息 | 6444|---------| --------------- | 6445| 202 | Not System Application. | 6446 6447**示例:** 6448 6449```ts 6450function unregisterSessionError(professionalVideoSession: camera.ProfessionalVideoSession): void { 6451 professionalVideoSession.off('error'); 6452} 6453``` 6454 6455### on('focusStateChange')<sup>12+</sup> 6456 6457on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 6458 6459监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 6460 6461**系统接口:** 此接口为系统接口。 6462 6463**系统能力:** SystemCapability.Multimedia.Camera.Core 6464 6465**参数:** 6466 6467| 参数名 | 类型 | 必填 | 说明 | 6468| -------- | ---------------- | ---- | ------------------------ | 6469| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 6470| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 6471 6472**错误码:** 6473 6474以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6475 6476| 错误码ID | 错误信息 | 6477|---------| --------------- | 6478| 202 | Not System Application. | 6479 6480**示例:** 6481 6482```ts 6483import { BusinessError } from '@kit.BasicServicesKit'; 6484 6485function callback(err: BusinessError, focusState: camera.FocusState): void { 6486 if (err !== undefined && err.code !== 0) { 6487 console.error(`Callback Error, errorCode: ${err.code}`); 6488 return; 6489 } 6490 console.info(`Focus state: ${focusState}`); 6491} 6492 6493function registerFocusStateChange(professionalVideoSession: camera.ProfessionalVideoSession): void { 6494 professionalVideoSession.on('focusStateChange', callback); 6495} 6496``` 6497 6498### off('focusStateChange')<sup>12+</sup> 6499 6500off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 6501 6502注销监听相机对焦的状态变化。 6503 6504**系统接口:** 此接口为系统接口。 6505 6506**系统能力:** SystemCapability.Multimedia.Camera.Core 6507 6508**参数:** 6509 6510| 参数名 | 类型 | 必填 | 说明 | 6511| -------- | ----------------------------------------- | ---- | ------------------------ | 6512| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 6513| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 6514 6515**错误码:** 6516 6517以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6518 6519| 错误码ID | 错误信息 | 6520|---------| --------------- | 6521| 202 | Not System Application. | 6522 6523**示例:** 6524 6525```ts 6526function unregisterFocusStateChange(professionalVideoSession: camera.ProfessionalVideoSession): void { 6527 professionalVideoSession.off('focusStateChange'); 6528} 6529``` 6530 6531### on('smoothZoomInfoAvailable')<sup>12+</sup> 6532 6533on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 6534 6535监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 6536 6537**系统接口:** 此接口为系统接口。 6538 6539**系统能力:** SystemCapability.Multimedia.Camera.Core 6540 6541**参数:** 6542 6543| 参数名 | 类型 | 必填 | 说明 | 6544| -------- | ----------------------- | ---- | ------------------------ | 6545| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 6546| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 6547 6548**错误码:** 6549 6550以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6551 6552| 错误码ID | 错误信息 | 6553|---------| --------------- | 6554| 202 | Not System Application. | 6555 6556**示例:** 6557 6558```ts 6559import { BusinessError } from '@kit.BasicServicesKit'; 6560 6561function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 6562 if (err !== undefined && err.code !== 0) { 6563 console.error(`Callback Error, errorCode: ${err.code}`); 6564 return; 6565 } 6566 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 6567} 6568 6569function registerSmoothZoomInfo(professionalVideoSession: camera.ProfessionalVideoSession): void { 6570 professionalVideoSession.on('smoothZoomInfoAvailable', callback); 6571} 6572``` 6573 6574### off('smoothZoomInfoAvailable')<sup>12+</sup> 6575 6576off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 6577 6578注销监听相机平滑变焦的状态变化。 6579 6580**系统接口:** 此接口为系统接口。 6581 6582**系统能力:** SystemCapability.Multimedia.Camera.Core 6583 6584**参数:** 6585 6586| 参数名 | 类型 | 必填 | 说明 | 6587| -------- | ----------------------------------------- | ---- | ------------------------ | 6588| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 6589| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,可选,有就是匹配on('smoothZoomInfoAvailable') callback(callback对象不可是匿名函数)。 | 6590 6591**错误码:** 6592 6593以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6594 6595| 错误码ID | 错误信息 | 6596|---------| --------------- | 6597| 202 | Not System Application. | 6598 6599**示例:** 6600 6601```ts 6602function unregisterSmoothZoomInfo(professionalVideoSession: camera.ProfessionalVideoSession): void { 6603 professionalVideoSession.off('smoothZoomInfoAvailable'); 6604} 6605``` 6606 6607### on('isoInfoChange')<sup>12+</sup> 6608 6609on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 6610 6611监听自动ISO变化事件,通过注册回调函数获取实时ISO信息。使用callback异步回调。 6612 6613**系统接口:** 此接口为系统接口。 6614 6615**系统能力:** SystemCapability.Multimedia.Camera.Core 6616 6617**参数:** 6618 6619| 参数名 | 类型 | 必填 | 说明 | 6620| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6621| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 6622| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 是 | 回调函数,用于获取ISO信息。 | 6623 6624**错误码:** 6625 6626| 错误码ID | 错误信息 | 6627| ------- | ---------------------- | 6628| 202 | Not System Application. | 6629 6630**示例:** 6631 6632```ts 6633import { BusinessError } from '@kit.BasicServicesKit'; 6634 6635function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 6636 if (err !== undefined && err.code !== 0) { 6637 console.error(`Callback Error, errorCode: ${err.code}`); 6638 return; 6639 } 6640 console.log(`ISO value: ${info.iso}`); 6641} 6642 6643function registerIsoInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6644 professionalVideoSession.on('isoInfoChange', isoInfoCallback); 6645} 6646``` 6647 6648### off('isoInfoChange')<sup>12+</sup> 6649 6650off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 6651 6652注销监听ISO信息事件,通过注册回调函数来注销。 6653 6654**系统接口:** 此接口为系统接口。 6655 6656**系统能力:** SystemCapability.Multimedia.Camera.Core 6657 6658**参数:** 6659 6660| 参数名 | 类型 | 必填 | 说明 | 6661| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6662| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 6663| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 否 | 回调函数,可选,用于匹配on('isoInfoChange')的callback。 | 6664 6665**错误码:** 6666 6667| 错误码ID | 错误信息 | 6668| ------- | ---------------------- | 6669| 202 | Not System Application. | 6670 6671**示例:** 6672 6673```ts 6674function unregisterIsoInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6675 professionalVideoSession.off('isoInfoChange'); 6676} 6677``` 6678 6679### on('exposureInfoChange')<sup>12+</sup> 6680 6681on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 6682 6683监听曝光信息事件,通过注册回调函数获取曝光信息。使用callback异步回调。 6684 6685**系统接口:** 此接口为系统接口。 6686 6687**系统能力:** SystemCapability.Multimedia.Camera.Core 6688 6689**参数:** 6690 6691| 参数名 | 类型 | 必填 | 说明 | 6692| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6693| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 6694| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 是 | 回调函数,用于获取曝光信息。 | 6695 6696**错误码:** 6697 6698| 错误码ID | 错误信息 | 6699| ------- | ---------------------- | 6700| 202 | Not System Application. | 6701 6702**示例:** 6703 6704```ts 6705import { BusinessError } from '@kit.BasicServicesKit'; 6706 6707function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 6708 if (err !== undefined && err.code !== 0) { 6709 console.error(`Callback Error, errorCode: ${err.code}`); 6710 return; 6711 } 6712 console.log(`exposureTimeValue: ${info.exposureTime}`); 6713} 6714 6715function registerExposureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6716 professionalVideoSession.on('exposureInfoChange', exposureInfoCallback); 6717} 6718``` 6719 6720### off('exposureInfoChange')<sup>12+</sup> 6721 6722off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 6723 6724注销监听曝光信息事件,通过注册回调函数来注销。 6725 6726**系统接口:** 此接口为系统接口。 6727 6728**系统能力:** SystemCapability.Multimedia.Camera.Core 6729 6730**参数:** 6731 6732| 参数名 | 类型 | 必填 | 说明 | 6733| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6734| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 6735| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 否 | 回调函数,可选,用于匹配on('exposureInfoChange')的callback。 | 6736 6737**错误码:** 6738 6739| 错误码ID | 错误信息 | 6740| ------- | ---------------------- | 6741| 202 | Not System Application. | 6742 6743**示例:** 6744 6745```ts 6746function unregisterExposureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6747 professionalVideoSession.off('exposureInfoChange'); 6748} 6749``` 6750 6751### on('apertureInfoChange')<sup>12+</sup> 6752 6753on(type: 'apertureInfoChange', callback: AsyncCallback\<ApertureInfo\>): void 6754 6755监听物理光圈变化事件,通过注册回调函数获取物理光圈信息。使用callback异步回调。 6756 6757**系统接口:** 此接口为系统接口。 6758 6759**系统能力:** SystemCapability.Multimedia.Camera.Core 6760 6761**参数:** 6762 6763| 参数名 | 类型 | 必填 | 说明 | 6764| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6765| type | string | 是 | 监听事件,固定为'apertureInfoChange'。 | 6766| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| 是 | 回调函数,用于获取物理光圈信息。 | 6767 6768**错误码:** 6769 6770| 错误码ID | 错误信息 | 6771| ------- | ---------------------- | 6772| 202 | Not System Application. | 6773 6774**示例:** 6775 6776```ts 6777import { BusinessError } from '@kit.BasicServicesKit'; 6778 6779function apertureInfoCallback(err: BusinessError, info: camera.ApertureInfo): void { 6780 if (err !== undefined && err.code !== 0) { 6781 console.error(`Callback Error, errorCode: ${err.code}`); 6782 return; 6783 } 6784 console.log(`Aperture value: ${info.aperture}`); 6785} 6786 6787function registerApertureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6788 professionalVideoSession.on('apertureInfoChange', apertureInfoCallback); 6789} 6790``` 6791 6792### off('apertureInfoChange')<sup>12+</sup> 6793 6794off(type: 'apertureInfoChange', callback?: AsyncCallback\<ApertureInfo\>): void 6795 6796注销监听物理光圈变化事件,通过注册回调函数来注销。 6797 6798**系统接口:** 此接口为系统接口。 6799 6800**系统能力:** SystemCapability.Multimedia.Camera.Core 6801 6802**参数:** 6803 6804| 参数名 | 类型 | 必填 | 说明 | 6805| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6806| type | string | 是 | 监听事件,固定为'apertureInfoChange'。 | 6807| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| 否 | 回调函数,可选,用于匹配on('apertureInfoChange')的callback。 | 6808 6809**错误码:** 6810 6811| 错误码ID | 错误信息 | 6812| ------- | ---------------------- | 6813| 202 | Not System Application. | 6814 6815**示例:** 6816 6817```ts 6818function unregisterApertureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6819 professionalVideoSession.off('apertureInfoChange'); 6820} 6821``` 6822 6823### on('luminationInfoChange')<sup>12+</sup> 6824 6825on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 6826 6827监听光照变化事件,通过注册回调函数获取光照参数。使用callback异步回调。 6828 6829**系统接口:** 此接口为系统接口。 6830 6831**系统能力:** SystemCapability.Multimedia.Camera.Core 6832 6833**参数:** 6834 6835| 参数名 | 类型 | 必填 | 说明 | 6836| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6837| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 6838| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 是 | 回调函数,用于获取光照参数。 | 6839 6840**错误码:** 6841 6842| 错误码ID | 错误信息 | 6843| ------- | ---------------------- | 6844| 202 | Not System Application. | 6845 6846**示例:** 6847 6848```ts 6849import { BusinessError } from '@kit.BasicServicesKit'; 6850 6851function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 6852 if (err !== undefined && err.code !== 0) { 6853 console.error(`Callback Error, errorCode: ${err.code}`); 6854 return; 6855 } 6856 console.log(`Lumination: ${info.lumination}`); 6857} 6858 6859function registerLuminationInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6860 professionalVideoSession.on('luminationInfoChange', luminationInfoCallback); 6861} 6862``` 6863 6864### off('luminationInfoChange')<sup>12+</sup> 6865 6866off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 6867 6868注销监听光照变化事件,通过注册回调函数来注销。 6869 6870**系统接口:** 此接口为系统接口。 6871 6872**系统能力:** SystemCapability.Multimedia.Camera.Core 6873 6874**参数:** 6875 6876| 参数名 | 类型 | 必填 | 说明 | 6877| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6878| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 6879| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 否 | 回调函数,可选,用于匹配on('luminationInfoChange')的callback。 | 6880 6881**错误码:** 6882 6883| 错误码ID | 错误信息 | 6884| ------- | ---------------------- | 6885| 202 | Not System Application. | 6886 6887**示例:** 6888 6889```ts 6890function unregisterLuminationInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 6891 professionalVideoSession.off('luminationInfoChange'); 6892} 6893``` 6894 6895## MacroPhotoSession<sup>12+</sup> 6896 6897MacroPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ManualFocus 6898 6899微距拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置微距拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 6900 6901### on('error')<sup>12+</sup> 6902 6903on(type: 'error', callback: ErrorCallback): void 6904 6905监听微距拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 6906 6907**系统接口:** 此接口为系统接口。 6908 6909**系统能力:** SystemCapability.Multimedia.Camera.Core 6910 6911**参数:** 6912 6913| 参数名 | 类型 | 必填 | 说明 | 6914|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 6915| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 6916| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 6917 6918**错误码:** 6919 6920以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6921 6922| 错误码ID | 错误信息 | 6923|-------|----------------------------| 6924| 202 | Not System Application. | 6925 6926**示例:** 6927 6928```ts 6929import { BusinessError } from '@kit.BasicServicesKit'; 6930 6931function callback(err: BusinessError): void { 6932 console.error(`MacroPhotoSession error code: ${err.code}`); 6933} 6934 6935function registerSessionError(macroPhotoSession: camera.MacroPhotoSession): void { 6936 macroPhotoSession.on('error', callback); 6937} 6938``` 6939 6940### off('error')<sup>12+</sup> 6941 6942off(type: 'error', callback?: ErrorCallback): void 6943 6944注销监听微距拍照会话的错误事件,通过注册回调函数获取结果。 6945 6946**系统接口:** 此接口为系统接口。 6947 6948**系统能力:** SystemCapability.Multimedia.Camera.Core 6949 6950**参数:** 6951 6952| 参数名 | 类型 | 必填 | 说明 | 6953|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 6954| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 6955| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 6956 6957**错误码:** 6958 6959以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6960 6961| 错误码ID | 错误信息 | 6962|-------|----------------------------| 6963| 202 | Not System Application. | 6964 6965**示例:** 6966 6967```ts 6968function unregisterSessionError(macroPhotoSession: camera.MacroPhotoSession): void { 6969 macroPhotoSession.off('error'); 6970} 6971``` 6972 6973### on('focusStateChange')<sup>12+</sup> 6974 6975on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 6976 6977监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 6978 6979**系统接口:** 此接口为系统接口。 6980 6981**系统能力:** SystemCapability.Multimedia.Camera.Core 6982 6983**参数:** 6984 6985| 参数名 | 类型 | 必填 | 说明 | 6986|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 6987| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 6988| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 6989 6990**错误码:** 6991 6992以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6993 6994| 错误码ID | 错误信息 | 6995|-------|----------------------------| 6996| 202 | Not System Application. | 6997 6998**示例:** 6999 7000```ts 7001import { BusinessError } from '@kit.BasicServicesKit'; 7002 7003function callback(err: BusinessError, focusState: camera.FocusState): void { 7004 if (err !== undefined && err.code !== 0) { 7005 console.error(`Callback Error, errorCode: ${err.code}`); 7006 return; 7007 } 7008 console.info(`Focus state: ${focusState}`); 7009} 7010 7011function registerFocusStateChange(macroPhotoSession: camera.MacroPhotoSession): void { 7012 macroPhotoSession.on('focusStateChange', callback); 7013} 7014``` 7015 7016### off('focusStateChange')<sup>12+</sup> 7017 7018off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7019 7020注销监听相机对焦的状态变化。 7021 7022**系统接口:** 此接口为系统接口。 7023 7024**系统能力:** SystemCapability.Multimedia.Camera.Core 7025 7026**参数:** 7027 7028| 参数名 | 类型 | 必填 | 说明 | 7029|-----------|---------------------------------------------|----|--------------------------------------------------------------| 7030| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 7031| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7032 7033**错误码:** 7034 7035以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7036 7037| 错误码ID | 错误信息 | 7038|-------|----------------------------| 7039| 202 | Not System Application. | 7040 7041**示例:** 7042 7043```ts 7044function unregisterFocusStateChange(macroPhotoSession: camera.MacroPhotoSession): void { 7045 macroPhotoSession.off('focusStateChange'); 7046} 7047``` 7048 7049### on('smoothZoomInfoAvailable')<sup>12+</sup> 7050 7051on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 7052 7053监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 7054 7055**系统接口:** 此接口为系统接口。 7056 7057**系统能力:** SystemCapability.Multimedia.Camera.Core 7058 7059**参数:** 7060 7061| 参数名 | 类型 | 必填 | 说明 | 7062| -------- | ----------------------- | ---- | ------------------------ | 7063| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 7064| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 7065 7066**错误码:** 7067 7068以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7069 7070| 错误码ID | 错误信息 | 7071|-------|----------------------------| 7072| 202 | Not System Application. | 7073 7074**示例:** 7075 7076```ts 7077import { BusinessError } from '@kit.BasicServicesKit'; 7078 7079function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 7080 if (err !== undefined && err.code !== 0) { 7081 console.error(`Callback Error, errorCode: ${err.code}`); 7082 return; 7083 } 7084 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 7085} 7086 7087function registerSmoothZoomInfo(macroPhotoSession: camera.MacroPhotoSession): void { 7088 macroPhotoSession.on('smoothZoomInfoAvailable', callback); 7089} 7090``` 7091 7092### off('smoothZoomInfoAvailable')<sup>12+</sup> 7093 7094off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 7095 7096注销监听相机平滑变焦的状态变化。 7097 7098**系统接口:** 此接口为系统接口。 7099 7100**系统能力:** SystemCapability.Multimedia.Camera.Core 7101 7102**参数:** 7103 7104| 参数名 | 类型 | 必填 | 说明 | 7105| -------- | ----------------------------------------- | ---- | ------------------------ | 7106| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 7107| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7108 7109**错误码:** 7110 7111以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7112 7113| 错误码ID | 错误信息 | 7114|-------|----------------------------| 7115| 202 | Not System Application. | 7116 7117**示例:** 7118 7119```ts 7120function unregisterSmoothZoomInfo(macroPhotoSession: camera.MacroPhotoSession): void { 7121 macroPhotoSession.off('smoothZoomInfoAvailable'); 7122} 7123``` 7124 7125## MacroVideoSession<sup>12+</sup> 7126 7127MacroVideoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ManualFocus 7128 7129微距录像模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置微距录像模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 7130 7131### on('error')<sup>12+</sup> 7132 7133on(type: 'error', callback: ErrorCallback): void 7134 7135监听微距录像会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 7136 7137**系统接口:** 此接口为系统接口。 7138 7139**系统能力:** SystemCapability.Multimedia.Camera.Core 7140 7141**参数:** 7142 7143| 参数名 | 类型 | 必填 | 说明 | 7144|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 7145| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 7146| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 7147 7148**错误码:** 7149 7150以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7151 7152| 错误码ID | 错误信息 | 7153|-------|----------------------------| 7154| 202 | Not System Application. | 7155 7156**示例:** 7157 7158```ts 7159import { BusinessError } from '@kit.BasicServicesKit'; 7160 7161function callback(err: BusinessError): void { 7162 console.error(`MacroPhotoSession error code: ${err.code}`); 7163} 7164 7165function registerSessionError(macroVideoSession: camera.MacroVideoSession): void { 7166 macroVideoSession.on('error', callback); 7167} 7168``` 7169 7170### off('error')<sup>12+</sup> 7171 7172off(type: 'error', callback?: ErrorCallback): void 7173 7174注销监听微距录像会话的错误事件,通过注册回调函数获取结果。 7175 7176**系统接口:** 此接口为系统接口。 7177 7178**系统能力:** SystemCapability.Multimedia.Camera.Core 7179 7180**参数:** 7181 7182| 参数名 | 类型 | 必填 | 说明 | 7183|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 7184| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 7185| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7186 7187**错误码:** 7188 7189以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7190 7191| 错误码ID | 错误信息 | 7192|-------|----------------------------| 7193| 202 | Not System Application. | 7194 7195**示例:** 7196 7197```ts 7198function unregisterSessionError(macroVideoSession: camera.MacroVideoSession): void { 7199 macroVideoSession.off('error'); 7200} 7201``` 7202 7203### on('focusStateChange')<sup>12+</sup> 7204 7205on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7206 7207监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 7208 7209**系统接口:** 此接口为系统接口。 7210 7211**系统能力:** SystemCapability.Multimedia.Camera.Core 7212 7213**参数:** 7214 7215| 参数名 | 类型 | 必填 | 说明 | 7216|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 7217| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 7218| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 7219 7220**错误码:** 7221 7222以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7223 7224| 错误码ID | 错误信息 | 7225|-------|----------------------------| 7226| 202 | Not System Application. | 7227 7228**示例:** 7229 7230```ts 7231import { BusinessError } from '@kit.BasicServicesKit'; 7232 7233function callback(err: BusinessError, focusState: camera.FocusState): void { 7234 if (err !== undefined && err.code !== 0) { 7235 console.error(`Callback Error, errorCode: ${err.code}`); 7236 return; 7237 } 7238 console.info(`Focus state: ${focusState}`); 7239} 7240 7241function registerFocusStateChange(macroVideoSession: camera.MacroVideoSession): void { 7242 macroVideoSession.on('focusStateChange', callback); 7243} 7244``` 7245 7246### off('focusStateChange')<sup>12+</sup> 7247 7248off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7249 7250注销监听相机对焦的状态变化。 7251 7252**系统接口:** 此接口为系统接口。 7253 7254**系统能力:** SystemCapability.Multimedia.Camera.Core 7255 7256**参数:** 7257 7258| 参数名 | 类型 | 必填 | 说明 | 7259|-----------|---------------------------------------------|----|--------------------------------------------------------------| 7260| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 7261| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7262 7263**错误码:** 7264 7265以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7266 7267| 错误码ID | 错误信息 | 7268|-------|----------------------------| 7269| 202 | Not System Application. | 7270 7271**示例:** 7272 7273```ts 7274function unregisterFocusStateChange(macroVideoSession: camera.MacroVideoSession): void { 7275 macroVideoSession.off('focusStateChange'); 7276} 7277``` 7278 7279### on('smoothZoomInfoAvailable')<sup>12+</sup> 7280 7281on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 7282 7283监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 7284 7285**系统接口:** 此接口为系统接口。 7286 7287**系统能力:** SystemCapability.Multimedia.Camera.Core 7288 7289**参数:** 7290 7291| 参数名 | 类型 | 必填 | 说明 | 7292| -------- | ----------------------- | ---- | ------------------------ | 7293| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 7294| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 7295 7296**错误码:** 7297 7298以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7299 7300| 错误码ID | 错误信息 | 7301|-------|----------------------------| 7302| 202 | Not System Application. | 7303 7304**示例:** 7305 7306```ts 7307import { BusinessError } from '@kit.BasicServicesKit'; 7308 7309function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 7310 if (err !== undefined && err.code !== 0) { 7311 console.error(`Callback Error, errorCode: ${err.code}`); 7312 return; 7313 } 7314 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 7315} 7316 7317function registerSmoothZoomInfo(macroVideoSession: camera.MacroVideoSession): void { 7318 macroVideoSession.on('smoothZoomInfoAvailable', callback); 7319} 7320``` 7321 7322### off('smoothZoomInfoAvailable')<sup>12+</sup> 7323 7324off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 7325 7326注销监听相机平滑变焦的状态变化。 7327 7328**系统接口:** 此接口为系统接口。 7329 7330**系统能力:** SystemCapability.Multimedia.Camera.Core 7331 7332**参数:** 7333 7334| 参数名 | 类型 | 必填 | 说明 | 7335| -------- | ----------------------------------------- | ---- | ------------------------ | 7336| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 7337| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7338 7339**错误码:** 7340 7341以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7342 7343| 错误码ID | 错误信息 | 7344|-------|----------------------------| 7345| 202 | Not System Application. | 7346 7347**示例:** 7348 7349```ts 7350function unregisterSmoothZoomInfo(macroVideoSession: camera.MacroVideoSession): void { 7351 macroVideoSession.off('smoothZoomInfoAvailable'); 7352} 7353``` 7354 7355## FlashQuery<sup>12+</sup> 7356 7357此接口提供了查阅设备闪光灯信息相应的方法,包括是否支持lcd闪光灯。 7358 7359### isLcdFlashSupported<sup>12+</sup> 7360 7361isLcdFlashSupported(): boolean 7362 7363查询是否支持lcd闪光灯。 7364 7365**系统接口:** 此接口为系统接口。 7366 7367**系统能力:** SystemCapability.Multimedia.Camera.Core 7368 7369**返回值:** 7370 7371| 类型 | 说明 | 7372| -------------- | ----------------------- | 7373| boolean | 查询是否支持lcd闪光灯。| 7374 7375**错误码:** 7376 7377以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7378 7379| 错误码ID | 错误信息 | 7380| --------------- | --------------- | 7381| 202 | Not System Application. | 7382| 7400103 | Session not config, only throw in session usage. | 7383 7384**示例:** 7385 7386```ts 7387function isLcdFlashSupported(nightPhotoSession: camera.NightPhotoSession): boolean { 7388 return nightPhotoSession.isLcdFlashSupported(); 7389} 7390``` 7391 7392## TimeLapseRecordState<sup>12+</sup> 7393 7394枚举,延时摄影录制状态。 7395 7396**系统接口:** 此接口为系统接口。 7397 7398**系统能力:** SystemCapability.Multimedia.Camera.Core 7399 7400| 名称 | 值 | 说明 | 7401| ----------------------------- | ---- | ----------- | 7402| IDLE | 0 | 未录制 | 7403| RECORDING | 1 | 录制中 | 7404 7405## TimeLapsePreviewType<sup>12+</sup> 7406 7407枚举,延时摄影预览类型,影响拍摄算法。 7408 7409**系统接口:** 此接口为系统接口。 7410 7411**系统能力:** SystemCapability.Multimedia.Camera.Core 7412 7413| 名称 | 值 | 说明 | 7414| ----------------------------- | ---- | ----------- | 7415| DARK | 1 | 暗光环境,指光照较差的场景,比如夜晚或暗处。 | 7416| LIGHT | 2 | 亮光环境,指光照较好的场景,比如白天或灯光下。 | 7417 7418## TryAEInfo<sup>12+</sup> 7419 7420TryAE参数信息,TryAE是指延时摄影时硬件会根据环境光照变化上报状态的操作。 7421 7422**系统接口:** 此接口为系统接口。 7423 7424**系统能力:** SystemCapability.Multimedia.Camera.Core 7425 7426| 名称 | 类型 | 只读 | 可选 | 说明 | 7427| ---- | ------- | ---- |--| -------------- | 7428| isTryAEDone | boolean | 是 | 否 | TryAE是否完成。 | 7429| isTryAEHintNeeded | boolean | 是 | 是 | 是否需要TryAE。 | 7430| previewType | [TimeLapsePreviewType](#timelapsepreviewtype12) | 是 | 是 | 预览类型。 | 7431| captureInterval | number | 是 | 是 | 拍摄间隔,单位毫秒(ms)。 | 7432 7433## TimeLapsePhotoSession<sup>12+</sup> 7434 7435TimeLapsePhotoSession extends Session, Focus, ManualFocus, AutoExposure, ManualExposure, ManualIso, WhiteBalance, Zoom, ColorEffect 7436 7437延时摄影会话类,继承自[Session](js-apis-camera.md#session12),用于设置延时摄影会话的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 7438 7439### on('error')<sup>12+</sup> 7440 7441on(type: 'error', callback: ErrorCallback): void 7442 7443监听延时摄影会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 7444 7445**系统接口:** 此接口为系统接口。 7446 7447**系统能力:** SystemCapability.Multimedia.Camera.Core 7448 7449**参数:** 7450 7451| 参数名 | 类型 | 必填 | 说明 | 7452| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 7453| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 7454| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 7455 7456**错误码:** 7457 7458以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7459 7460| 错误码ID | 错误信息 | 7461|---------| --------------- | 7462| 202 | Not System Application. | 7463 7464**示例:** 7465 7466```ts 7467import { BusinessError } from '@kit.BasicServicesKit'; 7468 7469function callback(err: BusinessError): void { 7470 console.error(`Time lapse photo session error code: ${err.code}`); 7471} 7472 7473function registerSessionError(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7474 timeLapsePhotoSession.on('error', callback); 7475} 7476``` 7477 7478### off('error')<sup>12+</sup> 7479 7480off(type: 'error', callback?: ErrorCallback): void 7481 7482注销监听延时摄影会话的错误事件,通过注册回调函数获取结果。 7483 7484**系统接口:** 此接口为系统接口。 7485 7486**系统能力:** SystemCapability.Multimedia.Camera.Core 7487 7488**参数:** 7489 7490| 参数名 | 类型 | 必填 | 说明 | 7491| -------- | ------------------------ | ---- | ------------------------------ | 7492| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 7493| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匿名函数。 | 7494 7495**错误码:** 7496 7497以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7498 7499| 错误码ID | 错误信息 | 7500|---------| --------------- | 7501| 202 | Not System Application. | 7502 7503**示例:** 7504 7505```ts 7506function unregisterSessionError(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7507 timeLapsePhotoSession.off('error'); 7508} 7509``` 7510 7511### on('focusStateChange')<sup>12+</sup> 7512 7513on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7514 7515监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 7516 7517**系统接口:** 此接口为系统接口。 7518 7519**系统能力:** SystemCapability.Multimedia.Camera.Core 7520 7521**参数:** 7522 7523| 参数名 | 类型 | 必填 | 说明 | 7524| -------- | ---------------- | ---- | ------------------------ | 7525| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 7526| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 7527 7528**错误码:** 7529 7530以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7531 7532| 错误码ID | 错误信息 | 7533|---------| --------------- | 7534| 202 | Not System Application. | 7535 7536**示例:** 7537 7538```ts 7539import { BusinessError } from '@kit.BasicServicesKit'; 7540 7541function callback(err: BusinessError, focusState: camera.FocusState): void { 7542 if (err !== undefined && err.code !== 0) { 7543 console.error(`Callback Error, errorCode: ${err.code}`); 7544 return; 7545 } 7546 console.info(`Focus state: ${focusState}`); 7547} 7548 7549function registerFocusStateChange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7550 timeLapsePhotoSession.on('focusStateChange', callback); 7551} 7552``` 7553 7554### off('focusStateChange')<sup>12+</sup> 7555 7556off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7557 7558注销监听相机对焦的状态变化。 7559 7560**系统接口:** 此接口为系统接口。 7561 7562**系统能力:** SystemCapability.Multimedia.Camera.Core 7563 7564**参数:** 7565 7566| 参数名 | 类型 | 必填 | 说明 | 7567| -------- | ----------------------------------------- | ---- | ------------------------ | 7568| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 7569| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 7570 7571**错误码:** 7572 7573以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7574 7575| 错误码ID | 错误信息 | 7576|---------| --------------- | 7577| 202 | Not System Application. | 7578 7579**示例:** 7580 7581```ts 7582function unregisterFocusStateChange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7583 timeLapsePhotoSession.off('focusStateChange'); 7584} 7585``` 7586 7587### on('isoInfoChange')<sup>12+</sup> 7588 7589on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 7590 7591监听自动ISO变化事件,通过注册回调函数获取实时ISO信息。使用callback异步回调。 7592 7593**系统接口:** 此接口为系统接口。 7594 7595**系统能力:** SystemCapability.Multimedia.Camera.Core 7596 7597**参数:** 7598 7599| 参数名 | 类型 | 必填 | 说明 | 7600| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7601| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 7602| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 是 | 回调函数,用于获取ISO信息。 | 7603 7604**错误码:** 7605 7606| 错误码ID | 错误信息 | 7607| ------- | ---------------------- | 7608| 202 | Not System Application. | 7609 7610**示例:** 7611 7612```ts 7613import { BusinessError } from '@kit.BasicServicesKit'; 7614 7615function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 7616 if (err !== undefined && err.code !== 0) { 7617 console.error(`Callback Error, errorCode: ${err.code}`); 7618 return; 7619 } 7620 console.log(`ISO value: ${info.iso}`); 7621} 7622 7623function registerIsoInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7624 timeLapsePhotoSession.on('isoInfoChange', isoInfoCallback); 7625} 7626``` 7627 7628### off('isoInfoChange')<sup>12+</sup> 7629 7630off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 7631 7632注销监听ISO信息事件,通过注册回调函数来注销。 7633 7634**系统接口:** 此接口为系统接口。 7635 7636**系统能力:** SystemCapability.Multimedia.Camera.Core 7637 7638**参数:** 7639 7640| 参数名 | 类型 | 必填 | 说明 | 7641| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7642| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 7643| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 否 | 回调函数,可选,用于匹配on('isoInfoChange')的callback。 | 7644 7645**错误码:** 7646 7647| 错误码ID | 错误信息 | 7648| ------- | ---------------------- | 7649| 202 | Not System Application. | 7650 7651**示例:** 7652 7653```ts 7654function unregisterIsoInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7655 timeLapsePhotoSession.off('isoInfoChange'); 7656} 7657``` 7658 7659### on('exposureInfoChange')<sup>12+</sup> 7660 7661on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 7662 7663监听曝光信息事件,通过注册回调函数获取曝光信息。使用callback异步回调。 7664 7665**系统接口:** 此接口为系统接口。 7666 7667**系统能力:** SystemCapability.Multimedia.Camera.Core 7668 7669**参数:** 7670 7671| 参数名 | 类型 | 必填 | 说明 | 7672| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7673| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 7674| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 是 | 回调函数,用于获取曝光信息。 | 7675 7676**错误码:** 7677 7678| 错误码ID | 错误信息 | 7679| ------- | ---------------------- | 7680| 202 | Not System Application. | 7681 7682**示例:** 7683 7684```ts 7685import { BusinessError } from '@kit.BasicServicesKit'; 7686 7687function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 7688 if (err !== undefined && err.code !== 0) { 7689 console.error(`Callback Error, errorCode: ${err.code}`); 7690 return; 7691 } 7692 console.log(`exposureTimeValue: ${info.exposureTime}`); 7693} 7694 7695function registerExposureInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7696 timeLapsePhotoSession.on('exposureInfoChange', exposureInfoCallback); 7697} 7698``` 7699 7700### off('exposureInfoChange')<sup>12+</sup> 7701 7702off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 7703 7704注销监听曝光信息事件,通过注册回调函数来注销。 7705 7706**系统接口:** 此接口为系统接口。 7707 7708**系统能力:** SystemCapability.Multimedia.Camera.Core 7709 7710**参数:** 7711 7712| 参数名 | 类型 | 必填 | 说明 | 7713| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7714| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 7715| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 否 | 回调函数,可选,用于匹配on('exposureInfoChange')的callback。 | 7716 7717**错误码:** 7718 7719| 错误码ID | 错误信息 | 7720| ------- | ---------------------- | 7721| 202 | Not System Application. | 7722 7723**示例:** 7724 7725```ts 7726function unregisterExposureInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7727 timeLapsePhotoSession.off('exposureInfoChange'); 7728} 7729``` 7730 7731### on('luminationInfoChange')<sup>12+</sup> 7732 7733on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 7734 7735监听光照变化事件,通过注册回调函数获取实时光照参数。使用callback异步回调。 7736 7737**系统接口:** 此接口为系统接口。 7738 7739**系统能力:** SystemCapability.Multimedia.Camera.Core 7740 7741**参数:** 7742 7743| 参数名 | 类型 | 必填 | 说明 | 7744| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7745| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 7746| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 是 | 回调函数,用于获取光照参数。 | 7747 7748**错误码:** 7749 7750| 错误码ID | 错误信息 | 7751| ------- | ---------------------- | 7752| 202 | Not System Application. | 7753 7754**示例:** 7755 7756```ts 7757import { BusinessError } from '@kit.BasicServicesKit'; 7758 7759function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 7760 if (err !== undefined && err.code !== 0) { 7761 console.error(`Callback Error, errorCode: ${err.code}`); 7762 return; 7763 } 7764 console.log(`Lumination: ${info.lumination}`); 7765} 7766 7767function registerLuminationInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7768 timeLapsePhotoSession.on('luminationInfoChange', luminationInfoCallback); 7769} 7770``` 7771 7772### off('luminationInfoChange')<sup>12+</sup> 7773 7774off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 7775 7776注销监听光照变化事件,通过注册回调函数来注销。 7777 7778**系统接口:** 此接口为系统接口。 7779 7780**系统能力:** SystemCapability.Multimedia.Camera.Core 7781 7782**参数:** 7783 7784| 参数名 | 类型 | 必填 | 说明 | 7785| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7786| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 7787| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 否 | 回调函数,可选,用于匹配on('luminationInfoChange')的callback。 | 7788 7789**错误码:** 7790 7791| 错误码ID | 错误信息 | 7792| ------- | ---------------------- | 7793| 202 | Not System Application. | 7794 7795**示例:** 7796 7797```ts 7798function unregisterLuminationInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7799 timeLapsePhotoSession.off('luminationInfoChange'); 7800} 7801``` 7802 7803### on('tryAEInfoChange')<sup>12+</sup> 7804 7805on(type: 'tryAEInfoChange', callback: AsyncCallback\<TryAEInfo\>): void 7806 7807监听TryAE变化事件,通过注册回调函数获取实时TryAE参数。使用callback异步回调。 7808 7809**系统接口:** 此接口为系统接口。 7810 7811**系统能力:** SystemCapability.Multimedia.Camera.Core 7812 7813**参数:** 7814 7815| 参数名 | 类型 | 必填 | 说明 | 7816| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7817| type | string | 是 | 监听事件,固定为'tryAEInfoChange'。 | 7818| callback | AsyncCallback\<[TryAEInfo](#tryaeinfo12)\>| 是 | 回调函数,用于获取TryAE参数。 | 7819 7820**错误码:** 7821 7822| 错误码ID | 错误信息 | 7823| ------- | ---------------------- | 7824| 202 | Not System Application. | 7825 7826**示例:** 7827 7828```ts 7829import { BusinessError } from '@kit.BasicServicesKit'; 7830 7831function tryAEInfoCallback(err: BusinessError, info: camera.TryAEInfo): void { 7832 if (err !== undefined && err.code !== 0) { 7833 console.error(`Callback Error, errorCode: ${err.code}`); 7834 return; 7835 } 7836 console.log(`TryAEInfo: ${info.isTryAEDone}, ${info.isTryAEHintNeeded}, ${info.previewType}, ${info.captureInterval}`); 7837} 7838 7839function registerTryAEInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7840 timeLapsePhotoSession.on('tryAEInfoChange', tryAEInfoCallback); 7841} 7842``` 7843 7844### off('tryAEInfoChange')<sup>12+</sup> 7845 7846off(type: 'tryAEInfoChange', callback?: AsyncCallback\<TryAEInfo\>): void 7847 7848注销监听TryAE变化事件,通过注册回调函数来注销。 7849 7850**系统接口:** 此接口为系统接口。 7851 7852**系统能力:** SystemCapability.Multimedia.Camera.Core 7853 7854**参数:** 7855 7856| 参数名 | 类型 | 必填 | 说明 | 7857| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7858| type | string | 是 | 监听事件,固定为'tryAEInfoChange'。 | 7859| callback | AsyncCallback\<[TryAEInfo](#tryaeinfo12)\>| 否 | 回调函数,可选,用于匹配on('tryAEInfoChange')的callback。 | 7860 7861**错误码:** 7862 7863| 错误码ID | 错误信息 | 7864| ------- | ---------------------- | 7865| 202 | Not System Application. | 7866 7867**示例:** 7868 7869```ts 7870function unregisterTryAEInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7871 timeLapsePhotoSession.off('tryAEInfoChange'); 7872} 7873``` 7874 7875### isTryAENeeded<sup>12+</sup> 7876 7877isTryAENeeded(): boolean 7878 7879判断是否需要执行TryAE。 7880 7881**系统接口:** 此接口为系统接口。 7882 7883**系统能力:** SystemCapability.Multimedia.Camera.Core 7884 7885**返回值:** 7886 7887| 类型 | 说明 | 7888| ---------- | ----------------------------- | 7889| boolean | 是否需要执行TryAE,接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 7890 7891**错误码:** 7892 7893以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7894 7895| 错误码ID | 错误信息 | 7896| --------------- | --------------- | 7897| 202 | Not System Application. | 7898| 7400103 | Session not config. | 7899 7900**示例:** 7901 7902```ts 7903import { BusinessError } from '@kit.BasicServicesKit'; 7904 7905function isTryAENeeded(timeLapsePhotoSession: camera.TimeLapsePhotoSession): boolean { 7906 let needed = false; 7907 try { 7908 needed = timeLapsePhotoSession.isTryAENeeded(); 7909 } catch (error) { 7910 // 失败返回错误码error.code并处理 7911 let err = error as BusinessError; 7912 console.error(`The isTryAENeeded call failed. error code: ${err.code}`); 7913 } 7914 return needed; 7915} 7916``` 7917 7918### startTryAE<sup>12+</sup> 7919 7920startTryAE(): void 7921 7922开始执行TryAE。 7923 7924**系统接口:** 此接口为系统接口。 7925 7926**系统能力:** SystemCapability.Multimedia.Camera.Core 7927 7928**错误码:** 7929 7930以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7931 7932| 错误码ID | 错误信息 | 7933| --------------- | --------------- | 7934| 202 | Not System Application. | 7935| 7400103 | Session not config. | 7936 7937**示例:** 7938 7939```ts 7940import { BusinessError } from '@kit.BasicServicesKit'; 7941 7942function startTryAE(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7943 try { 7944 timeLapsePhotoSession.startTryAE(); 7945 } catch (error) { 7946 // 失败返回错误码error.code并处理 7947 let err = error as BusinessError; 7948 console.error(`The startTryAE call failed. error code: ${err.code}`); 7949 } 7950} 7951``` 7952 7953### stopTryAE<sup>12+</sup> 7954 7955stopTryAE(): void 7956 7957停止执行TryAE。 7958 7959**系统接口:** 此接口为系统接口。 7960 7961**系统能力:** SystemCapability.Multimedia.Camera.Core 7962 7963**错误码:** 7964 7965以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7966 7967| 错误码ID | 错误信息 | 7968| --------------- | --------------- | 7969| 202 | Not System Application. | 7970| 7400103 | Session not config. | 7971 7972**示例:** 7973 7974```ts 7975import { BusinessError } from '@kit.BasicServicesKit'; 7976 7977function stopTryAE(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7978 try { 7979 timeLapsePhotoSession.stopTryAE(); 7980 } catch (error) { 7981 // 失败返回错误码error.code并处理 7982 let err = error as BusinessError; 7983 console.error(`The stopTryAE call failed. error code: ${err.code}`); 7984 } 7985} 7986``` 7987 7988### getSupportedTimeLapseIntervalRange<sup>12+</sup> 7989 7990getSupportedTimeLapseIntervalRange(): Array\<number\> 7991 7992获取支持的拍摄间隔范围。 7993 7994**系统接口:** 此接口为系统接口。 7995 7996**系统能力:** SystemCapability.Multimedia.Camera.Core 7997 7998**返回值:** 7999 8000| 类型 | 说明 | 8001| ---------- | ----------------------------- | 8002| Array\<number\> | 用于获取拍摄间隔范围,单位毫秒(ms),根据底层能力返回为准,接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 8003 8004**错误码:** 8005 8006以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8007 8008| 错误码ID | 错误信息 | 8009| --------------- | --------------- | 8010| 202 | Not System Application. | 8011| 7400103 | Session not config. | 8012 8013**示例:** 8014 8015```ts 8016import { BusinessError } from '@kit.BasicServicesKit'; 8017 8018function getSupportedTimeLapseIntervalRange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): Array<number> { 8019 let intervalRange: Array<number> = []; 8020 try { 8021 intervalRange = timeLapsePhotoSession.getSupportedTimeLapseIntervalRange(); 8022 } catch (error) { 8023 // 失败返回错误码error.code并处理 8024 let err = error as BusinessError; 8025 console.error(`The getSupportedTimeLapseIntervalRange call failed. error code: ${err.code}`); 8026 } 8027 return intervalRange; 8028} 8029``` 8030 8031### getTimeLapseInterval<sup>12+</sup> 8032 8033getTimeLapseInterval(): number 8034 8035获取当前的拍摄间隔值。 8036 8037**系统接口:** 此接口为系统接口。 8038 8039**系统能力:** SystemCapability.Multimedia.Camera.Core 8040 8041**返回值:** 8042 8043| 类型 | 说明 | 8044| ---------- | ----------------------------- | 8045| number | 返回当前拍摄间隔值,单位毫秒(ms)。 | 8046 8047**错误码:** 8048 8049以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8050 8051| 错误码ID | 错误信息 | 8052| --------------- | --------------- | 8053| 202 | Not System Application. | 8054| 7400103 | Session not config. | 8055 8056**示例:** 8057 8058```ts 8059import { BusinessError } from '@kit.BasicServicesKit'; 8060 8061function getTimeLapseInterval(timeLapsePhotoSession: camera.TimeLapsePhotoSession): number { 8062 let interval: number = 0; 8063 try { 8064 interval = timeLapsePhotoSession.getTimeLapseInterval(); 8065 } catch (error) { 8066 // 失败返回错误码error.code并处理 8067 let err = error as BusinessError; 8068 console.error(`The getTimeLapseInterval call failed. error code: ${err.code}`); 8069 } 8070 return interval; 8071} 8072``` 8073 8074### setTimeLapseInterval<sup>12+</sup> 8075setTimeLapseInterval(interval: number): void 8076 8077设置拍摄间隔值。 8078 8079**系统接口:** 此接口为系统接口。 8080 8081**系统能力:** SystemCapability.Multimedia.Camera.Core 8082 8083**参数:** 8084 8085| 参数名 | 类型 | 必填 | 说明 | 8086| -------- | ----------------------- | ---- | ------------------- | 8087| interval | number | 是 | 设置拍摄间隔值,单位毫秒(ms)。 | 8088 8089**错误码:** 8090 8091以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8092 8093| 错误码ID | 错误信息 | 8094| --------------- | --------------- | 8095| 202 | Not System Application. | 8096| 7400101 | Parameter missing or parameter type incorrect. | 8097| 7400103 | Session not config. | 8098 8099**示例:** 8100 8101```ts 8102import { BusinessError } from '@kit.BasicServicesKit'; 8103 8104function setTimeLapseInterval(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8105 try { 8106 let interval: number = 10000; 8107 timeLapsePhotoSession.setTimeLapseInterval(interval); 8108 } catch (error) { 8109 // 失败返回错误码error.code并处理 8110 let err = error as BusinessError; 8111 console.error(`The setTimeLapseInterval call failed. error code: ${err.code}`); 8112 } 8113} 8114``` 8115 8116### getTimeLapseRecordState<sup>12+</sup> 8117 8118getTimeLapseRecordState(): TimeLapseRecordState 8119 8120获取当前拍摄状态。 8121 8122**系统接口:** 此接口为系统接口。 8123 8124**系统能力:** SystemCapability.Multimedia.Camera.Core 8125 8126**返回值:** 8127 8128| 类型 | 说明 | 8129| ---------- | ----------------------------- | 8130| [TimeLapseRecordState](#timelapserecordstate12) | 获取当前拍摄状态。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 8131 8132**错误码:** 8133 8134以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8135 8136| 错误码ID | 错误信息 | 8137| --------------- | --------------- | 8138| 202 | Not System Application. | 8139| 7400103 | Session not config. | 8140 8141**示例:** 8142 8143```ts 8144import { BusinessError } from '@kit.BasicServicesKit'; 8145 8146function getTimeLapseRecordState(timeLapsePhotoSession: camera.TimeLapsePhotoSession): camera.TimeLapseRecordState { 8147 let state = camera.TimeLapseRecordState.IDLE; 8148 try { 8149 state = timeLapsePhotoSession.getTimeLapseRecordState(); 8150 } catch (error) { 8151 // 失败返回错误码error.code并处理 8152 let err = error as BusinessError; 8153 console.error(`The getTimeLapseRecordState call failed. error code: ${err.code}`); 8154 } 8155 return state; 8156} 8157``` 8158 8159### setTimeLapseRecordState<sup>12+</sup> 8160 8161setTimeLapseRecordState(state: TimeLapseRecordState): void 8162 8163设置当前拍摄状态。 8164 8165**系统接口:** 此接口为系统接口。 8166 8167**系统能力:** SystemCapability.Multimedia.Camera.Core 8168 8169**参数:** 8170 8171| 参数名 | 类型 | 必填 | 说明 | 8172| -------- | -------------------------------| ---- | ----------------------- | 8173| state | [TimeLapseRecordState](#timelapserecordstate12) | 是 | 拍摄状态。 | 8174 8175**错误码:** 8176 8177以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8178 8179| 错误码ID | 错误信息 | 8180| --------------- | --------------- | 8181| 202 | Not System Application. | 8182| 7400101 | Parameter missing or parameter type incorrect. | 8183| 7400103 | Session not config. | 8184 8185**示例:** 8186 8187```ts 8188import { BusinessError } from '@kit.BasicServicesKit'; 8189 8190function setTimeLapseRecordState(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8191 try { 8192 timeLapsePhotoSession.setTimeLapseRecordState(camera.TimeLapseRecordState.RECORDING); 8193 } catch (error) { 8194 // 失败返回错误码error.code并处理 8195 let err = error as BusinessError; 8196 console.error(`The setTimeLapseRecordState call failed. error code: ${err.code}`); 8197 } 8198} 8199``` 8200 8201### getTimeLapsePreviewType<sup>12+</sup> 8202 8203getTimeLapsePreviewType(): TimeLapsePreviewType 8204 8205获取当前预览类型。 8206 8207**系统接口:** 此接口为系统接口。 8208 8209**系统能力:** SystemCapability.Multimedia.Camera.Core 8210 8211**返回值:** 8212 8213| 类型 | 说明 | 8214| ---------- | ----------------------------- | 8215| [TimeLapsePreviewType](#timelapsepreviewtype12) | 获取当前预览类型。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 8216 8217**错误码:** 8218 8219以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8220 8221| 错误码ID | 错误信息 | 8222| --------------- | --------------- | 8223| 202 | Not System Application. | 8224| 7400103 | Session not config. | 8225 8226**示例:** 8227 8228```ts 8229import { BusinessError } from '@kit.BasicServicesKit'; 8230 8231function getTimeLapsePreviewType(timeLapsePhotoSession: camera.TimeLapsePhotoSession): camera.TimeLapsePreviewType { 8232 let type = camera.TimeLapsePreviewType.DARK; 8233 try { 8234 type = timeLapsePhotoSession.getTimeLapsePreviewType(); 8235 } catch (error) { 8236 // 失败返回错误码error.code并处理 8237 let err = error as BusinessError; 8238 console.error(`The getTimeLapsePreviewType call failed. error code: ${err.code}`); 8239 } 8240 return type; 8241} 8242``` 8243 8244### setTimeLapsePreviewType<sup>12+</sup> 8245 8246setTimeLapsePreviewType(type: TimeLapsePreviewType): void 8247 8248设置当前预览类型。 8249 8250**系统接口:** 此接口为系统接口。 8251 8252**系统能力:** SystemCapability.Multimedia.Camera.Core 8253 8254**参数:** 8255 8256| 参数名 | 类型 | 必填 | 说明 | 8257| -------- | -------------------------------| ---- | ----------------------- | 8258| state | [TimeLapsePreviewType](#timelapsepreviewtype12) | 是 | 预览类型。 | 8259 8260**错误码:** 8261 8262以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8263 8264| 错误码ID | 错误信息 | 8265| --------------- | --------------- | 8266| 202 | Not System Application. | 8267| 7400101 | Parameter missing or parameter type incorrect. | 8268| 7400103 | Session not config. | 8269 8270**示例:** 8271 8272```ts 8273import { BusinessError } from '@kit.BasicServicesKit'; 8274 8275function setTimeLapsePreviewType(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8276 try { 8277 timeLapsePhotoSession.setTimeLapsePreviewType(camera.TimeLapsePreviewType.LIGHT); 8278 } catch (error) { 8279 // 失败返回错误码error.code并处理 8280 let err = error as BusinessError; 8281 console.error(`The setTimeLapsePreviewType call failed. error code: ${err.code}`); 8282 } 8283} 8284``` 8285 8286## LightPaintingPhotoSession<sup>12+</sup> 8287 8288LightPaintingPhotoSession extends Session, Flash, Focus, Zoom, ColorEffect 8289 8290流光快门拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置流光快门拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 8291 8292### on('error')<sup>12+</sup> 8293 8294on(type: 'error', callback: ErrorCallback): void 8295 8296监听流光快门拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 8297 8298**系统接口:** 此接口为系统接口。 8299 8300**系统能力:** SystemCapability.Multimedia.Camera.Core 8301 8302**参数:** 8303 8304| 参数名 | 类型 | 必填 | 说明 | 8305|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 8306| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 8307| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 8308 8309**错误码:** 8310 8311以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8312 8313| 错误码ID | 错误信息 | 8314|-------|----------------------------| 8315| 202 | Not System Application. | 8316 8317**示例:** 8318 8319```ts 8320import { BusinessError } from '@kit.BasicServicesKit'; 8321 8322function callback(err: BusinessError): void { 8323 console.error(`LightPaintingPhotoSession error code: ${err.code}`); 8324} 8325 8326function registerSessionError(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8327 lightPaintingPhotoSession.on('error', callback); 8328} 8329``` 8330 8331### off('error')<sup>12+</sup> 8332 8333off(type: 'error', callback?: ErrorCallback): void 8334 8335注销监听流光快门拍照会话的错误事件,通过注册回调函数获取结果。 8336 8337**系统接口:** 此接口为系统接口。 8338 8339**系统能力:** SystemCapability.Multimedia.Camera.Core 8340 8341**参数:** 8342 8343| 参数名 | 类型 | 必填 | 说明 | 8344|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 8345| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 8346| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 8347 8348**错误码:** 8349 8350以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8351 8352| 错误码ID | 错误信息 | 8353|-------|----------------------------| 8354| 202 | Not System Application. | 8355 8356**示例:** 8357 8358```ts 8359function unregisterSessionError(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8360 lightPaintingPhotoSession.off('error'); 8361} 8362``` 8363 8364### on('focusStateChange')<sup>12+</sup> 8365 8366on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 8367 8368监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 8369 8370**系统接口:** 此接口为系统接口。 8371 8372**系统能力:** SystemCapability.Multimedia.Camera.Core 8373 8374**参数:** 8375 8376| 参数名 | 类型 | 必填 | 说明 | 8377|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 8378| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 8379| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 8380 8381**错误码:** 8382 8383以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8384 8385| 错误码ID | 错误信息 | 8386|-------|----------------------------| 8387| 202 | Not System Application. | 8388 8389**示例:** 8390 8391```ts 8392import { BusinessError } from '@kit.BasicServicesKit'; 8393 8394function callback(err: BusinessError, focusState: camera.FocusState): void { 8395 if (err !== undefined && err.code !== 0) { 8396 console.error(`Callback Error, errorCode: ${err.code}`); 8397 return; 8398 } 8399 console.info(`Focus state: ${focusState}`); 8400} 8401 8402function registerFocusStateChange(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8403 lightPaintingPhotoSession.on('focusStateChange', callback); 8404} 8405``` 8406 8407### off('focusStateChange')<sup>12+</sup> 8408 8409off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 8410 8411注销监听相机对焦的状态变化。 8412 8413**系统接口:** 此接口为系统接口。 8414 8415**系统能力:** SystemCapability.Multimedia.Camera.Core 8416 8417**参数:** 8418 8419| 参数名 | 类型 | 必填 | 说明 | 8420|-----------|---------------------------------------------|----|--------------------------------------------------------------| 8421| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 8422| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 8423 8424**错误码:** 8425 8426以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8427 8428| 错误码ID | 错误信息 | 8429|-------|----------------------------| 8430| 202 | Not System Application. | 8431 8432**示例:** 8433 8434```ts 8435function unregisterFocusStateChange(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8436 lightPaintingPhotoSession.off('focusStateChange'); 8437} 8438``` 8439 8440### on('smoothZoomInfoAvailable')<sup>12+</sup> 8441 8442on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 8443 8444监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 8445 8446**系统接口:** 此接口为系统接口。 8447 8448**系统能力:** SystemCapability.Multimedia.Camera.Core 8449 8450**参数:** 8451 8452| 参数名 | 类型 | 必填 | 说明 | 8453| -------- | ----------------------- | ---- | ------------------------ | 8454| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 8455| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 8456 8457**错误码:** 8458 8459以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8460 8461| 错误码ID | 错误信息 | 8462|-------|----------------------------| 8463| 202 | Not System Application. | 8464 8465**示例:** 8466 8467```ts 8468import { BusinessError } from '@kit.BasicServicesKit'; 8469 8470function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 8471 if (err !== undefined && err.code !== 0) { 8472 console.error(`Callback Error, errorCode: ${err.code}`); 8473 return; 8474 } 8475 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 8476} 8477 8478function registerSmoothZoomInfo(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8479 lightPaintingPhotoSession.on('smoothZoomInfoAvailable', callback); 8480} 8481``` 8482 8483### off('smoothZoomInfoAvailable')<sup>12+</sup> 8484 8485off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 8486 8487注销监听相机平滑变焦的状态变化。 8488 8489**系统接口:** 此接口为系统接口。 8490 8491**系统能力:** SystemCapability.Multimedia.Camera.Core 8492 8493**参数:** 8494 8495| 参数名 | 类型 | 必填 | 说明 | 8496| -------- | ----------------------------------------- | ---- | ------------------------ | 8497| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 8498| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 8499 8500**错误码:** 8501 8502以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8503 8504| 错误码ID | 错误信息 | 8505|-------|----------------------------| 8506| 202 | Not System Application. | 8507 8508**示例:** 8509 8510```ts 8511function unregisterSmoothZoomInfo(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8512 lightPaintingPhotoSession.off('smoothZoomInfoAvailable'); 8513} 8514``` 8515 8516### getLightPaintingType<sup>12+</sup> 8517 8518getLightPaintingType(): LightPaintingType 8519 8520获取当前生效的流光快门模式类型。 8521 8522**系统接口:** 此接口为系统接口。 8523 8524**系统能力:** SystemCapability.Multimedia.Camera.Core 8525 8526**返回值:** 8527| 类型 | 说明 | 8528|------------------------------------------------- | --------------------- | 8529| [LightPaintingType](#lightpaintingtype12) | 流光快门模式类型。 | 8530 8531**错误码:** 8532 8533以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8534 8535| 错误码ID | 错误信息 | 8536| --------------- | --------------- | 8537| 202 | Not System Application. | 8538| 7400103 | Session not config. | 8539 8540**示例:** 8541 8542```ts 8543function getLightPaintingType(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): camera.LightPaintingType { 8544 let type: camera.LightPaintingType = lightPaintingPhotoSession.getLightPaintingType(); 8545 return type; 8546} 8547``` 8548 8549### setLightPaintingType<sup>12+</sup> 8550 8551setLightPaintingType(type: LightPaintingType): void 8552 8553设置当前生效的流光快门模式类型。 8554 8555**系统接口:** 此接口为系统接口。 8556 8557**系统能力:** SystemCapability.Multimedia.Camera.Core 8558 8559**返回值:** 8560| 参数名 | 类型 | 必填 | 说明 | 8561| -------- | ----------------------- | ---- | ------------------- | 8562| type | [LightPaintingType](#lightpaintingtype12) | 是 | 设置流光快门模式的类型。 | 8563 8564**错误码:** 8565 8566以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8567 8568| 错误码ID | 错误信息 | 8569| --------------- | --------------- | 8570| 202 | Not System Application. | 8571| 7400101 | Parameter missing or parameter type incorrect. | 8572| 7400103 | Session not config. | 8573 8574**示例:** 8575 8576```ts 8577import { BusinessError } from '@kit.BasicServicesKit'; 8578 8579function setLightPaintingType(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8580 try { 8581 let type: camera.LightPaintingType = camera.LightPaintingType.TRAFFIC_TRAILS; 8582 lightPaintingPhotoSession.setLightPaintingType(type); 8583 } catch (error) { 8584 // 失败返回错误码error.code并处理 8585 let err = error as BusinessError; 8586 console.error(`The setLightPaintingType call failed. error code: ${err.code}`); 8587 } 8588} 8589``` 8590 8591### getSupportedLightPaintingTypes<sup>12+</sup> 8592 8593getSupportedLightPaintingTypes(): Array\<LightPaintingType\> 8594 8595获取当前支持的流光快门模式类型。 8596 8597**系统接口:** 此接口为系统接口。 8598 8599**系统能力:** SystemCapability.Multimedia.Camera.Core 8600 8601**返回值:** 8602| 类型 | 说明 | 8603|------------------------------------------------- | --------------------- | 8604| Array\<[LightPaintingType](#lightpaintingtype12)\> | 支持的流光快门模式类型。 | 8605 8606**错误码:** 8607 8608以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8609 8610| 错误码ID | 错误信息 | 8611| --------------- | --------------- | 8612| 202 | Not System Application. | 8613| 7400103 | Session not config. | 8614 8615**示例:** 8616 8617```ts 8618function getSupportedLightPaintingTypes(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): Array<camera.LightPaintingType> { 8619 let types: Array<camera.LightPaintingType> = lightPaintingPhotoSession.getSupportedLightPaintingTypes(); 8620 return types 8621} 8622```