• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Interface (CameraOutput)
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
13会话中[Session](arkts-apis-camera-Session.md)使用的输出信息,output的基类。
14
15## 导入模块
16
17```ts
18import { camera } from '@kit.CameraKit';
19```
20
21## release
22
23release(callback: AsyncCallback\<void\>): void
24
25释放输出资源,通过注册回调函数获取结果。使用callback异步回调。
26
27**原子化服务API:** 从API version 19开始,该接口支持在原子化服务中使用。
28
29**系统能力:** SystemCapability.Multimedia.Camera.Core
30
31**参数:**
32
33| 参数名      | 类型                  | 必填 | 说明                 |
34| -------- | -------------------- | ---- | ------------------- |
35| callback | AsyncCallback\<void\> | 是   | 回调函数。当释放输出资源成功,err为undefined,否则为错误对象。错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 |
36
37**错误码:**
38
39以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
40
41| 错误码ID         | 错误信息        |
42| --------------- | --------------- |
43| 7400201                |  Camera service fatal error.                           |
44
45**示例:**
46
47```ts
48import { BusinessError } from '@kit.BasicServicesKit';
49
50function releasePreviewOutput(previewOutput: camera.PreviewOutput): void {
51  previewOutput.release((err: BusinessError) => {
52    if (err) {
53      console.error(`Failed to release the Preview output instance ${err.code}`);
54      return;
55    }
56    console.info('Callback invoked to indicate that the preview output instance is released successfully.');
57  });
58}
59
60function releaseVideoOutput(videoOutput: camera.VideoOutput): void {
61  videoOutput.release((err: BusinessError) => {
62    if (err) {
63      console.error(`Failed to release the video output instance ${err.code}`);
64      return;
65    }
66    console.info('Callback invoked to indicate that the video output instance is released successfully.');
67  });
68}
69```
70
71## release
72
73release(): Promise\<void\>
74
75释放输出资源。使用Promise异步回调。
76
77**原子化服务API:** 从API version 19开始,该接口支持在原子化服务中使用。
78
79**系统能力:** SystemCapability.Multimedia.Camera.Core
80
81**返回值:**
82
83| 类型            | 说明                     |
84| -------------- | ----------------------- |
85| Promise\<void\> | Promise对象,无返回结果。 |
86
87**错误码:**
88
89以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
90
91| 错误码ID         | 错误信息        |
92| --------------- | --------------- |
93| 7400201                |  Camera service fatal error.                           |
94
95**示例:**
96
97```ts
98import { BusinessError } from '@kit.BasicServicesKit';
99
100function releasePreviewOutput(previewOutput: camera.PreviewOutput): void {
101  previewOutput.release().then(() => {
102    console.info('Promise returned to indicate that the preview output instance is released successfully.');
103  }).catch((error: BusinessError) => {
104    console.error(`Failed to preview output release, error code: ${error.code}`);
105  });
106}
107
108function releaseVideoOutput(videoOutput: camera.VideoOutput): void {
109  videoOutput.release().then(() => {
110    console.info('Promise returned to indicate that the video output instance is released successfully.');
111  }).catch((error: BusinessError) => {
112    console.error(`Failed to video output release, error code: ${error.code}`);
113  });
114}
115```
116