• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Interface (FocusQuery)
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 12。接口在API version 12发生兼容变更,保留了内层元素的起始版本信息,会出现外层元素@since版本号大于内层元素的情况,不影响接口使用。
13
14提供了查询是否支持当前对焦模式的方法。
15
16## 导入模块
17
18```ts
19import { camera } from '@kit.CameraKit';
20```
21
22## isFocusModeSupported<sup>11+</sup>
23
24isFocusModeSupported(afMode: FocusMode): boolean
25
26检测对焦模式是否支持。
27
28**原子化服务API:** 从API version 19开始,该接口支持在原子化服务中使用。
29
30**系统能力:** SystemCapability.Multimedia.Camera.Core
31
32**参数:**
33
34| 参数名      | 类型                     | 必填 | 说明                              |
35| -------- | ----------------------- | ---- | -------------------------------- |
36| afMode   | [FocusMode](arkts-apis-camera-e.md#focusmode) | 是   | 指定的焦距模式。传参为null或者undefined,作为0处理,手动对焦模式。                    |
37
38**返回值:**
39
40| 类型        | 说明                          |
41| ---------- | ----------------------------- |
42| boolean    | 检测对焦模式是否支持。true表示支持,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
43
44**错误码:**
45
46以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
47
48| 错误码ID         | 错误信息        |
49| --------------- | --------------- |
50| 7400103                |  Session not config, only throw in session usage.          |
51
52**示例:**
53
54```ts
55import { BusinessError } from '@kit.BasicServicesKit';
56
57function isFocusModeSupported(photoSession: camera.PhotoSession): boolean {
58  let status: boolean = false;
59  try {
60    status = photoSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO);
61  } catch (error) {
62    // 失败返回错误码error.code并处理。
63    let err = error as BusinessError;
64    console.error(`The isFocusModeSupported call failed. error code: ${err.code}`);
65  }
66  return status;
67}
68```
69