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