1# Interface (VideoSession) 2<!--Kit: Camera Kit--> 3<!--Subsystem: Multimedia--> 4<!--Owner: @qano--> 5<!--Designer: @leo_ysl--> 6<!--Tester: @xchaosioda--> 7<!--Adviser: @zengyawen--> 8 9> **说明:** 10> 11> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 12> - 本Interface首批接口从API version 11开始支持。 13 14VideoSession 继承自 [Session](arkts-apis-camera-Session.md)、[Flash](arkts-apis-camera-Flash.md)、[AutoExposure](arkts-apis-camera-AutoExposure.md)、 [WhiteBalance](arkts-apis-camera-WhiteBalance.md)、[Focus](arkts-apis-camera-Focus.md)、[Zoom](arkts-apis-camera-Zoom.md)、[Stabilization](arkts-apis-camera-Stabilization.md)、[ColorManagement](arkts-apis-camera-ColorManagement.md)、[AutoDeviceSwitch](arkts-apis-camera-AutoDeviceSwitch.md)、[Macro](arkts-apis-camera-Macro.md)、[ControlCenter](arkts-apis-camera-ControlCenter.md)。 15 16普通录像模式会话类,提供了对闪光灯、曝光、白平衡、对焦、变焦、视频防抖、色彩空间、微距及控制器的操作。 17 18> **说明:** 19> 20> 默认的视频录制模式,适用于一般场景。支持720P、1080p等多种分辨率的录制,可选择不同帧率(如30fps、60fps)。 21 22## 导入模块 23 24```ts 25import { camera } from '@kit.CameraKit'; 26``` 27 28## canPreconfig<sup>12+</sup> 29 30canPreconfig(preconfigType: PreconfigType, preconfigRatio?: PreconfigRatio): boolean 31 32查询当前Session是否支持指定的预配置类型。 33 34**原子化服务API:** 从API version 19开始,该接口支持在原子化服务中使用。 35 36**系统能力:** SystemCapability.Multimedia.Camera.Core 37 38**参数:** 39 40| 参数名 | 类型 | 必填 | 说明 | 41|----------------|-------------------------------------|-----|-----------------| 42| preconfigType | [PreconfigType](arkts-apis-camera-e.md#preconfigtype12) | 是 | 指定配置预期分辨率。 | 43| preconfigRatio | [PreconfigRatio](arkts-apis-camera-e.md#preconfigratio12) | 否 | 可选画幅比例,默认为16:9。 | 44 45**返回值:** 46 47| 类型 | 说明 | 48|---------|-----------------------------------------| 49| boolean | true: 支持指定预配置类型。<br/>false: 不支持指定预配置类型。 | 50 51**错误码:** 52 53以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 54 55| 错误码ID | 错误信息 | 56|---------|-----------------------------| 57| 7400201 | Camera service fatal error. | 58 59**示例:** 60 61```ts 62import { BusinessError } from '@kit.BasicServicesKit'; 63 64function testCanPreconfig(videoSession: camera.VideoSession, preconfigType: camera.PreconfigType, 65 preconfigRatio: camera.PreconfigRatio): void { 66 try { 67 let result = videoSession.canPreconfig(preconfigType, preconfigRatio); 68 console.info(`canPreconfig ${preconfigType} ${preconfigRatio} result is : ${result}`); 69 } catch (error) { 70 let err = error as BusinessError; 71 console.error(`The canPreconfig call failed. error code: ${err.code}`); 72 } 73} 74``` 75 76## preconfig<sup>12+</sup> 77 78preconfig(preconfigType: PreconfigType, preconfigRatio?: PreconfigRatio): void 79 80对当前Session进行预配置。 81 82**原子化服务API:** 从API version 19开始,该接口支持在原子化服务中使用。 83 84**系统能力:** SystemCapability.Multimedia.Camera.Core 85 86**参数:** 87 88| 参数名 | 类型 | 必填 | 说明 | 89|----------------|-------------------------------------|-----|-----------------| 90| preconfigType | [PreconfigType](arkts-apis-camera-e.md#preconfigtype12) | 是 | 指定配置预期分辨率。 | 91| preconfigRatio | [PreconfigRatio](arkts-apis-camera-e.md#preconfigratio12) | 否 | 可选画幅比例,默认为16:9。 | 92 93**错误码:** 94 95以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 96 97| 错误码ID | 错误信息 | 98|---------|-----------------------------| 99| 7400201 | Camera service fatal error. | 100 101**示例:** 102 103```ts 104import { BusinessError } from '@kit.BasicServicesKit'; 105 106function testPreconfig(videoSession: camera.VideoSession, preconfigType: camera.PreconfigType, 107 preconfigRatio: camera.PreconfigRatio): void { 108 try { 109 videoSession.preconfig(preconfigType, preconfigRatio); 110 console.info(`preconfig ${preconfigType} ${preconfigRatio} success`); 111 } catch (error) { 112 let err = error as BusinessError; 113 console.error(`The preconfig call failed. error code: ${err.code}`); 114 } 115} 116``` 117 118## on('error')<sup>11+</sup> 119 120on(type: 'error', callback: ErrorCallback): void 121 122监听普通录像会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 123 124> **说明:** 125> 126> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。 127 128**原子化服务API:** 从API version 19开始,该接口支持在原子化服务中使用。 129 130**系统能力:** SystemCapability.Multimedia.Camera.Core 131 132**参数:** 133 134| 参数名 | 类型 | 必填 | 说明 | 135| -------- | ------------------ | ---- | ------------------------------ | 136| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](arkts-apis-camera-Session.md#beginconfig11),[commitConfig](arkts-apis-camera-Session.md#commitconfig11),[addInput](arkts-apis-camera-Session.md#addinput11)等接口发生错误时返回错误信息。 | 137| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 138 139**示例:** 140 141```ts 142import { BusinessError } from '@kit.BasicServicesKit'; 143 144function callback(err: BusinessError): void { 145 console.error(`Video session error code: ${err.code}`); 146} 147 148function registerSessionError(videoSession: camera.VideoSession): void { 149 videoSession.on('error', callback); 150} 151``` 152 153## off('error')<sup>11+</sup> 154 155off(type: 'error', callback?: ErrorCallback): void 156 157注销监听普通录像会话的错误事件,通过注册回调函数获取结果。 158 159**原子化服务API:** 从API version 19开始,该接口支持在原子化服务中使用。 160 161**系统能力:** SystemCapability.Multimedia.Camera.Core 162 163**参数:** 164 165| 参数名 | 类型 | 必填 | 说明 | 166| -------- | --------------------------- | ---- | ------------------------------ | 167| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 168| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 169 170**示例:** 171 172```ts 173function unregisterSessionError(videoSession: camera.VideoSession): void { 174 videoSession.off('error'); 175} 176``` 177 178## on('focusStateChange')<sup>11+</sup> 179 180on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 181 182监听相机聚焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 183 184> **说明:** 185> 186> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。 187 188**原子化服务API:** 从API version 19开始,该接口支持在原子化服务中使用。 189 190**系统能力:** SystemCapability.Multimedia.Camera.Core 191 192**参数:** 193 194| 参数名 | 类型 | 必填 | 说明 | 195| -------- | ---------------- | ---- | ------------------------ | 196| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 197| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 198 199**示例:** 200 201```ts 202import { BusinessError } from '@kit.BasicServicesKit'; 203 204function callback(err: BusinessError, focusState: camera.FocusState): void { 205 if (err !== undefined && err.code !== 0) { 206 console.error(`Callback Error, errorCode: ${err.code}`); 207 return; 208 } 209 console.info(`Focus state: ${focusState}`); 210} 211 212function registerFocusStateChange(videoSession: camera.VideoSession): void { 213 videoSession.on('focusStateChange', callback); 214} 215``` 216 217## off('focusStateChange')<sup>11+</sup> 218 219off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 220 221注销监听相机聚焦的状态变化。 222 223**原子化服务API:** 从API version 19开始,该接口支持在原子化服务中使用。 224 225**系统能力:** SystemCapability.Multimedia.Camera.Core 226 227**参数:** 228 229| 参数名 | 类型 | 必填 | 说明 | 230| -------- | ----------------------------------------- | ---- | ------------------------ | 231| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 232| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 233 234**示例:** 235 236```ts 237function unregisterFocusStateChange(videoSession: camera.VideoSession): void { 238 videoSession.off('focusStateChange'); 239} 240``` 241 242## on('smoothZoomInfoAvailable')<sup>11+</sup> 243 244on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 245 246监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 247 248> **说明:** 249> 250> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。 251 252**原子化服务API:** 从API version 19开始,该接口支持在原子化服务中使用。 253 254**系统能力:** SystemCapability.Multimedia.Camera.Core 255 256**参数:** 257 258| 参数名 | 类型 | 必填 | 说明 | 259| -------- | ----------------------- | ---- | ------------------------ | 260| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 261| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 262 263**示例:** 264 265```ts 266import { BusinessError } from '@kit.BasicServicesKit'; 267 268function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 269 if (err !== undefined && err.code !== 0) { 270 console.error(`Callback Error, errorCode: ${err.code}`); 271 return; 272 } 273 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 274} 275 276function registerSmoothZoomInfo(videoSession: camera.VideoSession): void { 277 videoSession.on('smoothZoomInfoAvailable', callback); 278} 279``` 280 281## off('smoothZoomInfoAvailable')<sup>11+</sup> 282 283off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 284 285注销监听相机平滑变焦的状态变化。 286 287**原子化服务API:** 从API version 19开始,该接口支持在原子化服务中使用。 288 289**系统能力:** SystemCapability.Multimedia.Camera.Core 290 291**参数:** 292 293| 参数名 | 类型 | 必填 | 说明 | 294| -------- | ----------------------------------------- | ---- | ------------------------ | 295| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 296| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 297 298**示例:** 299 300```ts 301function unregisterSmoothZoomInfo(videoSession: camera.VideoSession): void { 302 videoSession.off('smoothZoomInfoAvailable'); 303} 304``` 305 306## on('autoDeviceSwitchStatusChange')<sup>13+</sup> 307 308on(type: 'autoDeviceSwitchStatusChange', callback: AsyncCallback\<AutoDeviceSwitchStatus\>): void 309 310监听相机自动切换镜头状态变化,通过注册回调函数获取结果。使用callback异步回调。 311 312> **说明:** 313> 314> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。 315 316**原子化服务API:** 从API version 19开始,该接口支持在原子化服务中使用。 317 318**系统能力:** SystemCapability.Multimedia.Camera.Core 319 320**参数:** 321 322| 参数名 | 类型 | 必填 | 说明 | 323| -------- |----------------------------------------------------------------------| ---- | ------------------------ | 324| type | string | 是 | 监听事件,固定为'autoDeviceSwitchStatusChange',session创建成功可监听。| 325| callback | AsyncCallback\<[AutoDeviceSwitchStatus](arkts-apis-camera-i.md#autodeviceswitchstatus13)\> | 是 | 回调函数,用于获取当前自动切换镜头的状态。 | 326 327**示例:** 328 329```ts 330import { BusinessError } from '@kit.BasicServicesKit'; 331 332function callback(err: BusinessError, autoDeviceSwitchStatus: camera.AutoDeviceSwitchStatus): void { 333 if (err !== undefined && err.code !== 0) { 334 console.error(`Callback Error, errorCode: ${err.code}`); 335 return; 336 } 337 console.info(`isDeviceSwitched: ${autoDeviceSwitchStatus.isDeviceSwitched}, isDeviceCapabilityChanged: ${autoDeviceSwitchStatus.isDeviceCapabilityChanged}`); 338} 339 340function registerAutoDeviceSwitchStatus(videoSession: camera.VideoSession): void { 341 videoSession.on('autoDeviceSwitchStatusChange', callback); 342} 343``` 344 345## off('autoDeviceSwitchStatusChange')<sup>13+</sup> 346 347off(type: 'autoDeviceSwitchStatusChange', callback?: AsyncCallback\<AutoDeviceSwitchStatus\>): void 348 349注销监听相机自动切换镜头状态变化。 350 351**原子化服务API:** 从API version 19开始,该接口支持在原子化服务中使用。 352 353**系统能力:** SystemCapability.Multimedia.Camera.Core 354 355**参数:** 356 357| 参数名 | 类型 | 必填 | 说明 | 358| -------- |----------------------------------------------| ---- | ------------------------ | 359| type | string | 是 | 监听事件,固定为'autoDeviceSwitchStatusChange',session创建成功可监听。| 360| callback | AsyncCallback\<[AutoDeviceSwitchStatus](arkts-apis-camera-i.md#autodeviceswitchstatus13)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 361 362**示例:** 363 364```ts 365function unregisterSmoothZoomInfo(videoSession: camera.VideoSession): void { 366 videoSession.off('autoDeviceSwitchStatusChange'); 367} 368``` 369 370## setQualityPrioritization<sup>14+</sup> 371 372setQualityPrioritization(quality : QualityPrioritization) : void; 373 374设置录像质量优先级。 375 376> **说明:** 377> 默认为高质量,设置为功耗平衡将降低录像质量以减少功耗。实际功耗收益因平台而异。 378 379**原子化服务API:** 从API version 19开始,该接口支持在原子化服务中使用。 380 381**系统能力:** SystemCapability.Multimedia.Camera.Core 382 383**参数:** 384 385| 参数名 | 类型 | 必填 | 说明 | 386| ------- | ------------------------------------------------- | ---- | ------------------------------------------ | 387| quality | [QualityPrioritization](arkts-apis-camera-e.md#qualityprioritization14) | 是 | 需要设置的视频质量优先级(默认为高质量)。 | 388 389**错误码:** 390 391以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 392 393| 错误码ID | 错误信息 | 394| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | 395| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 396| 7400103 | Session not config. The session has not been committed or configured. | 397 398**示例:** 399 400```ts 401import { BusinessError } from '@kit.BasicServicesKit'; 402 403function setQualityPrioritization(videoSession: camera.VideoSession): void { 404 try { 405 videoSession.setQualityPrioritization(camera.QualityPrioritization.POWER_BALANCE); 406 } catch (error) { 407 // 失败返回错误码error.code并处理。 408 let err = error as BusinessError; 409 console.error(`The setQualityPrioritization call failed. error code: ${err.code}`); 410 } 411} 412``` 413 414## on('systemPressureLevelChange')<sup>20+</sup> 415 416on(type: 'systemPressureLevelChange', callback: AsyncCallback\<SystemPressureLevel\>): void 417 418监听系统压力状态变化,通过注册回调函数获取结果。使用callback异步回调。 419 420> **说明:** 421> 422> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。 423 424**原子化服务API:** 从API version 20开始,该接口支持在原子化服务中使用。 425 426**系统能力:** SystemCapability.Multimedia.Camera.Core 427 428**参数:** 429 430| 参数名 | 类型 | 必填 | 说明 | 431|---------|----------------------------------------------------------|------|-------------------------------------------------------------------| 432|type | string | 是 | 监听事件,固定为'systemPressureLevelChange',session创建成功可监听。 | 433|callback | AsyncCallback\<[SystemPressureLevel](arkts-apis-camera-e.md#systempressurelevel20)\> | 是 | 回调函数,用于获取当前系统压力状态。 | 434 435**示例:** 436 437```ts 438import { BusinessError } from '@kit.BasicServicesKit'; 439 440function callback(err: BusinessError, systemPressureLevel: camera.SystemPressureLevel): void { 441 if (err !== undefined && err.code !== 0) { 442 console.error(`Callback Error, errorCode: ${err.code}`); 443 return; 444 } 445 console.info(`systemPressureLevel: ${systemPressureLevel}`); 446} 447 448function registerSystemPressureLevelChangeCallback(videoSession: camera.VideoSession): void { 449 videoSession.on('systemPressureLevelChange', callback); 450} 451``` 452 453## off('systemPressureLevelChange')<sup>20+</sup> 454 455off(type: 'systemPressureLevelChange', callback?: AsyncCallback\<SystemPressureLevel\>): void 456 457注销监听系统压力状态变化。 458 459**原子化服务API:** 从API version 20开始,该接口支持在原子化服务中使用。 460 461**系统能力:** SystemCapability.Multimedia.Camera.Core 462 463**参数:** 464 465| 参数名 | 类型 | 必填 | 说明 | 466|----------|--------------------------------|---------|------------------------------------------------------------------| 467| type | string | 是 | 注销监听事件,固定为'systemPressureLevelChange',session创建成功可触发此事件。| 468| callback | AsyncCallback\<[SystemPressureLevel](arkts-apis-camera-e.md#systempressurelevel20)\> | 否 | 回调函数,如果指定参数则取消对应callback (callback对象不可是匿名函数),否则参数默认为空,取消所有callback。 | 469 470**示例:** 471 472```ts 473function unregisterSystemPressureLevelChangeCallback(videoSession: camera.VideoSession): void { 474 videoSession.off('systemPressureLevelChange'); 475} 476``` 477 478## on('controlCenterEffectStatusChange')<sup>20+</sup> 479 480on(type: 'controlCenterEffectStatusChange', callback: AsyncCallback\<ControlCenterStatusInfo\>): void 481 482监听相机控制器效果激活状态变化,通过注册回调函数获取结果。使用callback异步回调。 483 484> **说明:** 485> 486> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。 487 488**原子化服务API:** 从API version 20开始,该接口支持在原子化服务中使用。 489 490**系统能力:** SystemCapability.Multimedia.Camera.Core 491 492**参数:** 493 494| 参数名 | 类型 | 必填 | 说明 | 495|----------|-------|----|------------------------------------------------------------------------| 496| type | string | 是 | 监听事件,固定为'controlCenterEffectStatusChange',session创建成功可监听。 | 497| callback | AsyncCallback\<[ControlCenterStatusInfo](arkts-apis-camera-i.md#controlcenterstatusinfo20)\> | 是 | 回调函数,用于获取当前控制器激活状态。 | 498 499**示例:** 500```ts 501import { BusinessError } from '@kit.BasicServicesKit'; 502 503function callback(err: BusinessError, status: camera.ControlCenterStatusInfo): void { 504 if (err !== undefined && err.code !== 0) { 505 console.error(`Callback Error, errorCode: ${err.code}`); 506 return; 507 } 508 console.info(`controlCenterEffectStatusChange: ${status}`); 509} 510 511function registerControlCenterEffectStatusChangeCallback(videoSession: camera.VideoSession): void { 512 videoSession.on('controlCenterEffectStatusChange', callback); 513} 514``` 515 516## off('controlCenterEffectStatusChange')<sup>20+</sup> 517 518off(type: 'controlCenterEffectStatusChange', callback?: AsyncCallback\<ControlCenterStatusInfo\>): void 519 520注销监听相机控制器激活状态变化。 521 522**原子化服务API:** 从API version 20开始,该接口支持在原子化服务中使用。 523 524**系统能力:** SystemCapability.Multimedia.Camera.Core 525 526**参数:** 527 528| 参数名 | 类型 | 必填 | 说明 | 529|----------|-------|----|------------------------------------------------------------------------| 530| type | string | 是 | 注销监听事件,固定为'controlCenterEffectStatusChange',session创建成功可触发此事件。 | 531| callback | AsyncCallback\<[ControlCenterStatusInfo](arkts-apis-camera-i.md#controlcenterstatusinfo20)\> | 否 | 回调函数,如果指定参数则取消对应callback (callback对象不可是匿名函数),否则参数默认为空,取消所有callback。| 532 533**示例:** 534 535```ts 536function unregisterControlCenterEffectStatusChange(videoSession: camera.VideoSession): void { 537 videoSession.off('controlCenterEffectStatusChange'); 538} 539``` 540 541## on('macroStatusChanged')<sup>20+</sup> 542 543on(type: 'macroStatusChanged', callback: AsyncCallback\<boolean\>): void 544 545监听相机微距状态变化,通过注册回调函数获取结果。使用callback异步回调。 546 547**原子化服务API:** 从API version 20开始,该接口支持在原子化服务中使用。 548 549**系统能力:** SystemCapability.Multimedia.Camera.Core 550 551**参数:** 552 553| 参数名 | 类型 | 必填 | 说明 | 554| -------- | ----------------------------------------- | ---- | ------------------------ | 555| type | string | 是 | 监听事件,固定为'macroStatusChanged',session创建成功可监听。 | 556| callback | AsyncCallback\<boolean\> | 是 | 回调函数,用于获取当前微距状态,返回true是开启状态,返回false是禁用状态。 | 557 558**示例:** 559 560```ts 561import { BusinessError } from '@kit.BasicServicesKit'; 562 563function callback(err: BusinessError, macroStatus: boolean): void { 564 if (err !== undefined && err.code !== 0) { 565 console.error(`Callback Error, errorCode: ${err.code}`); 566 return; 567 } 568 console.info(`Macro state: ${macroStatus}`); 569} 570 571function registerMacroStatusChanged(videoSession: camera.VideoSession): void { 572 videoSession.on('macroStatusChanged', callback); 573} 574``` 575 576## off('macroStatusChanged')<sup>20+</sup> 577 578off(type: 'macroStatusChanged', callback?: AsyncCallback\<boolean\>): void 579 580注销相机微距状态变化的监听。 581 582**原子化服务API:** 从API version 20开始,该接口支持在原子化服务中使用。 583 584**系统能力:** SystemCapability.Multimedia.Camera.Core 585 586**参数:** 587 588| 参数名 | 类型 | 必填 | 说明 | 589| -------- | ------------------------ | ---- |------------------------------------------------------------------------| 590| type | string | 是 | 注销监听事件,固定为'macroStatusChanged',session创建成功可触发此事件。 | 591| callback | AsyncCallback\<boolean\> | 否 | 回调函数,可选,如果指定参数则取消对应callback (callback对象不可是匿名函数),否则参数默认为空,取消所有callback。 | 592 593**示例:** 594 595```ts 596function unregisterMacroStatusChanged(videoSession: camera.VideoSession): void { 597 videoSession.off('macroStatusChanged'); 598} 599``` 600