• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 废弃的Interface (CaptureSession, deprecated)
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开始支持,从API version 11开始废弃。建议使用[PhotoSession](arkts-apis-camera-PhotoSession.md)、[VideoSession](arkts-apis-camera-VideoSession.md)替代。
12
13拍照会话类,保存一次相机运行所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md),并向相机设备申请完成相机功能(录像,拍照)。
14
15## 导入模块
16
17```ts
18import { camera } from '@kit.CameraKit';
19```
20
21## beginConfig<sup>(deprecated)</sup>
22
23beginConfig(): void
24
25开始配置会话。
26
27> **说明:**
28>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.beginConfig](arkts-apis-camera-Session.md#beginconfig11)替代。
29
30**系统能力:** SystemCapability.Multimedia.Camera.Core
31
32**错误码:**
33
34以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
35
36| 错误码ID         | 错误信息        |
37| --------------- | --------------- |
38| 7400105         |  Session config locked.               |
39
40**示例:**
41
42```ts
43import { BusinessError } from '@kit.BasicServicesKit';
44
45function beginConfig(captureSession: camera.CaptureSession): void {
46  try {
47    captureSession.beginConfig();
48  } catch (error) {
49    // 失败返回错误码error.code并处理。
50    let err = error as BusinessError;
51    console.error(`The beginConfig call failed. error code: ${err.code}`);
52  }
53}
54```
55
56## commitConfig<sup>(deprecated)</sup>
57
58commitConfig(callback: AsyncCallback\<void\>): void
59
60提交配置信息,通过注册回调函数获取结果。使用callback异步回调。
61
62> **说明:**
63>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.commitConfig](arkts-apis-camera-Session.md#commitconfig11)替代。
64
65**系统能力:** SystemCapability.Multimedia.Camera.Core
66
67**参数:**
68
69| 参数名     | 类型                   | 必填 | 说明                  |
70| -------- | -------------------- | ---- | -------------------- |
71| callback | AsyncCallback\<void\> | 是   | 回调函数。当提交配置信息成功,err为undefined,否则为错误对象。错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) |
72
73**错误码:**
74
75以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
76
77| 错误码ID         | 错误信息        |
78| --------------- | --------------- |
79| 7400102                |  Operation not allowed.                                  |
80| 7400201                |  Camera service fatal error.                           |
81
82**示例:**
83
84```ts
85import { BusinessError } from '@kit.BasicServicesKit';
86
87function commitConfig(captureSession: camera.CaptureSession): void {
88  captureSession.commitConfig((err: BusinessError) => {
89    if (err) {
90      console.error(`The commitConfig call failed. error code: ${err.code}`);
91      return;
92    }
93    console.info('Callback invoked to indicate the commit config success.');
94  });
95}
96```
97
98## commitConfig<sup>(deprecated)</sup>
99
100commitConfig(): Promise\<void\>
101
102提交配置信息。使用Promise异步回调。
103
104> **说明:**
105>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.commitConfig](arkts-apis-camera-Session.md#commitconfig11-1)替代。
106
107**系统能力:** SystemCapability.Multimedia.Camera.Core
108
109**返回值:**
110
111| 类型            | 说明                |
112| -------------- |-------------------|
113| Promise\<void\> | Promise对象,无返回结果。 |
114
115**错误码:**
116
117以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
118
119| 错误码ID         | 错误信息        |
120| --------------- | --------------- |
121| 7400102                |  Operation not allowed.                                  |
122| 7400201                |  Camera service fatal error.                           |
123
124**示例:**
125
126```ts
127import { BusinessError } from '@kit.BasicServicesKit';
128
129function commitConfig(captureSession: camera.CaptureSession): void {
130  captureSession.commitConfig().then(() => {
131    console.info('Promise returned to indicate the commit config success.');
132  }).catch((error: BusinessError) => {
133    // 失败返回错误码error.code并处理。
134    console.error(`The commitConfig call failed. error code: ${error.code}`);
135  });
136}
137```
138
139## addInput<sup>(deprecated)</sup>
140
141addInput(cameraInput: CameraInput): void
142
143把[CameraInput](arkts-apis-camera-CameraInput.md)加入到会话。
144
145> **说明:**
146>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.addInput](arkts-apis-camera-Session.md#addinput11)替代。
147
148**系统能力:** SystemCapability.Multimedia.Camera.Core
149
150**参数:**
151
152| 参数名        | 类型                          | 必填 | 说明                     |
153| ----------- | --------------------------- | ---- | ------------------------ |
154| cameraInput | [CameraInput](arkts-apis-camera-CameraInput.md) | 是   | 需要添加的CameraInput实例。 |
155
156**错误码:**
157
158以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
159
160| 错误码ID   | 错误信息                                          |
161|---------|-----------------------------------------------|
162| 7400101 | Parameter missing or parameter type incorrect. |
163| 7400102 | Operation not allowed.                           |
164
165**示例:**
166
167```ts
168import { BusinessError } from '@kit.BasicServicesKit';
169
170function addInput(captureSession: camera.CaptureSession, cameraInput: camera.CameraInput): void {
171  try {
172    captureSession.addInput(cameraInput);
173  } catch (error) {
174    // 失败返回错误码error.code并处理。
175    let err = error as BusinessError;
176    console.error(`The addInput call failed. error code: ${err.code}`);
177  }
178}
179```
180
181## removeInput<sup>(deprecated)</sup>
182
183removeInput(cameraInput: CameraInput): void
184
185移除[CameraInput](arkts-apis-camera-CameraInput.md)。
186
187> **说明:**
188>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.removeInput](arkts-apis-camera-Session.md#removeinput11)替代。
189
190**系统能力:** SystemCapability.Multimedia.Camera.Core
191
192**参数:**
193
194| 参数名        | 类型                          | 必填 | 说明                      |
195| ----------- | --------------------------- | ---- | ------------------------ |
196| cameraInput | [CameraInput](arkts-apis-camera-CameraInput.md) | 是   | 需要移除的CameraInput实例。 |
197
198**错误码:**
199
200以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
201
202| 错误码ID         | 错误信息        |
203| --------------- | --------------- |
204| 7400101                |  Parameter missing or parameter type incorrect.        |
205| 7400102                |  Operation not allowed.                                  |
206
207**示例:**
208
209```ts
210import { BusinessError } from '@kit.BasicServicesKit';
211
212function removeInput(captureSession: camera.CaptureSession, cameraInput: camera.CameraInput): void {
213  try {
214    captureSession.removeInput(cameraInput);
215  } catch (error) {
216    // 失败返回错误码error.code并处理。
217    let err = error as BusinessError;
218    console.error(`The removeInput call failed. error code: ${err.code}`);
219  }
220}
221```
222
223## addOutput<sup>(deprecated)</sup>
224
225addOutput(cameraOutput: CameraOutput): void
226
227把[CameraOutput](arkts-apis-camera-CameraOutput.md)加入到会话。
228
229> **说明:**
230>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.addOutput](arkts-apis-camera-Session.md#addoutput11)替代。
231
232**系统能力:** SystemCapability.Multimedia.Camera.Core
233
234**参数:**
235
236| 参数名           | 类型                             | 必填 | 说明                      |
237| ------------- | ------------------------------- | ---- | ------------------------ |
238| cameraOutput  | [CameraOutput](arkts-apis-camera-CameraOutput.md)   | 是   | 需要添加的CameraOutput实例。 |
239
240**错误码:**
241
242以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
243
244| 错误码ID         | 错误信息        |
245| --------------- | --------------- |
246| 7400101                |  Parameter missing or parameter type incorrect.        |
247| 7400102                |  Operation not allowed.                                  |
248
249**示例:**
250
251```ts
252import { BusinessError } from '@kit.BasicServicesKit';
253
254function addOutput(captureSession: camera.CaptureSession, cameraOutput: camera.CameraOutput): void {
255  try {
256    captureSession.addOutput(cameraOutput);
257  } catch (error) {
258    // 失败返回错误码error.code并处理。
259    let err = error as BusinessError;
260    console.error(`The addOutput call failed. error code: ${err.code}`);
261  }
262}
263```
264
265## removeOutput<sup>(deprecated)</sup>
266
267removeOutput(cameraOutput: CameraOutput): void
268
269从会话中移除[CameraOutput](arkts-apis-camera-CameraOutput.md)。
270
271> **说明:**
272>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.removeOutput](arkts-apis-camera-Session.md#removeoutput11)替代。
273
274**系统能力:** SystemCapability.Multimedia.Camera.Core
275
276**参数:**
277
278| 参数名           | 类型                             | 必填 | 说明                      |
279| ------------- | ------------------------------- | ---- | ------------------------ |
280| cameraOutput  | [CameraOutput](arkts-apis-camera-CameraOutput.md)   | 是   | 需要移除的CameraOutput实例。 |
281
282**错误码:**
283
284以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
285
286| 错误码ID         | 错误信息        |
287| --------------- | --------------- |
288| 7400101                |  Parameter missing or parameter type incorrect.        |
289| 7400102                |  Operation not allowed.                                  |
290
291**示例:**
292
293```ts
294import { BusinessError } from '@kit.BasicServicesKit';
295
296function removeOutput(captureSession: camera.CaptureSession, previewOutput: camera.PreviewOutput): void {
297  try {
298    captureSession.removeOutput(previewOutput);
299  } catch (error) {
300    // 失败返回错误码error.code并处理。
301    let err = error as BusinessError;
302    console.error(`The removeOutput call failed. error code: ${err.code}`);
303  }
304}
305```
306
307## start<sup>(deprecated)</sup>
308
309start(callback: AsyncCallback\<void\>): void
310
311开始会话工作,通过注册回调函数获取结果。使用callback异步回调。
312
313> **说明:**
314>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.start](arkts-apis-camera-Session.md#start11)替代。
315
316**系统能力:** SystemCapability.Multimedia.Camera.Core
317
318**参数:**
319
320| 参数名      | 类型                  | 必填 | 说明                 |
321| -------- | -------------------- | ---- | -------------------- |
322| callback | AsyncCallback\<void\> | 是   | 回调函数。当开始会话工作成功,err为undefined,否则为错误对象。错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
323
324**错误码:**
325
326以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
327
328| 错误码ID         | 错误信息        |
329| --------------- | --------------- |
330| 7400103                |  Session not config.                                   |
331| 7400201                |  Camera service fatal error.                           |
332
333**示例:**
334
335```ts
336import { BusinessError } from '@kit.BasicServicesKit';
337
338function startCaptureSession(captureSession: camera.CaptureSession): void {
339  captureSession.start((err: BusinessError) => {
340    if (err) {
341      console.error(`Failed to start the session, error code: ${err.code}.`);
342      return;
343    }
344    console.info('Callback invoked to indicate the session start success.');
345  });
346}
347```
348
349## start<sup>(deprecated)</sup>
350
351start(): Promise\<void\>
352
353开始会话工作。使用Promise异步回调。
354
355> **说明:**
356>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.start](arkts-apis-camera-Session.md#start11-1)替代。
357
358**系统能力:** SystemCapability.Multimedia.Camera.Core
359
360**返回值:**
361
362| 类型            | 说明                     |
363| -------------- | ------------------------ |
364| Promise\<void\> | Promise对象,无返回结果。 |
365
366**错误码:**
367
368以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
369
370| 错误码ID         | 错误信息        |
371| --------------- | --------------- |
372| 7400103                |  Session not config.                                   |
373| 7400201                |  Camera service fatal error.                           |
374
375**示例:**
376
377```ts
378import { BusinessError } from '@kit.BasicServicesKit';
379
380function startCaptureSession(captureSession: camera.CaptureSession): void {
381  captureSession.start().then(() => {
382    console.info('Promise returned to indicate the session start success.');
383  }).catch((err: BusinessError) => {
384    console.error(`Failed to start the session, error code: ${err.code}.`);
385  });
386}
387```
388
389## stop<sup>(deprecated)</sup>
390
391stop(callback: AsyncCallback\<void\>): void
392
393停止会话工作,通过注册回调函数获取结果。使用callback异步回调。
394
395> **说明:**
396>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.stop](arkts-apis-camera-Session.md#stop11)替代。
397
398**系统能力:** SystemCapability.Multimedia.Camera.Core
399
400**参数:**
401
402| 参数名      | 类型                  | 必填 | 说明                 |
403| -------- | -------------------- | ---- | ------------------- |
404| callback | AsyncCallback\<void\> | 是   | 回调函数。当停止会话工作成功,err为undefined,否则为错误对象。错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
405
406**错误码:**
407
408以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
409
410| 错误码ID         | 错误信息        |
411| --------------- | --------------- |
412| 7400201                |  Camera service fatal error.                           |
413
414**示例:**
415
416```ts
417import { BusinessError } from '@kit.BasicServicesKit';
418
419function stopCaptureSession(captureSession: camera.CaptureSession): void {
420  captureSession.stop((err: BusinessError) => {
421    if (err) {
422      console.error(`Failed to stop the session, error code: ${err.code}.`);
423      return;
424    }
425    console.info('Callback invoked to indicate the session stop success.');
426  });
427}
428```
429
430## stop<sup>(deprecated)</sup>
431
432stop(): Promise\<void\>
433
434停止会话工作。使用Promise异步回调。
435
436> **说明:**
437>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.stop](arkts-apis-camera-Session.md#stop11-1)替代。
438
439**系统能力:** SystemCapability.Multimedia.Camera.Core
440
441**返回值:**
442
443| 类型            | 说明                     |
444| -------------- | ----------------------- |
445| Promise\<void\> | Promise对象,无返回结果。 |
446
447**错误码:**
448
449以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
450
451| 错误码ID         | 错误信息        |
452| --------------- | --------------- |
453| 7400201                |  Camera service fatal error.                           |
454
455**示例:**
456
457```ts
458import { BusinessError } from '@kit.BasicServicesKit';
459
460function stopCaptureSession(captureSession: camera.CaptureSession): void {
461  captureSession.stop().then(() => {
462    console.info('Promise returned to indicate the session stop success.');
463  }).catch((err: BusinessError) => {
464    console.error(`Failed to stop the session, error code: ${err.code}.`);
465  });
466}
467```
468
469## release<sup>(deprecated)</sup>
470
471release(callback: AsyncCallback\<void\>): void
472
473释放会话资源,通过注册回调函数获取结果。使用callback异步回调。
474
475> **说明:**
476>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.release](arkts-apis-camera-Session.md#release11)替代。
477
478**系统能力:** SystemCapability.Multimedia.Camera.Core
479
480**参数:**
481
482| 参数名      | 类型                  | 必填 | 说明                 |
483| -------- | -------------------- | ---- | -------------------- |
484| callback | AsyncCallback\<void\> | 是   | 回调函数。当释放会话资源成功,err为undefined,否则为错误对象。错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
485
486**错误码:**
487
488以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
489
490| 错误码ID         | 错误信息        |
491| --------------- | --------------- |
492| 7400201                |  Camera service fatal error.                           |
493
494**示例:**
495
496```ts
497import { BusinessError } from '@kit.BasicServicesKit';
498
499function releaseCaptureSession(captureSession: camera.CaptureSession): void {
500  captureSession.release((err: BusinessError) => {
501    if (err) {
502      console.error(`Failed to release the CaptureSession instance, error code: ${err.code}.`);
503      return;
504    }
505    console.info('Callback invoked to indicate that the CaptureSession instance is released successfully.');
506  });
507}
508```
509
510## release<sup>(deprecated)</sup>
511
512release(): Promise\<void\>
513
514释放会话资源。使用Promise异步回调。
515
516> **说明:**
517>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.release](arkts-apis-camera-Session.md#release11-1)替代。
518
519**系统能力:** SystemCapability.Multimedia.Camera.Core
520
521**返回值:**
522
523| 类型            | 说明                     |
524| -------------- | ------------------------ |
525| Promise\<void\> | Promise对象,无返回结果。 |
526
527**错误码:**
528
529以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
530
531| 错误码ID         | 错误信息        |
532| --------------- | --------------- |
533| 7400201                |  Camera service fatal error.                           |
534
535**示例:**
536
537```ts
538import { BusinessError } from '@kit.BasicServicesKit';
539
540function releaseCaptureSession(captureSession: camera.CaptureSession): void {
541  captureSession.release().then(() => {
542    console.info('Promise returned to indicate that the CaptureSession instance is released successfully.');
543  }).catch((err: BusinessError) => {
544    console.error(`Failed to release the CaptureSession instance, error code: ${err.code}.`);
545  });
546}
547```
548
549## hasFlash<sup>(deprecated)</sup>
550
551hasFlash(): boolean
552
553检测是否有闪光灯。
554
555> **说明:**
556>从 API version 10开始支持,从API version 11开始废弃。建议使用[Flash.hasFlash](arkts-apis-camera-FlashQuery.md#hasflash11)替代。
557
558**系统能力:** SystemCapability.Multimedia.Camera.Core
559
560**返回值:**
561
562| 类型        | 说明                          |
563| ---------- | ----------------------------- |
564| boolean    | 设备支持闪光灯。true表示支持,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
565
566**错误码:**
567
568以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
569
570| 错误码ID         | 错误信息        |
571| --------------- | --------------- |
572| 7400103                |  Session not config.                                   |
573
574**示例:**
575
576```ts
577import { BusinessError } from '@kit.BasicServicesKit';
578
579function hasFlash(captureSession: camera.CaptureSession): boolean {
580  let status: boolean = false;
581  try {
582    status = captureSession.hasFlash();
583  } catch (error) {
584    // 失败返回错误码error.code并处理。
585    let err = error as BusinessError;
586    console.error(`The hasFlash call failed. error code: ${err.code}`);
587  }
588  return status;
589}
590```
591
592## isFlashModeSupported<sup>(deprecated)</sup>
593
594isFlashModeSupported(flashMode: FlashMode): boolean
595
596检测闪光灯模式是否支持。
597
598> **说明:**
599>从 API version 10开始支持,从API version 11开始废弃。建议使用[Flash.isFlashModeSupported](arkts-apis-camera-FlashQuery.md#isflashmodesupported11)替代。
600
601**系统能力:** SystemCapability.Multimedia.Camera.Core
602
603**参数:**
604
605| 参数名       | 类型                     | 必填 | 说明                               |
606| --------- | ----------------------- | ---- | --------------------------------- |
607| flashMode | [FlashMode](arkts-apis-camera-e.md#flashmode) | 是   | 指定闪光灯模式。                     |
608
609**返回值:**
610
611| 类型        | 说明                          |
612| ---------- | ----------------------------- |
613| boolean    | 检测闪光灯模式是否支持。true表示支持,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
614
615**错误码:**
616
617以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
618
619| 错误码ID         | 错误信息        |
620| --------------- | --------------- |
621| 7400103                |  Session not config.                                   |
622
623**示例:**
624
625```ts
626import { BusinessError } from '@kit.BasicServicesKit';
627
628function isFlashModeSupported(captureSession: camera.CaptureSession): boolean {
629  let status: boolean = false;
630  try {
631    status = captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO);
632  } catch (error) {
633    // 失败返回错误码error.code并处理。
634    let err = error as BusinessError;
635    console.error(`The isFlashModeSupported call failed. error code: ${err.code}`);
636  }
637  return status;
638}
639```
640
641## setFlashMode<sup>(deprecated)</sup>
642
643setFlashMode(flashMode: FlashMode): void
644
645设置闪光灯模式。
646
647进行设置之前,需要先检查:
648
6491. 设备是否支持闪光灯,可使用方法[hasFlash](#hasflashdeprecated)。
6502. 设备是否支持指定的闪光灯模式,可使用方法[isFlashModeSupported](#isflashmodesupporteddeprecated)。
651
652> **说明:**
653>从 API version 10开始支持,从API version 11开始废弃。建议使用[Flash.setFlashMode](arkts-apis-camera-Flash.md#setflashmode11)替代。
654
655**系统能力:** SystemCapability.Multimedia.Camera.Core
656
657**参数:**
658
659| 参数名     | 类型                    | 必填 | 说明                 |
660| --------- | ----------------------- | ---- | -------------------- |
661| flashMode | [FlashMode](arkts-apis-camera-e.md#flashmode) | 是   | 指定闪光灯模式。       |
662
663**错误码:**
664
665以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
666
667| 错误码ID         | 错误信息        |
668| --------------- | --------------- |
669| 7400103                |  Session not config.                                   |
670
671**示例:**
672
673```ts
674import { BusinessError } from '@kit.BasicServicesKit';
675
676function setFlashMode(captureSession: camera.CaptureSession): void {
677  try {
678    captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO);
679  } catch (error) {
680    // 失败返回错误码error.code并处理。
681    let err = error as BusinessError;
682    console.error(`The setFlashMode call failed. error code: ${err.code}`);
683  }
684}
685```
686
687## getFlashMode<sup>(deprecated)</sup>
688
689getFlashMode(): FlashMode
690
691获取当前设备的闪光灯模式。
692
693> **说明:**
694>从 API version 10开始支持,从API version 11开始废弃。建议使用[Flash.getFlashMode](arkts-apis-camera-Flash.md#getflashmode11)替代。
695
696**系统能力:** SystemCapability.Multimedia.Camera.Core
697
698**返回值:**
699
700| 类型        | 说明                          |
701| ---------- | ----------------------------- |
702| [FlashMode](arkts-apis-camera-e.md#flashmode)    | 获取当前设备的闪光灯模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
703
704**错误码:**
705
706以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
707
708| 错误码ID         | 错误信息        |
709| --------------- | --------------- |
710| 7400103                |  Session not config.                                   |
711
712**示例:**
713
714```ts
715import { BusinessError } from '@kit.BasicServicesKit';
716
717function getFlashMode(captureSession: camera.CaptureSession): camera.FlashMode | undefined {
718  let flashMode: camera.FlashMode | undefined = undefined;
719  try {
720    flashMode = captureSession.getFlashMode();
721  } catch (error) {
722    // 失败返回错误码error.code并处理。
723    let err = error as BusinessError;
724    console.error(`The getFlashMode call failed.error code: ${err.code}`);
725  }
726  return flashMode;
727}
728```
729
730## isExposureModeSupported<sup>(deprecated)</sup>
731
732isExposureModeSupported(aeMode: ExposureMode): boolean
733
734查询曝光模式是否支持。
735
736> **说明:**
737>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.isExposureModeSupported](arkts-apis-camera-AutoExposureQuery.md#isexposuremodesupported11)替代。
738
739**系统能力:** SystemCapability.Multimedia.Camera.Core
740
741**参数:**
742
743| 参数名      | 类型                           | 必填  | 说明                           |
744| -------- | -------------------------------| ---- | ----------------------------- |
745| aeMode   | [ExposureMode](arkts-apis-camera-e.md#exposuremode)  | 是   | 曝光模式。                      |
746
747**返回值:**
748
749| 类型        | 说明                          |
750| ---------- | ----------------------------- |
751| boolean    | 获取是否支持曝光模式。true表示支持,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
752
753**错误码:**
754
755以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
756
757| 错误码ID         | 错误信息        |
758| --------------- | --------------- |
759| 7400103                |  Session not config.                                   |
760
761**示例:**
762
763```ts
764import { BusinessError } from '@kit.BasicServicesKit';
765
766function isExposureModeSupported(captureSession: camera.CaptureSession): boolean {
767  let isSupported: boolean = false;
768  try {
769    isSupported = captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
770  } catch (error) {
771    // 失败返回错误码error.code并处理。
772    let err = error as BusinessError;
773    console.error(`The isExposureModeSupported call failed. error code: ${err.code}`);
774  }
775  return isSupported;
776}
777```
778
779## getExposureMode<sup>(deprecated)</sup>
780
781getExposureMode(): ExposureMode
782
783获取当前曝光模式。
784
785> **说明:**
786>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.getExposureMode](arkts-apis-camera-AutoExposure.md#getexposuremode11)替代。
787
788**系统能力:** SystemCapability.Multimedia.Camera.Core
789
790**返回值:**
791
792| 类型        | 说明                          |
793| ---------- | ----------------------------- |
794| [ExposureMode](arkts-apis-camera-e.md#exposuremode)    | 获取当前曝光模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
795
796**错误码:**
797
798以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
799
800| 错误码ID         | 错误信息        |
801| --------------- | --------------- |
802| 7400103                |  Session not config.                                   |
803
804**示例:**
805
806```ts
807import { BusinessError } from '@kit.BasicServicesKit';
808
809function getExposureMode(captureSession: camera.CaptureSession): camera.ExposureMode | undefined {
810  let exposureMode: camera.ExposureMode | undefined = undefined;
811  try {
812    exposureMode = captureSession.getExposureMode();
813  } catch (error) {
814    // 失败返回错误码error.code并处理。
815    let err = error as BusinessError;
816    console.error(`The getExposureMode call failed. error code: ${err.code}`);
817  }
818  return exposureMode;
819}
820```
821
822## setExposureMode<sup>(deprecated)</sup>
823
824setExposureMode(aeMode: ExposureMode): void
825
826设置曝光模式。进行设置之前,需要先检查设备是否支持指定的曝光模式,可使用方法[isExposureModeSupported](#isexposuremodesupporteddeprecated)。
827
828> **说明:**
829>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.setExposureMode](arkts-apis-camera-AutoExposure.md#setexposuremode11)替代。
830
831**系统能力:** SystemCapability.Multimedia.Camera.Core
832
833**参数:**
834
835| 参数名      | 类型                            | 必填 | 说明                    |
836| -------- | -------------------------------| ---- | ----------------------- |
837| aeMode   | [ExposureMode](arkts-apis-camera-e.md#exposuremode)  | 是   | 曝光模式。                |
838
839**错误码:**
840
841以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
842
843| 错误码ID         | 错误信息        |
844| --------------- | --------------- |
845| 7400103                |  Session not config.                                   |
846
847**示例:**
848
849```ts
850import { BusinessError } from '@kit.BasicServicesKit';
851
852function setExposureMode(captureSession: camera.CaptureSession): void {
853  try {
854    captureSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
855  } catch (error) {
856    // 失败返回错误码error.code并处理。
857    let err = error as BusinessError;
858    console.error(`The setExposureMode call failed. error code: ${err.code}`);
859  }
860}
861```
862
863## getMeteringPoint<sup>(deprecated)</sup>
864
865getMeteringPoint(): Point
866
867查询曝光区域中心点。
868
869> **说明:**
870>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.getMeteringPoint](arkts-apis-camera-AutoExposure.md#getmeteringpoint11)替代。
871
872**系统能力:** SystemCapability.Multimedia.Camera.Core
873
874**返回值:**
875
876| 类型        | 说明                          |
877| ---------- | ----------------------------- |
878| [Point](arkts-apis-camera-i.md#point)    | 获取当前曝光点。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
879
880**错误码:**
881
882以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
883
884| 错误码ID         | 错误信息        |
885| --------------- | --------------- |
886| 7400103                |  Session not config.                                   |
887
888**示例:**
889
890```ts
891import { BusinessError } from '@kit.BasicServicesKit';
892
893function getMeteringPoint(captureSession: camera.CaptureSession): camera.Point | undefined {
894  let exposurePoint: camera.Point | undefined = undefined;
895  try {
896    exposurePoint = captureSession.getMeteringPoint();
897  } catch (error) {
898    // 失败返回错误码error.code并处理。
899    let err = error as BusinessError;
900    console.error(`The getMeteringPoint call failed. error code: ${err.code}`);
901  }
902  return exposurePoint;
903}
904```
905
906## setMeteringPoint<sup>(deprecated)</sup>
907
908setMeteringPoint(point: Point): void
909
910设置曝光区域中心点,曝光点应位于0-1坐标系内,该坐标系左上角为{0,0},右下角为{1,1}。
911此坐标系是以设备充电口在右侧时的横向设备方向为基准的,例如应用的预览界面布局以
912设备充电口在下侧时的竖向方向为基准,布局宽高为{w,h},且触碰点为{x,y},
913则转换后的坐标点为{y/h,1-x/w}。
914
915> **说明:**
916>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.setMeteringPoint](arkts-apis-camera-AutoExposure.md#setmeteringpoint11)替代。
917
918**系统能力:** SystemCapability.Multimedia.Camera.Core
919
920**参数:**
921
922| 参数名           | 类型                            | 必填 | 说明                 |
923| ------------- | -------------------------------| ---- | ------------------- |
924| point | [Point](arkts-apis-camera-i.md#point)                | 是   | 曝光点,x,y设置范围应在[0,1]之内,超过范围,如果小于0设置0,大于1设置1。             |
925
926**错误码:**
927
928以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
929
930| 错误码ID         | 错误信息        |
931| --------------- | --------------- |
932| 7400103                |  Session not config.                                   |
933
934**示例:**
935
936```ts
937import { BusinessError } from '@kit.BasicServicesKit';
938
939function setMeteringPoint(captureSession: camera.CaptureSession): void {
940  const point: camera.Point = {x: 1, y: 1};
941  try {
942    captureSession.setMeteringPoint(point);
943  } catch (error) {
944    // 失败返回错误码error.code并处理。
945    let err = error as BusinessError;
946    console.error(`The setMeteringPoint call failed. error code: ${err.code}`);
947  }
948}
949```
950
951## getExposureBiasRange<sup>(deprecated)</sup>
952
953getExposureBiasRange(): Array\<number\>
954
955查询曝光补偿范围。
956
957> **说明:**
958>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.getExposureBiasRange](arkts-apis-camera-AutoExposureQuery.md#getexposurebiasrange11)替代。
959
960**系统能力:** SystemCapability.Multimedia.Camera.Core
961
962**返回值:**
963
964| 类型        | 说明                          |
965| ---------- | ----------------------------- |
966| Array\<number\>   | 获取补偿范围的数组。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
967
968**错误码:**
969
970以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
971
972| 错误码ID         | 错误信息        |
973| --------------- | --------------- |
974| 7400103                |  Session not config.                                   |
975
976**示例:**
977
978```ts
979import { BusinessError } from '@kit.BasicServicesKit';
980
981function getExposureBiasRange(captureSession: camera.CaptureSession): Array<number> {
982  let biasRangeArray: Array<number> = [];
983  try {
984    biasRangeArray = captureSession.getExposureBiasRange();
985  } catch (error) {
986    // 失败返回错误码error.code并处理。
987    let err = error as BusinessError;
988    console.error(`The getExposureBiasRange call failed. error code: ${err.code}`);
989  }
990  return biasRangeArray;
991}
992```
993
994## setExposureBias<sup>(deprecated)</sup>
995
996setExposureBias(exposureBias: number): void
997
998设置曝光补偿,曝光补偿值(EV)。
999
1000进行设置之前,建议先通过方法[getExposureBiasRange](#getexposurebiasrangedeprecated)查询支持的范围。
1001
1002> **说明:**
1003>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.setExposureBias](arkts-apis-camera-AutoExposure.md#setexposurebias11)替代。
1004
1005**系统能力:** SystemCapability.Multimedia.Camera.Core
1006
1007**参数:**
1008
1009| 参数名     | 类型         | 必填  | 说明       |
1010| -------- | -----------|-----|-----------------|
1011| exposureBias   | number                   | 是  | 曝光补偿,[getExposureBiasRange](arkts-apis-camera-AutoExposureQuery.md#getexposurebiasrange11)查询支持的范围,如果设置超过支持范围的值,自动匹配到就近临界点。曝光补偿存在步长,如步长为0.5。则设置1.2时,获取到实际生效曝光补偿为1.0。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。传参为null或者undefined,作为0处理,曝光补偿设置0。 |
1012
1013**错误码:**
1014
1015以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1016
1017| 错误码ID         | 错误信息        |
1018| --------------- | --------------- |
1019| 7400103                |  Session not config.                                   |
1020
1021**示例:**
1022
1023```ts
1024import { BusinessError } from '@kit.BasicServicesKit';
1025
1026function setExposureBias(captureSession: camera.CaptureSession, biasRangeArray: Array<number>): void {
1027  if (biasRangeArray && biasRangeArray.length > 0) {
1028    let exposureBias = biasRangeArray[0];
1029    try {
1030      captureSession.setExposureBias(exposureBias);
1031    } catch (error) {
1032      // 失败返回错误码error.code并处理。
1033      let err = error as BusinessError;
1034      console.error(`The setExposureBias call failed. error code: ${err.code}`);
1035    }
1036  }
1037}
1038```
1039
1040## getExposureValue<sup>(deprecated)</sup>
1041
1042getExposureValue(): number
1043
1044查询当前的曝光值。
1045
1046> **说明:**
1047>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.getExposureValue](arkts-apis-camera-AutoExposure.md#getexposurevalue11)替代。
1048
1049**系统能力:** SystemCapability.Multimedia.Camera.Core
1050
1051**返回值:**
1052
1053| 类型        | 说明                          |
1054| ---------- | ----------------------------- |
1055| number    | 获取曝光值。曝光补偿存在步长,如步长为0.5。则设置1.2时,获取到实际生效曝光补偿为1.0。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
1056
1057**错误码:**
1058
1059以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1060
1061| 错误码ID         | 错误信息        |
1062| --------------- | --------------- |
1063| 7400103                |  Session not config.                                   |
1064
1065**示例:**
1066
1067```ts
1068import { BusinessError } from '@kit.BasicServicesKit';
1069
1070function getExposureValue(captureSession: camera.CaptureSession): number {
1071  const invalidValue: number = -1;
1072  let exposureValue: number = invalidValue;
1073  try {
1074    exposureValue = captureSession.getExposureValue();
1075  } catch (error) {
1076    // 失败返回错误码error.code并处理。
1077    let err = error as BusinessError;
1078    console.error(`The getExposureValue call failed. error code: ${err.code}`);
1079  }
1080  return exposureValue;
1081}
1082```
1083
1084## isFocusModeSupported<sup>(deprecated)</sup>
1085
1086isFocusModeSupported(afMode: FocusMode): boolean
1087
1088查询对焦模式是否支持。
1089
1090> **说明:**
1091>从 API version 10开始支持,从API version 11开始废弃。建议使用[Focus.isFocusModeSupported](arkts-apis-camera-FocusQuery.md#isfocusmodesupported11)替代。
1092
1093**系统能力:** SystemCapability.Multimedia.Camera.Core
1094
1095**参数:**
1096
1097| 参数名      | 类型                     | 必填 | 说明                              |
1098| -------- | ----------------------- | ---- | -------------------------------- |
1099| afMode   | [FocusMode](arkts-apis-camera-e.md#focusmode) | 是   | 指定的焦距模式。                    |
1100
1101**返回值:**
1102
1103| 类型        | 说明                          |
1104| ---------- | ----------------------------- |
1105| boolean    | 检测对焦模式是否支持。true表示支持,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
1106
1107**错误码:**
1108
1109以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1110
1111| 错误码ID         | 错误信息        |
1112| --------------- | --------------- |
1113| 7400103                |  Session not config.                                   |
1114
1115**示例:**
1116
1117```ts
1118import { BusinessError } from '@kit.BasicServicesKit';
1119
1120function isFocusModeSupported(captureSession: camera.CaptureSession): boolean {
1121  let status: boolean = false;
1122  try {
1123    status = captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO);
1124  } catch (error) {
1125    // 失败返回错误码error.code并处理。
1126    let err = error as BusinessError;
1127    console.error(`The isFocusModeSupported call failed. error code: ${err.code}`);
1128  }
1129  return status;
1130}
1131```
1132
1133## setFocusMode<sup>(deprecated)</sup>
1134
1135setFocusMode(afMode: FocusMode): void
1136
1137设置对焦模式。
1138
1139进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupporteddeprecated)。
1140
1141> **说明:**
1142>从 API version 10开始支持,从API version 11开始废弃。建议使用[Focus.setFocusMode](arkts-apis-camera-Focus.md#setfocusmode11)替代。
1143
1144**系统能力:** SystemCapability.Multimedia.Camera.Core
1145
1146**参数:**
1147
1148| 参数名      | 类型                     | 必填 | 说明                 |
1149| -------- | ----------------------- | ---- | ------------------- |
1150| afMode   | [FocusMode](arkts-apis-camera-e.md#focusmode) | 是   | 指定的焦距模式。       |
1151
1152**错误码:**
1153
1154以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1155
1156| 错误码ID         | 错误信息        |
1157| --------------- | --------------- |
1158| 7400103                |  Session not config.                                   |
1159
1160**示例:**
1161
1162```ts
1163import { BusinessError } from '@kit.BasicServicesKit';
1164
1165function setFocusMode(captureSession: camera.CaptureSession): void {
1166  try {
1167    captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO);
1168  } catch (error) {
1169    // 失败返回错误码error.code并处理。
1170    let err = error as BusinessError;
1171    console.error(`The setFocusMode call failed. error code: ${err.code}`);
1172  }
1173}
1174```
1175
1176## getFocusMode<sup>(deprecated)</sup>
1177
1178getFocusMode(): FocusMode
1179
1180获取当前的对焦模式。
1181
1182> **说明:**
1183>从 API version 10开始支持,从API version 11开始废弃。建议使用[Focus.getFocusMode](arkts-apis-camera-Focus.md#getfocusmode11)替代。
1184
1185**系统能力:** SystemCapability.Multimedia.Camera.Core
1186
1187**返回值:**
1188
1189| 类型        | 说明                          |
1190| ---------- | ----------------------------- |
1191| [FocusMode](arkts-apis-camera-e.md#focusmode)   | 获取当前设备的焦距模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
1192
1193**错误码:**
1194
1195以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1196
1197| 错误码ID         | 错误信息        |
1198| --------------- | --------------- |
1199| 7400103                |  Session not config.                                   |
1200
1201**示例:**
1202
1203```ts
1204import { BusinessError } from '@kit.BasicServicesKit';
1205
1206function getFocusMode(captureSession: camera.CaptureSession): camera.FocusMode | undefined {
1207  let afMode: camera.FocusMode | undefined = undefined;
1208  try {
1209    afMode = captureSession.getFocusMode();
1210  } catch (error) {
1211    // 失败返回错误码error.code并处理。
1212    let err = error as BusinessError;
1213    console.error(`The getFocusMode call failed. error code: ${err.code}`);
1214  }
1215  return afMode;
1216}
1217```
1218
1219## setFocusPoint<sup>(deprecated)</sup>
1220
1221setFocusPoint(point: Point): void
1222
1223设置焦点,焦点应在0-1坐标系内,该坐标系左上角为{0,0},右下角为{1,1}。
1224此坐标系是以设备充电口在右侧时的横向设备方向为基准的,例如应用的预览界面布局以
1225设备充电口在下侧时的竖向方向为基准,布局宽高为{w,h},且触碰点为{x,y},
1226则转换后的坐标点为{y/h,1-x/w}。
1227
1228> **说明:**
1229>从 API version 10开始支持,从API version 11开始废弃。建议使用[Focus.setFocusPoint](arkts-apis-camera-Focus.md#setfocuspoint11)替代。
1230
1231**系统能力:** SystemCapability.Multimedia.Camera.Core
1232
1233**参数:**
1234
1235| 参数名   | 类型                     | 必填  | 说明                 |
1236|-------| ----------------------- |-----| ------------------- |
1237| point | [Point](arkts-apis-camera-i.md#point)         | 是  | 焦点。x,y设置范围应在[0,1]之内,超过范围,如果小于0设置0,大于1设置1。   |
1238
1239**错误码:**
1240
1241以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1242
1243| 错误码ID         | 错误信息        |
1244| --------------- | --------------- |
1245| 7400103                |  Session not config.                                   |
1246
1247**示例:**
1248
1249```ts
1250import { BusinessError } from '@kit.BasicServicesKit';
1251
1252function setFocusPoint(captureSession: camera.CaptureSession): void {
1253  const focusPoint: camera.Point = {x: 1, y: 1};
1254  try {
1255    captureSession.setFocusPoint(focusPoint);
1256  } catch (error) {
1257    // 失败返回错误码error.code并处理。
1258    let err = error as BusinessError;
1259    console.error(`The setFocusPoint call failed. error code: ${err.code}`);
1260  }
1261}
1262```
1263
1264## getFocusPoint<sup>(deprecated)</sup>
1265
1266getFocusPoint(): Point
1267
1268查询焦点。
1269
1270> **说明:**
1271>从 API version 10开始支持,从API version 11开始废弃。建议使用[Focus.getFocusPoint](arkts-apis-camera-Focus.md#getfocuspoint11)替代。
1272
1273**系统能力:** SystemCapability.Multimedia.Camera.Core
1274
1275**返回值:**
1276
1277| 类型        | 说明                          |
1278| ---------- | ----------------------------- |
1279| [Point](arkts-apis-camera-i.md#point)    | 用于获取当前焦点。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
1280
1281**错误码:**
1282
1283以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1284
1285| 错误码ID         | 错误信息        |
1286| --------------- | --------------- |
1287| 7400103                |  Session not config.                                   |
1288
1289**示例:**
1290
1291```ts
1292import { BusinessError } from '@kit.BasicServicesKit';
1293
1294function getFocusPoint(captureSession: camera.CaptureSession): camera.Point | undefined {
1295  let point: camera.Point | undefined = undefined;
1296  try {
1297    point = captureSession.getFocusPoint();
1298  } catch (error) {
1299    // 失败返回错误码error.code并处理。
1300    let err = error as BusinessError;
1301    console.error(`The getFocusPoint call failed. error code: ${err.code}`);
1302  }
1303  return point;
1304}
1305```
1306
1307## getFocalLength<sup>(deprecated)</sup>
1308
1309getFocalLength(): number
1310
1311查询焦距值。
1312
1313> **说明:**
1314>从 API version 10开始支持,从API version 11开始废弃。建议使用[Focus.getFocalLength](arkts-apis-camera-Focus.md#getfocallength11)替代。
1315
1316**系统能力:** SystemCapability.Multimedia.Camera.Core
1317
1318**返回值:**
1319
1320| 类型        | 说明                          |
1321| ---------- | ----------------------------- |
1322| number    | 用于获取当前焦距。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
1323
1324**错误码:**
1325
1326以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1327
1328| 错误码ID         | 错误信息        |
1329| --------------- | --------------- |
1330| 7400103                |  Session not config.                                   |
1331
1332**示例:**
1333
1334```ts
1335import { BusinessError } from '@kit.BasicServicesKit';
1336
1337function getFocalLength(captureSession: camera.CaptureSession): number {
1338  const invalidValue: number = -1;
1339  let focalLength: number = invalidValue;
1340  try {
1341    focalLength = captureSession.getFocalLength();
1342  } catch (error) {
1343    // 失败返回错误码error.code并处理。
1344    let err = error as BusinessError;
1345    console.error(`The getFocalLength call failed. error code: ${err.code}`);
1346  }
1347  return focalLength;
1348}
1349```
1350
1351## getZoomRatioRange<sup>(deprecated)</sup>
1352
1353getZoomRatioRange(): Array\<number\>
1354
1355获取支持的变焦范围。
1356
1357> **说明:**
1358>从 API version 10开始支持,从API version 11开始废弃。建议使用[Zoom.getZoomRatioRange](arkts-apis-camera-ZoomQuery.md#getzoomratiorange11)替代。
1359
1360**系统能力:** SystemCapability.Multimedia.Camera.Core
1361
1362**返回值:**
1363
1364| 类型        | 说明                          |
1365| ---------- | ----------------------------- |
1366| Array\<number\>   | 用于获取可变焦距比范围,返回的数组包括其最小值和最大值。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
1367
1368**错误码:**
1369
1370以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1371
1372| 错误码ID         | 错误信息        |
1373| --------------- | --------------- |
1374| 7400103                |  Session not config.                                   |
1375
1376**示例:**
1377
1378```ts
1379import { BusinessError } from '@kit.BasicServicesKit';
1380
1381function getZoomRatioRange(captureSession: camera.CaptureSession): Array<number> {
1382  let zoomRatioRange: Array<number> = [];
1383  try {
1384    zoomRatioRange = captureSession.getZoomRatioRange();
1385  } catch (error) {
1386    // 失败返回错误码error.code并处理。
1387    let err = error as BusinessError;
1388    console.error(`The getZoomRatioRange call failed. error code: ${err.code}`);
1389  }
1390  return zoomRatioRange;
1391}
1392```
1393
1394## setZoomRatio<sup>(deprecated)</sup>
1395
1396setZoomRatio(zoomRatio: number): void
1397
1398设置变焦比,变焦精度最高为小数点后两位,如果设置超过支持的精度范围,则只保留精度范围内数值。
1399
1400> **说明:**
1401>从 API version 10开始支持,从API version 11开始废弃。建议使用[Zoom.setZoomRatio](arkts-apis-camera-Zoom.md#setzoomratio11)替代。
1402
1403**系统能力:** SystemCapability.Multimedia.Camera.Core
1404
1405**参数:**
1406
1407| 参数名       | 类型                  | 必填  | 说明                 |
1408| --------- | -------------------- |-----| ------------------- |
1409| zoomRatio | number               | 是  | 可变焦距比,通过[getZoomRatioRange](arkts-apis-camera-ZoomQuery.md#getzoomratiorange11)获取支持的变焦范围,如果设置超过支持范围的值,则只保留精度范围内数值。传参为null或者undefined,作为0处理,变焦设置最小值。 |
1410
1411**错误码:**
1412
1413以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1414
1415| 错误码ID         | 错误信息        |
1416| --------------- | --------------- |
1417| 7400103                |  Session not config.                                   |
1418
1419**示例:**
1420
1421```ts
1422import { BusinessError } from '@kit.BasicServicesKit';
1423
1424function setZoomRatio(captureSession: camera.CaptureSession, zoomRatioRange: Array<number>): void {
1425  if (zoomRatioRange === undefined || zoomRatioRange.length <= 0) {
1426    return;
1427  }
1428  let zoomRatio = zoomRatioRange[0];
1429  try {
1430    captureSession.setZoomRatio(zoomRatio);
1431  } catch (error) {
1432    // 失败返回错误码error.code并处理。
1433    let err = error as BusinessError;
1434    console.error(`The setZoomRatio call failed. error code: ${err.code}`);
1435  }
1436}
1437```
1438
1439## getZoomRatio<sup>(deprecated)</sup>
1440
1441getZoomRatio(): number
1442
1443获取当前的变焦比。
1444
1445> **说明:**
1446>从 API version 10开始支持,从API version 11开始废弃。建议使用[Zoom.getZoomRatio](arkts-apis-camera-Zoom.md#getzoomratio11)替代。
1447
1448**系统能力:** SystemCapability.Multimedia.Camera.Core
1449
1450**返回值:**
1451
1452| 类型        | 说明                          |
1453| ---------- | ----------------------------- |
1454| number    | 获取当前的变焦比结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
1455
1456**错误码:**
1457
1458以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1459
1460| 错误码ID         | 错误信息        |
1461| --------------- | --------------- |
1462| 7400103                |  Session not config.                                   |
1463
1464**示例:**
1465
1466```ts
1467import { BusinessError } from '@kit.BasicServicesKit';
1468
1469function getZoomRatio(captureSession: camera.CaptureSession): number {
1470  const invalidValue: number = -1;
1471  let zoomRatio: number = invalidValue;
1472  try {
1473    zoomRatio = captureSession.getZoomRatio();
1474  } catch (error) {
1475    // 失败返回错误码error.code并处理。
1476    let err = error as BusinessError;
1477    console.error(`The getZoomRatio call failed. error code: ${err.code}`);
1478  }
1479  return zoomRatio;
1480}
1481```
1482
1483## isVideoStabilizationModeSupported<sup>(deprecated)</sup>
1484
1485isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean
1486
1487查询是否支持指定的视频防抖模式。
1488
1489> **说明:**
1490>从 API version 10开始支持,从API version 11开始废弃。建议使用[Stabilization.isVideoStabilizationModeSupported](arkts-apis-camera-StabilizationQuery.md#isvideostabilizationmodesupported11)替代。
1491
1492**系统能力:** SystemCapability.Multimedia.Camera.Core
1493
1494**参数:**
1495
1496| 参数名      | 类型                                              | 必填 | 说明                             |
1497| -------- | ------------------------------------------------- | ---- | ------------------------------ |
1498| vsMode   | [VideoStabilizationMode](arkts-apis-camera-e.md#videostabilizationmode) | 是   | 视频防抖模式。传参为null或者undefined,作为0处理,超级防抖模式关闭。              |
1499
1500**返回值:**
1501
1502| 类型        | 说明                          |
1503| ---------- | ----------------------------- |
1504| boolean    | 返回视频防抖模式是否支持。true表示支持,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
1505
1506**错误码:**
1507
1508以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1509
1510| 错误码ID         | 错误信息        |
1511| --------------- | --------------- |
1512| 7400103                |  Session not config.                                   |
1513
1514**示例:**
1515
1516```ts
1517import { BusinessError } from '@kit.BasicServicesKit';
1518
1519function isVideoStabilizationModeSupported(captureSession: camera.CaptureSession): boolean {
1520  let isSupported: boolean = false;
1521  try {
1522    isSupported = captureSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF);
1523  } catch (error) {
1524    // 失败返回错误码error.code并处理。
1525    let err = error as BusinessError;
1526    console.error(`The isVideoStabilizationModeSupported call failed. error code: ${err.code}`);
1527  }
1528  return isSupported;
1529}
1530```
1531
1532## getActiveVideoStabilizationMode<sup>(deprecated)</sup>
1533
1534getActiveVideoStabilizationMode(): VideoStabilizationMode
1535
1536查询当前正在使用的视频防抖模式。
1537
1538> **说明:**
1539>从 API version 10开始支持,从API version 11开始废弃。建议使用[Stabilization.getActiveVideoStabilizationMode](arkts-apis-camera-Stabilization.md#getactivevideostabilizationmode11)替代。
1540
1541**系统能力:** SystemCapability.Multimedia.Camera.Core
1542
1543**返回值:**
1544
1545| 类型        | 说明                          |
1546| ---------- | ----------------------------- |
1547| [VideoStabilizationMode](arkts-apis-camera-e.md#videostabilizationmode)    | 视频防抖是否正在使用。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
1548
1549**错误码:**
1550
1551以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1552
1553| 错误码ID         | 错误信息        |
1554| --------------- | --------------- |
1555| 7400103                |  Session not config.                                   |
1556
1557**示例:**
1558
1559```ts
1560import { BusinessError } from '@kit.BasicServicesKit';
1561
1562function getActiveVideoStabilizationMode(captureSession: camera.CaptureSession): camera.VideoStabilizationMode | undefined {
1563  let vsMode: camera.VideoStabilizationMode | undefined = undefined;
1564  try {
1565    vsMode = captureSession.getActiveVideoStabilizationMode();
1566  } catch (error) {
1567    // 失败返回错误码error.code并处理。
1568    let err = error as BusinessError;
1569    console.error(`The getActiveVideoStabilizationMode call failed. error code: ${err.code}`);
1570  }
1571  return vsMode;
1572}
1573```
1574
1575## setVideoStabilizationMode<sup>(deprecated)</sup>
1576
1577setVideoStabilizationMode(mode: VideoStabilizationMode): void
1578
1579设置视频防抖模式。需要先检查设备是否支持对应的防抖模式,可以通过[isVideoStabilizationModeSupported](#isvideostabilizationmodesupporteddeprecated)方法判断所设置的模式是否支持。
1580
1581> **说明:**
1582>从 API version 10开始支持,从API version 11开始废弃。建议使用[Stabilization.setVideoStabilizationMode](arkts-apis-camera-Stabilization.md#setvideostabilizationmode11)替代。
1583
1584**系统能力:** SystemCapability.Multimedia.Camera.Core
1585
1586**参数:**
1587
1588| 参数名      | 类型                                              | 必填 | 说明                    |
1589| -------- | ------------------------------------------------- | ---- | --------------------- |
1590| mode     | [VideoStabilizationMode](arkts-apis-camera-e.md#videostabilizationmode) | 是   | 需要设置的视频防抖模式。传参为null或者undefined,作为0处理,超级防抖模式关闭。   |
1591
1592**错误码:**
1593
1594以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1595
1596| 错误码ID         | 错误信息        |
1597| --------------- | --------------- |
1598| 7400103                |  Session not config.                                   |
1599
1600**示例:**
1601
1602```ts
1603import { BusinessError } from '@kit.BasicServicesKit';
1604
1605function setVideoStabilizationMode(captureSession: camera.CaptureSession): void {
1606  try {
1607    captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF);
1608  } catch (error) {
1609    // 失败返回错误码error.code并处理。
1610    let err = error as BusinessError;
1611    console.error(`The setVideoStabilizationMode call failed. error code: ${err.code}`);
1612  }
1613}
1614```
1615
1616## on('focusStateChange')<sup>(deprecated)</sup>
1617
1618on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void
1619
1620监听相机聚焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。
1621
1622> **说明:**
1623> 从 API version 10开始支持,从API version 11开始废弃。建议使用[VideoSession.on('focusStateChange')](arkts-apis-camera-VideoSession.md#onfocusstatechange11)替代。
1624>
1625> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
1626
1627**系统能力:** SystemCapability.Multimedia.Camera.Core
1628
1629**参数:**
1630
1631| 参数名     | 类型                                      | 必填 | 说明                       |
1632| -------- | ----------------------------------------- | ---- | ------------------------ |
1633| type     | string                                    | 是   | 监听事件,固定为'focusStateChange',session 创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 |
1634| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 是   | 回调函数,用于获取当前对焦状态。  |
1635
1636**示例:**
1637
1638```ts
1639import { BusinessError } from '@kit.BasicServicesKit';
1640
1641function registerFocusStateChange(captureSession: camera.CaptureSession): void {
1642  captureSession.on('focusStateChange', (err: BusinessError, focusState: camera.FocusState) => {
1643    if (err !== undefined && err.code !== 0) {
1644      console.error(`Callback Error, errorCode: ${err.code}`);
1645      return;
1646    }
1647    console.info(`Focus state: ${focusState}`);
1648  });
1649}
1650```
1651
1652## off('focusStateChange')<sup>(deprecated)</sup>
1653
1654off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void
1655
1656注销监听相机聚焦的状态变化。
1657
1658> **说明:**
1659>从 API version 10开始支持,从API version 11开始废弃。建议使用[VideoSession.off('focusStateChange')](arkts-apis-camera-VideoSession.md#offfocusstatechange11)替代。
1660
1661**系统能力:** SystemCapability.Multimedia.Camera.Core
1662
1663**参数:**
1664
1665| 参数名     | 类型                                      | 必填 | 说明                       |
1666| -------- | ----------------------------------------- | ---- | ------------------------ |
1667| type     | string                                    | 是   | 监听事件,固定为'focusStateChange',session 创建成功可监听。|
1668| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
1669
1670**示例:**
1671
1672```ts
1673function unregisterFocusStateChange(captureSession: camera.CaptureSession): void {
1674  captureSession.off('focusStateChange');
1675}
1676```
1677
1678## on('error')<sup>(deprecated)</sup>
1679
1680on(type: 'error', callback: ErrorCallback): void
1681
1682监听拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。
1683
1684> **说明:**
1685>
1686> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
1687
1688> **说明:**
1689>从 API version 10开始支持,从API version 11开始废弃。建议使用[VideoSession.on('error')](arkts-apis-camera-VideoSession.md#onerror11)替代。
1690
1691**系统能力:** SystemCapability.Multimedia.Camera.Core
1692
1693**参数:**
1694
1695| 参数名     | 类型                                                                       | 必填 | 说明                           |
1696| -------- |--------------------------------------------------------------------------| ---- | ------------------------------ |
1697| type     | string                                                                   | 是   | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](#beginconfigdeprecated),[commitConfig](#commitconfigdeprecated-1),[addInput](#addinputdeprecated)等接口发生错误时返回错误信息。 |
1698| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是   | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。        |
1699
1700**示例:**
1701
1702```ts
1703import { BusinessError } from '@kit.BasicServicesKit';
1704
1705function registerCaptureSessionError(captureSession: camera.CaptureSession): void {
1706  captureSession.on('error', (error: BusinessError) => {
1707    console.error(`Capture session error code: ${error.code}`);
1708  });
1709}
1710```
1711
1712## off('error')<sup>(deprecated)</sup>
1713
1714off(type: 'error', callback?: ErrorCallback): void
1715
1716注销监听拍照会话的错误事件,通过注册回调函数获取结果。
1717
1718> **说明:**
1719>从 API version 10开始支持,从API version 11开始废弃。建议使用[VideoSession.off('error')](arkts-apis-camera-VideoSession.md#offerror11)替代。
1720
1721**系统能力:** SystemCapability.Multimedia.Camera.Core
1722
1723**参数:**
1724
1725| 参数名     | 类型                                                          | 必填 | 说明                           |
1726| -------- | ----------------------------------------------------------- | ---- | ------------------------------ |
1727| type     | string                                                      | 是   | 监听事件,固定为'error',session创建成功之后可监听该接口。 |
1728| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
1729
1730**示例:**
1731
1732```ts
1733function unregisterCaptureSessionError(captureSession: camera.CaptureSession): void {
1734  captureSession.off('error');
1735}
1736```
1737