Interface (CameraOutput)
CameraOutput implements output information used in Session. It is the base class of output.
NOTE
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.
Modules to Import
import { camera } from '@kit.CameraKit';
release
release(callback: AsyncCallback<void>): void
Releases output resources. This API uses an asynchronous callback to return the result.
Atomic service API: This API can be used in atomic services since API version 19.
System capability: SystemCapability.Multimedia.Camera.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the output resources are released successfully, err is undefined; otherwise, err is an error object with an error code defined in CameraErrorCode. |
Error codes
For details about the error codes, see Camera Error Codes.
| ID | Error Message |
|---|---|
| 7400201 | Camera service fatal error. |
Example
import { BusinessError } from '@kit.BasicServicesKit';
function releasePreviewOutput(previewOutput: camera.PreviewOutput): void {
previewOutput.release((err: BusinessError) => {
if (err) {
console.error(`Failed to release the Preview output instance ${err.code}`);
return;
}
console.info('Callback invoked to indicate that the preview output instance is released successfully.');
});
}
function releaseVideoOutput(videoOutput: camera.VideoOutput): void {
videoOutput.release((err: BusinessError) => {
if (err) {
console.error(`Failed to release the video output instance ${err.code}`);
return;
}
console.info('Callback invoked to indicate that the video output instance is released successfully.');
});
}
release
release(): Promise<void>
Releases output resources. This API uses a promise to return the result.
Atomic service API: This API can be used in atomic services since API version 19.
System capability: SystemCapability.Multimedia.Camera.Core
Return value
| Type | Description |
|---|---|
| Promise<void> | Promise that returns no value. |
Error codes
For details about the error codes, see Camera Error Codes.
| ID | Error Message |
|---|---|
| 7400201 | Camera service fatal error. |
Example
import { BusinessError } from '@kit.BasicServicesKit';
function releasePreviewOutput(previewOutput: camera.PreviewOutput): void {
previewOutput.release().then(() => {
console.info('Promise returned to indicate that the preview output instance is released successfully.');
}).catch((error: BusinessError) => {
console.error(`Failed to preview output release, error code: ${error.code}`);
});
}
function releaseVideoOutput(videoOutput: camera.VideoOutput): void {
videoOutput.release().then(() => {
console.info('Promise returned to indicate that the video output instance is released successfully.');
}).catch((error: BusinessError) => {
console.error(`Failed to video output release, error code: ${error.code}`);
});
}