• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Interface (CameraOutput)
2<!--Kit: Camera Kit-->
3<!--Subsystem: Multimedia-->
4<!--Owner: @qano-->
5<!--SE: @leo_ysl-->
6<!--TSE: @xchaosioda-->
7
8> **NOTE**
9>
10> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
11
12CameraOutput implements output information used in [Session](arkts-apis-camera-Session.md). It is the base class of **output**.
13
14## Modules to Import
15
16```ts
17import { camera } from '@kit.CameraKit';
18```
19
20## release
21
22release(callback: AsyncCallback\<void\>): void
23
24Releases output resources. This API uses an asynchronous callback to return the result.
25
26**Atomic service API**: This API can be used in atomic services since API version 19.
27
28**System capability**: SystemCapability.Multimedia.Camera.Core
29
30**Parameters**
31
32| Name     | Type                 | Mandatory| Description                |
33| -------- | -------------------- | ---- | ------------------- |
34| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.|
35
36**Error codes**
37
38For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
39
40| ID        | Error Message       |
41| --------------- | --------------- |
42| 7400201                |  Camera service fatal error.                           |
43
44**Example**
45
46```ts
47import { BusinessError } from '@kit.BasicServicesKit';
48
49function releasePreviewOutput(previewOutput: camera.PreviewOutput): void {
50  previewOutput.release((err: BusinessError) => {
51    if (err) {
52      console.error(`Failed to release the Preview output instance ${err.code}`);
53      return;
54    }
55    console.info('Callback invoked to indicate that the preview output instance is released successfully.');
56  });
57}
58
59function releaseVideoOutput(videoOutput: camera.VideoOutput): void {
60  videoOutput.release((err: BusinessError) => {
61    if (err) {
62      console.error(`Failed to release the video output instance ${err.code}`);
63      return;
64    }
65    console.info('Callback invoked to indicate that the video output instance is released successfully.');
66  });
67}
68```
69
70## release
71
72release(): Promise\<void\>
73
74Releases output resources. This API uses a promise to return the result.
75
76**Atomic service API**: This API can be used in atomic services since API version 19.
77
78**System capability**: SystemCapability.Multimedia.Camera.Core
79
80**Return value**
81
82| Type           | Description                    |
83| -------------- | ----------------------- |
84| Promise\<void\> | Promise that returns no value.|
85
86**Error codes**
87
88For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
89
90| ID        | Error Message       |
91| --------------- | --------------- |
92| 7400201                |  Camera service fatal error.                           |
93
94**Example**
95
96```ts
97import { BusinessError } from '@kit.BasicServicesKit';
98
99function releasePreviewOutput(previewOutput: camera.PreviewOutput): void {
100  previewOutput.release().then(() => {
101    console.info('Promise returned to indicate that the preview output instance is released successfully.');
102  }).catch((error: BusinessError) => {
103    console.error(`Failed to preview output release, error code: ${error.code}`);
104  });
105}
106
107function releaseVideoOutput(videoOutput: camera.VideoOutput): void {
108  videoOutput.release().then(() => {
109    console.info('Promise returned to indicate that the video output instance is released successfully.');
110  }).catch((error: BusinessError) => {
111    console.error(`Failed to video output release, error code: ${error.code}`);
112  });
113}
114```
115