未验证 提交 6417b286 编写于 作者: O openharmony_ci 提交者: Gitee

!6491 翻译完成:6171 camera文档优化

Merge pull request !6491 from wusongqing/TR6171
# Camera Management
> **NOTE**<br/>
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
```js
import camera from '@ohos.multimedia.camera';
```
## Required Permissions
ohos.permission.CAMERA
## camera.getCameraManager
getCameraManager(context: Context, callback: AsyncCallback<CameraManager\>): void
......@@ -30,7 +27,7 @@ Obtains a **CameraManager** instance. This API uses an asynchronous callback to
**Example**
```
```js
camera.getCameraManager(context, (err, cameraManager) => {
if (err) {
console.error('Failed to get the CameraManager instance ${err.message}');
......@@ -62,7 +59,7 @@ Obtains a **CameraManager** instance. This API uses a promise to return the resu
**Example**
```
```js
camera.getCameraManager(context).then((cameraManager) => {
console.log('Promise returned with the CameraManager instance.');
})
......@@ -74,8 +71,8 @@ Enumerates the camera statuses.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ------------------------- | ------ | ------------ |
| Name | Value | Description |
| ------------------------- | ---- | ------------ |
| CAMERA_STATUS_APPEAR | 0 | The camera exists. |
| CAMERA_STATUS_DISAPPEAR | 1 | The camera does not exist.|
| CAMERA_STATUS_AVAILABLE | 2 | The camera is ready. |
......@@ -88,8 +85,8 @@ Enumerates the camera positions.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| --------------------------- | ------ | ---------------- |
| Name | Value | Description |
| --------------------------- | ---- | ---------------- |
| CAMERA_POSITION_UNSPECIFIED | 0 | Unspecified position.|
| CAMERA_POSITION_BACK | 1 | Rear camera. |
| CAMERA_POSITION_FRONT | 2 | Front camera. |
......@@ -100,8 +97,8 @@ Enumerates the camera types.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ----------------------- | ------ | ---------------- |
| Name | Value | Description |
| ----------------------- | ---- | ---------------- |
| CAMERA_TYPE_UNSPECIFIED | 0 | Unspecified camera type.|
| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera. |
| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera. |
......@@ -115,12 +112,22 @@ Enumerates the camera connection types.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ---------------------------- | ------ | ------------- |
| Name | Value | Description |
| ---------------------------- | ---- | ------------- |
| CAMERA_CONNECTION_BUILT_IN | 0 | Built-in camera. |
| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB.|
| CAMERA_CONNECTION_REMOTE | 2 | Remote camera. |
## Size
Defines the image size that can be used in previewing, photographing, and video recording.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Readable| Writable| Description |
| ------ | ------ | ---- | ---- | ------------ |
| height | string | Yes | Yes | Image height.|
| width | number | Yes | Yes | Image width.|
## CameraManager
......@@ -142,7 +149,7 @@ Obtains all cameras supported by the device. This API uses an asynchronous callb
**Example**
```
```js
cameraManager.getCameras((err, cameras) => {
if (err) {
console.error('Failed to get the cameras. ${err.message}');
......@@ -169,41 +176,32 @@ Obtains all cameras supported by the device. This API uses a promise to return t
**Example**
```
```js
cameraManager.getCameras().then((cameraArray) => {
console.log('Promise returned with an array of supported cameras: ' + cameraArray.length);
})
```
### Size
Size parameters. This interface used to get supported size for Preview + Photo + Video.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ----------------------------------- |
| height | number | Yes | Desired height of the Preview + Photo + Video. |
| width | number | Yes | Desired width of the Preview + Photo + Video.|
### createCameraInput
createCameraInput(cameraId: string, callback: AsyncCallback<CameraInput\>): void
Creates a **CameraInput** instance with the specified camera ID. This API uses an asynchronous callback to return the instance.
**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Default Value | Mandatory| Description |
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ----------------------------------- |
| cameraId | string | Yes | Camera ID used to create the instance. |
| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance.|
**Example**
```
```js
cameraManager.createCameraInput(cameraId, (err, cameraInput) => {
if (err) {
console.error('Failed to create the CameraInput instance. ${err.message}');
......@@ -219,11 +217,13 @@ createCameraInput(cameraId: string): Promise<CameraInput\>
Creates a **CameraInput** instance with the specified camera ID. This API uses a promise to return the instance.
**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Default Value| Mandatory| Description |
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------ |
| cameraId | string | Yes | Camera ID used to create the instance.|
......@@ -235,7 +235,7 @@ Creates a **CameraInput** instance with the specified camera ID. This API uses a
**Example**
```
```js
cameraManager.createCameraInput(cameraId).then((cameraInput) => {
console.log('Promise returned with the CameraInput instance');
})
......@@ -247,6 +247,8 @@ createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCal
Creates a **CameraInput** instance with the specified camera position and camera type. This API uses an asynchronous callback to return the instance.
**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
......@@ -259,7 +261,7 @@ Creates a **CameraInput** instance with the specified camera position and camera
**Example**
```
```js
cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => {
if (err) {
console.error('Failed to create the CameraInput instance. ${err.message}');
......@@ -275,6 +277,8 @@ createCameraInput(position: CameraPosition, type: CameraType): Promise<CameraInp
Creates a **CameraInput** instance with the specified camera position and camera type. This API uses a promise to return the instance.
**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
......@@ -292,7 +296,7 @@ Creates a **CameraInput** instance with the specified camera position and camera
**Example**
```
```js
cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => {
console.log('Promise returned with the CameraInput instance.');
})
......@@ -302,7 +306,7 @@ cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, came
on(type: 'cameraStatus', callback: AsyncCallback<CameraStatusInfo\>): void
Listens for camera status changes. This API uses a callback to return the camera status changes.
Listens for camera status changes. This API uses an asynchronous callback to return the camera status changes.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -315,7 +319,7 @@ Listens for camera status changes. This API uses a callback to return the camera
**Example**
```
```js
cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
if (err) {
console.error('Failed to get cameraStatus callback. ${err.message}');
......@@ -328,7 +332,7 @@ cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
## Camera
After **[camera.getCameraManager](#cameragetcameramanager)** is called, a camera instance is returned, including camera-related metadata such as **cameraId**, **cameraPosition**, **cameraType**, and **connectionType**.
After **[camera.getCameraManager](#cameragetcameramanager)** is called, a camera instance is returned, with camera-related metadata such as **cameraId**, **cameraPosition**, **cameraType**, and **connectionType**.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -341,7 +345,7 @@ After **[camera.getCameraManager](#cameragetcameramanager)** is called, a camera
**Example**
```
```js
async function getCameraInfo("cameraId") {
var cameraManager = await camera.getCameraManager();
var cameras = await cameraManager.getCameras();
......@@ -351,7 +355,6 @@ async function getCameraInfo("cameraId") {
var cameraType = cameraObj.cameraType;
var connectionType = cameraObj.connectionType;
}
```
## CameraStatusInfo
......@@ -386,7 +389,7 @@ Obtains the camera ID based on which this **CameraInput** instance is created. T
**Example**
```
```js
cameraInput.getCameraId((err, cameraId) => {
if (err) {
console.error('Failed to get the camera ID. ${err.message}');
......@@ -412,7 +415,7 @@ Obtains the camera ID based on which this **CameraInput** instance is created. T
**Example**
```
```js
cameraInput.getCameraId().then((cameraId) => {
console.log('Promise returned with the camera ID:' + cameraId);
})
......@@ -435,7 +438,7 @@ Checks whether the device has flash light. This API uses an asynchronous callbac
**Example**
```
```js
cameraInput.hasFlash((err, status) => {
if (err) {
console.error('Failed to check whether the device has flash light. ${err.message}');
......@@ -461,7 +464,7 @@ Checks whether the device has flash light. This API uses a promise to return the
**Example**
```
```js
cameraInput.hasFlash().then((status) => {
console.log('Promise returned with the flash light support status:' + status);
})
......@@ -484,7 +487,7 @@ Checks whether a specified flash mode is supported. This API uses an asynchronou
**Example**
```
```js
cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => {
if (err) {
console.error('Failed to check whether the flash mode is supported. ${err.message}');
......@@ -516,7 +519,7 @@ Checks whether a specified flash mode is supported. This API uses a promise to r
**Example**
```
```js
cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => {
console.log('Promise returned with flash mode support status.' + status);
})
......@@ -544,7 +547,7 @@ Before setting the parameters, do the following checks:
**Example**
```
```js
cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => {
if (err) {
console.error('Failed to set the flash mode ${err.message}');
......@@ -581,7 +584,7 @@ Before setting the parameters, do the following checks:
**Example**
```
```js
cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => {
console.log('Promise returned with the successful execution of setFlashMode.');
})
......@@ -603,7 +606,7 @@ Obtains the current flash mode. This API uses an asynchronous callback to return
**Example**
```
```js
cameraInput.getFlashMode((err, flashMode) => {
if (err) {
console.error('Failed to get the flash mode ${err.message}');
......@@ -629,7 +632,7 @@ Obtains the current flash mode. This API uses a promise to return the result.
**Example**
```
```js
cameraInput.getFlashMode().then((flashMode) => {
console.log('Promise returned with current flash mode : ' + flashMode);
})
......@@ -652,7 +655,7 @@ Checks whether a specified focus mode is supported. This API uses an asynchronou
**Example**
```
```js
cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => {
if (err) {
console.error('Failed to check whether the focus mode is supported. ${err.message}');
......@@ -680,11 +683,11 @@ Checks whether a specified focus mode is supported. This API uses a promise to r
| Type | Description |
| ----------------- | ----------------------------------------------------------- |
| Promise<boolean\> | Promise used to return the flash mode support status. The value **true** means that the specified focus mode is supported.|
| Promise<boolean\> | Promise used to return the focus mode support status. The value **true** means that the specified focus mode is supported.|
**Example**
```
```js
cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => {
console.log('Promise returned with focus mode support status.' + status);
})
......@@ -709,7 +712,7 @@ Before setting the focus mode, use **[isFocusModeSupported](#isfocusmodesupporte
**Example**
```
```js
cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => {
if (err) {
console.error('Failed to set the focus mode ${err.message}');
......@@ -743,7 +746,7 @@ Before setting the focus mode, use **[isFocusModeSupported](#isfocusmodesupporte
**Example**
```
```js
cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => {
console.log('Promise returned with the successful execution of setFocusMode.');
})
......@@ -765,7 +768,7 @@ Obtains the current focus mode. This API uses an asynchronous callback to return
**Example**
```
```js
cameraInput.getFocusMode((err, afMode) => {
if (err) {
console.error('Failed to get the focus mode ${err.message}');
......@@ -791,7 +794,7 @@ Obtains the current focus mode. This API uses a promise to return the result.
**Example**
```
```js
cameraInput.getFocusMode().then((afMode) => {
console.log('Promise returned with current focus mode : ' + afMode);
})
......@@ -813,7 +816,7 @@ Obtains the zoom ratio range. This API uses an asynchronous callback to return t
**Example**
```
```js
cameraInput.getZoomRatioRange((err, zoomRatioRange) => {
if (err) {
console.error('Failed to get the zoom ratio range. ${err.message}');
......@@ -839,7 +842,7 @@ Obtains the zoom ratio range. This API uses a promise to return the result.
**Example**
```
```js
cameraInput.getZoomRatioRange().then((zoomRatioRange) => {
console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length);
})
......@@ -862,7 +865,7 @@ Sets a zoom ratio. This API uses an asynchronous callback to return the result.
**Example**
```
```js
cameraInput.setZoomRatio(1, (err) => {
if (err) {
console.error('Failed to set the zoom ratio value ${err.message}');
......@@ -894,7 +897,7 @@ Sets a zoom ratio. This API uses a promise to return the result.
**Example**
```
```js
cameraInput.setZoomRatio(1).then(() => {
console.log('Promise returned with the successful execution of setZoomRatio.');
})
......@@ -916,7 +919,7 @@ Obtains the current zoom ratio. This API uses an asynchronous callback to return
**Example**
```
```js
cameraInput.getZoomRatio((err, zoomRatio) => {
if (err) {
console.error('Failed to get the zoom ratio ${err.message}');
......@@ -942,7 +945,7 @@ Obtains the current zoom ratio. This API uses a promise to return the result.
**Example**
```
```js
cameraInput.getZoomRatio().then((zoomRatio) => {
console.log('Promise returned with current zoom ratio : ' + zoomRatio);
})
......@@ -964,7 +967,7 @@ Releases this **CameraInput** instance. This API uses an asynchronous callback t
**Example**
```
```js
cameraInput.release((err) => {
if (err) {
console.error('Failed to release the CameraInput instance ${err.message}');
......@@ -990,7 +993,7 @@ Releases this **CameraInput** instance. This API uses a promise to return the re
**Example**
```
```js
cameraInput.release().then(() => {
console.log('Promise returned to indicate that the CameraInput instance is released successfully.');
})
......@@ -1000,7 +1003,7 @@ cameraInput.release().then(() => {
on(type: 'focusStateChange', callback: AsyncCallback<FocusState\>): void
Listens for focus state changes. This API uses a callback to return the focus state changes.
Listens for focus state changes. This API uses an asynchronous callback to return the focus state changes.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -1013,7 +1016,7 @@ Listens for focus state changes. This API uses a callback to return the focus st
**Example**
```
```js
cameraInput.on('focusStateChange', (focusState) => {
console.log('Focus state : ' + focusState);
})
......@@ -1030,13 +1033,13 @@ Listens for **CameraInput** errors. This API uses a callback to return the error
**Parameters**
| Name | Type | Mandatory| Description |
| :------- | :------------------------------- | :--- | :---------------------------------------------- |
| :------- | :------------------------------- | :--- | :----------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the camera input error event.|
| callback | ErrorCallback<CameraInputError\> | Yes | Callback used to return the capture input errors. |
| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | Yes | Callback used to return the error information. |
**Example**
```
```js
cameraInput.on('error', (cameraInputError) => {
console.log('Camera input error code: ' + cameraInputError.code);
})
......@@ -1044,25 +1047,24 @@ cameraInput.on('error', (cameraInputError) => {
## CameraInputErrorCode
Enumerates the CameraInput error code.
Enumerates the **CameraInput** error codes.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| Name | Value | Description |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1 | Unknown error.|
## CameraInputError
Camera input error object which extends **Error** interface.
Defines a **CameraInput** error object.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name| Type | Description |
| ---- | ------------------------------------------- | -------------------------- |
| code | [CameraInputErrorCode](#camerainputerrorcode) | **CameraInput** error code.|
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| code | [CameraInputErrorCode](#camerainputerrorcode) | Used to get error code in CameraInput on('error') callback|
## FlashMode
......@@ -1070,8 +1072,8 @@ Enumerates the flash modes.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| Name | Value | Description |
| ---------------------- | ---- | ------------ |
| FLASH_MODE_CLOSE | 0 | The flash is off.|
| FLASH_MODE_OPEN | 1 | The flash is on.|
| FLASH_MODE_AUTO | 2 | The flash mode is auto, indicating that the flash fires automatically depending on the shooting conditions.|
......@@ -1083,8 +1085,8 @@ Enumerates the focus modes.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| -------------------------- | ------ | ------------------ |
| Name | Value | Description |
| -------------------------- | ---- | ------------------ |
| FOCUS_MODE_MANUAL | 0 | Manual focus. |
| FOCUS_MODE_CONTINUOUS_AUTO | 1 | Continuous auto focus.|
| FOCUS_MODE_AUTO | 2 | Auto focus. |
......@@ -1096,8 +1098,8 @@ Enumerates the focus states.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| --------------------- | ------ | ------------ |
| Name | Value | Description |
| --------------------- | ---- | ------------ |
| FOCUS_STATE_SCAN | 0 | Scanning. |
| FOCUS_STATE_FOCUSED | 1 | Focused.|
| FOCUS_STATE_UNFOCUSED | 2 | Unfocused.|
......@@ -1119,7 +1121,7 @@ Creates a **CaptureSession** instance. This API uses an asynchronous callback to
**Example**
```
```js
camera.createCaptureSession((context), (err, captureSession) => {
if (err) {
console.error('Failed to create the CaptureSession instance. ${err.message}');
......@@ -1151,7 +1153,7 @@ Creates a **CaptureSession** instance. This API uses a promise to return the ins
**Example**
```
```js
camera.createCaptureSession(context).then((captureSession) => {
console.log('Promise returned with the CaptureSession instance');
})
......@@ -1177,7 +1179,7 @@ Starts configuration for this **CaptureSession** instance. This API uses an asyn
**Example**
```
```js
captureSession.beginConfig((err) => {
if (err) {
console.error('Failed to start the configuration. ${err.message}');
......@@ -1204,7 +1206,7 @@ Starts configuration for this **CaptureSession** instance. This API uses a promi
**Example**
```
```js
captureSession.beginConfig().then(() => {
console.log('Promise returned to indicate the begin config success.');
})
......@@ -1226,7 +1228,7 @@ Commits the configuration for this **CaptureSession** instance. This API uses an
**Example**
```
```js
captureSession.commitConfig((err) => {
if (err) {
console.error('Failed to commit the configuration. ${err.message}');
......@@ -1252,7 +1254,7 @@ Commits the configuration for this **CaptureSession** instance. This API uses a
**Example**
```
```js
captureSession.commitConfig().then(() => {
console.log('Promise returned to indicate the commit config success.');
})
......@@ -1275,7 +1277,7 @@ Adds a **CameraInput** instance to this **CaptureSession** instance. This API us
**Example**
```
```js
captureSession.addInput(cameraInput, (err) => {
if (err) {
console.error('Failed to add the CameraInput instance. ${err.message}');
......@@ -1307,7 +1309,7 @@ Adds a **CameraInput** instance to this **CaptureSession** instance. This API us
**Example**
```
```js
captureSession.addInput(cameraInput).then(() => {
console.log('Promise used to indicate that the CameraInput instance is added.');
})
......@@ -1330,7 +1332,7 @@ Adds a **PreviewOutput** instance to this **CaptureSession** instance. This API
**Example**
```
```js
captureSession.addOutput(previewOutput, (err) => {
if (err) {
console.error('Failed to add the PreviewOutput instance ${err.message}');
......@@ -1362,7 +1364,7 @@ Adds a **PreviewOutput** instance to this **CaptureSession** instance. This API
**Example**
```
```js
captureSession.addOutput(previewOutput).then(() => {
console.log('Promise used to indicate that the PreviewOutput instance is added.');
})
......@@ -1385,7 +1387,7 @@ Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API us
**Example**
```
```js
captureSession.addOutput(photoOutput, (err) => {
if (err) {
console.error('Failed to add the PhotoOutput instance ${err.message}');
......@@ -1417,7 +1419,7 @@ Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API us
**Example**
```
```js
captureSession.addOutput(photoOutput).then(() => {
console.log('Promise used to indicate that the PhotoOutput instance is added.');
})
......@@ -1440,7 +1442,7 @@ Adds a **VideoOutput** instance to this **CaptureSession** instance. This API us
**Example**
```
```js
captureSession.addOutput(videoOutput, (err) => {
if (err) {
console.error('Failed to add the VideoOutput instance ${err.message}');
......@@ -1472,7 +1474,7 @@ Adds a **VideoOutput** instance to this **CaptureSession** instance. This API us
**Example**
```
```js
captureSession.addOutput(videoOutput).then(() => {
console.log('Promise used to indicate that the VideoOutput instance is added.');
})
......@@ -1495,7 +1497,7 @@ Removes a **CameraInput** instance from this **CaptureSession** instance. This A
**Example**
```
```js
captureSession.removeInput(cameraInput, (err) => {
if (err) {
console.error('Failed to remove the CameraInput instance. ${err.message}');
......@@ -1527,7 +1529,7 @@ Removes a **CameraInput** instance from this **CaptureSession** instance. This A
**Example**
```
```js
captureSession.removeInput(cameraInput).then(() => {
console.log('Promise returned to indicate that the cameraInput instance is removed.');
})
......@@ -1550,7 +1552,7 @@ Removes a **PreviewOutput** instance from this **CaptureSession** instance. This
**Example**
```
```js
captureSession.removeOutput(previewOutput, (err) => {
if (err) {
console.error('Failed to remove the PreviewOutput instance. ${err.message}');
......@@ -1584,7 +1586,7 @@ Removes a **PreviewOutput** instance from this **CaptureSession** instance. This
**Example**
```
```js
captureSession.removeOutput(previewOutput).then(() => {
console.log('Promise returned to indicate that the PreviewOutput instance is removed.');
})
......@@ -1607,7 +1609,7 @@ Removes a **PhotoOutput** instance from this **CaptureSession** instance. This A
**Example**
```
```js
captureSession.removeOutput(photoOutput, (err) => {
if (err) {
console.error('Failed to remove the PhotoOutput instance. ${err.message}');
......@@ -1641,7 +1643,7 @@ Removes a **PhotoOutput** instance from this **CaptureSession** instance. This A
**Example**
```
```js
captureSession.removeOutput(photoOutput).then(() => {
console.log('Promise returned to indicate that the PhotoOutput instance is removed.');
})
......@@ -1664,7 +1666,7 @@ Removes a **VideoOutput** instance from this **CaptureSession** instance. This A
**Example**
```
```js
captureSession.removeOutput(videoOutput, (err) => {
if (err) {
console.error('Failed to remove the VideoOutput instance. ${err.message}');
......@@ -1698,7 +1700,7 @@ Removes a **VideoOutput** instance from this **CaptureSession** instance. This A
**Example**
```
```js
captureSession.removeOutput(videoOutput).then(() => {
console.log('Promise returned to indicate that the VideoOutput instance is removed.');
})
......@@ -1720,7 +1722,7 @@ Starts this **CaptureSession** instance. This API uses an asynchronous callback
**Example**
```
```js
captureSession.start((err) => {
if (err) {
console.error('Failed to start the session ${err.message}');
......@@ -1746,7 +1748,7 @@ Starts this **CaptureSession** instance. This API uses a promise to return the r
**Example**
```
```js
captureSession.start().then(() => {
console.log('Promise returned to indicate the session start success.');
})
......@@ -1769,7 +1771,7 @@ Stops this **CaptureSession** instance. This API uses an asynchronous callback t
**Example**
```
```js
captureSession.stop((err) => {
if (err) {
console.error('Failed to stop the session ${err.message}');
......@@ -1795,7 +1797,7 @@ Stops this **CaptureSession** instance. This API uses a promise to return the re
**Example**
```
```js
captureSession.stop().then(() => {
console.log('Promise returned to indicate the session stop success.');
})
......@@ -1817,7 +1819,7 @@ Releases this **CaptureSession** instance. This API uses an asynchronous callbac
**Example**
```
```js
captureSession.release((err) => {
if (err) {
console.error('Failed to release the CaptureSession instance ${err.message}');
......@@ -1843,7 +1845,7 @@ Releases this **CaptureSession** instance. This API uses a promise to return the
**Example**
```
```js
captureSession.release().then(() => {
console.log('Promise returned to indicate that the CaptureSession instance is released successfully.');
})
......@@ -1860,13 +1862,13 @@ Listens for **CaptureSession** errors. This API uses a callback to return the er
**Parameters**
| Name | Type | Mandatory| Description |
| :------- | :---------------------------------- | :--- | :-------------------------------------------- |
| :------- | :---------------------------------------------------------- | :--- | :-------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the capture session error event.|
| callback | ErrorCallback<CaptureSessionError\> | Yes | Callback used to return the capture session errors. |
| callback | ErrorCallback<[CaptureSessionError](#capturesessionerror)\> | Yes | Callback used to return the error information. |
**Example**
```
```js
captureSession.on('error', (captureSessionError) => {
console.log('Capture session error code: ' + captureSessionError.code);
})
......@@ -1874,25 +1876,23 @@ captureSession.on('error', (captureSessionError) => {
## CaptureSessionErrorCode
Enumerates the CaptureSession error code.
Enumerates the **CaptureSession** error codes.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| Name | Value | Description |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1 | Unknown error.|
## CaptureSessionError
Capture session error object which extends **Error** interface.
Defines a **CaptureSession** error object.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| code | [CaptureSessionErrorCode](#capturesessionerrorcode) | Used to get error code in CaptureSession on('error') callback.|
| Name| Type | Description |
| ---- | ------------------------------------------- | -------------------------- |
| code | [CaptureSessionError](#capturesessionerror) | **CaptureSession** error code.|
## camera.createPreviewOutput
......@@ -1911,7 +1911,7 @@ Creates a **PreviewOutput** instance. This API uses an asynchronous callback to
**Example**
```
```js
camera.createPreviewOutput(("surfaceId"), (err, previewOutput) => {
if (err) {
console.error('Failed to create the PreviewOutput instance. ${err.message}');
......@@ -1943,7 +1943,7 @@ Creates a **PreviewOutput** instance. This API uses a promise to return the inst
**Example**
```
```js
camera.createPreviewOutput("surfaceId").then((previewOutput) => {
console.log('Promise returned with the PreviewOutput instance');
})
......@@ -1969,7 +1969,7 @@ Releases this **PreviewOutput** instance. This API uses an asynchronous callback
**Example**
```
```js
previewOutput.release((err) => {
if (err) {
console.error('Failed to release the PreviewOutput instance ${err.message}');
......@@ -1996,7 +1996,7 @@ Releases this **PreviewOutput** instance. This API uses a promise to return the
**Example**
```
```js
previewOutput.release().then(() => {
console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.');
})
......@@ -2019,7 +2019,7 @@ Listens for preview frame start events. This API uses an asynchronous callback t
**Example**
```
```js
previewOutput.on('frameStart', () => {
console.log('Preview frame started');
})
......@@ -2042,7 +2042,7 @@ Listens for preview frame end events. This API uses an asynchronous callback to
**Example**
```
```js
previewOutput.on('frameEnd', () => {
console.log('Preview frame ended');
})
......@@ -2059,13 +2059,13 @@ Listens for **PreviewOutput** errors. This API uses a callback to return the err
**Parameters**
| Name | Type | Mandatory| Description |
| :------- | :--------------------------------- | :--- | :-------------------------------------------- |
| :------- | :----------------------------------------------------------- | :--- | :-------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the preview output error event.|
| callback | ErrorCallback<PreviewOutputError\> | Yes | Callback used to return the preview output errors. |
| callback | ErrorCallback<[PreviewOutputErrorCode](#previewoutputerrorcode)\> | Yes | Callback used to return the error information. |
**Example**
```
```js
previewOutput.on('error', (previewOutputError) => {
console.log('Preview output error code: ' + previewOutputError.code);
})
......@@ -2073,25 +2073,23 @@ previewOutput.on('error', (previewOutputError) => {
## PreviewOutputErrorCode
Enumerates the PreviewOutput error code.
Enumerates the **PreviewOutput** error codes.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| Name | Value | Description |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1 | Unknown error.|
## PreviewOutputError
Preview output error object which extends **Error** interface.
Defines a **PreviewOutput** error object.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| code | [PreviewOutputErrorCode](#previewoutputerrorcode) | Used to get error code in PreviewOutput on('error') callback.|
| Name| Type | Description |
| ---- | ------------------------------------------------- | ---------------------- |
| code | [PreviewOutputErrorCode](#previewoutputerrorcode) | **PreviewOutput** error code.|
## camera.createPhotoOutput
......@@ -2110,7 +2108,7 @@ Creates a **PhotoOutput** instance. This API uses an asynchronous callback to re
**Example**
```
```js
camera.createPhotoOutput(("surfaceId"), (err, photoOutput) => {
if (err) {
console.error('Failed to create the PhotoOutput instance. ${err.message}');
......@@ -2142,7 +2140,7 @@ Creates a **PhotoOutput** instance. This API uses a promise to return the instan
**Example**
```
```js
camera.createPhotoOutput("surfaceId").then((photoOutput) => {
console.log('Promise returned with PhotoOutput instance');
})
......@@ -2153,23 +2151,21 @@ Enumerates the image rotation angles.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ------------ | ------ | --------------- |
| Name | Value | Description |
| ------------ | ---- | --------------- |
| ROTATION_0 | 0 | The image rotates 0 degrees. |
| ROTATION_90 | 90 | The image rotates 90 degrees. |
| ROTATION_180 | 180 | The image rotates 180 degrees.|
| ROTATION_270 | 270 | The image rotates 270 degrees.|
## QualityLevel
Enumerates the image quality levels.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| -------------------- | ------ | -------------- |
| Name | Value | Description |
| -------------------- | ---- | -------------- |
| QUALITY_LEVEL_HIGH | 0 | High image quality. |
| QUALITY_LEVEL_MEDIUM | 1 | Medium image quality.|
| QUALITY_LEVEL_LOW | 2 | Low image quality. |
......@@ -2177,14 +2173,14 @@ Enumerates the image quality levels.
## PhotoCaptureSetting
Defines the settings for image capture.
Defines the settings for photo capture.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | -------------- |
| quality | [QualityLevel](#qualitylevel) | No | Photo image quality. |
| rotation | [ImageRotation](#imagerotation) | No | Photo rotation.|
| quality | [QualityLevel](#qualitylevel) | No | Photo quality. |
| rotation | [ImageRotation](#imagerotation) | No | Rotation angle of the photo.|
## PhotoOutput
......@@ -2207,7 +2203,7 @@ Captures a photo. This API uses an asynchronous callback to return the result.
**Example**
```
```js
photoOutput.capture((err) => {
if (err) {
console.error('Failed to capture the photo ${err.message}');
......@@ -2234,7 +2230,7 @@ Captures a photo with the specified capture settings. This API uses an asynchron
**Example**
```
```js
photoOutput.capture(settings, (err) => {
if (err) {
console.error('Failed to capture the photo ${err.message}');
......@@ -2267,7 +2263,7 @@ Captures a photo with the specified capture settings. This API uses a promise to
**Example**
```
```js
photoOutput.capture().then(() => {
console.log('Promise returned to indicate that photo capture request success.');
})
......@@ -2289,7 +2285,7 @@ Releases this **PhotoOutput** instance. This API uses an asynchronous callback t
**Example**
```
```js
photoOutput.release((err) => {
if (err) {
console.error('Failed to release the PhotoOutput instance ${err.message}');
......@@ -2316,7 +2312,7 @@ Releases this **PhotoOutput** instance. This API uses a promise to return the re
**Example**
```
```js
photoOutput.release().then(() => {
console.log('Promise returned to indicate that the PhotoOutput instance is released successfully.');
})
......@@ -2326,7 +2322,7 @@ photoOutput.release().then(() => {
on(type: 'captureStart', callback: AsyncCallback<number\>): void
Listens for photo capture start events. This API uses a callback to return the event information.
Listens for photo capture start events. This API uses an asynchronous callback to return the capture ID.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -2339,7 +2335,7 @@ Listens for photo capture start events. This API uses a callback to return the e
**Example**
```
```js
photoOutput.on('captureStart', (err, captureId) => {
console.log('photo capture stated, captureId : ' + captureId);
})
......@@ -2349,20 +2345,20 @@ photoOutput.on('captureStart', (err, captureId) => {
on(type: 'frameShutter', callback: AsyncCallback<FrameShutterInfo\>): void
Listens for frame shutter events. This API uses a callback to return the event information.
Listens for frame shutter events. This API uses an asynchronous callback to return the event information.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Type | Mandatory| Description |
| :------- | :------------------------------- | :--- | :--------------------------------------------- |
| :------- | :---------------------------------------------------- | :--- | :--------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **frameShutter**, indicating the frame shutter event.|
| callback | AsyncCallback<FrameShutterInfo\> | Yes | Callback used to return the frame shutter information. |
| callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | Yes | Callback used to return the information. |
**Example**
```
```js
photoOutput.on('frameShutter', (frameShutterInfo) => {
console.log('photo capture end, captureId : ' + frameShutterInfo.captureId);
console.log('Timestamp for frame : ' + frameShutterInfo.timestamp);
......@@ -2373,20 +2369,20 @@ photoOutput.on('frameShutter', (frameShutterInfo) => {
on(type: 'captureEnd', callback: AsyncCallback<CaptureEndInfo\>): void
Listens for photo capture end events. This API uses a callback to return the event information.
Listens for photo capture end events. This API uses an asynchronous callback to return the event information.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Type | Mandatory| Description |
| :------- | :----------------------------- | :--- | :--------------------------------------------- |
| :------- | :------------------------------------------------ | :--- | :--------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **captureEnd**, indicating the photo capture end event.|
| callback | AsyncCallback<CaptureEndInfo\> | Yes | Callback used to return the photo capture end information. |
| callback | AsyncCallback<[CaptureEndInfo](#captureendinfo)\> | Yes | Callback used to return the information. |
**Example**
```
```js
photoOutput.on('captureEnd', (captureEndInfo) => {
console.log('photo capture end, captureId : ' + captureEndInfo.captureId);
console.log('frameCount : ' + captureEndInfo.frameCount);
......@@ -2404,61 +2400,59 @@ Listens for **PhotoOutput** errors. This API uses a callback to return the error
**Parameters**
| Name | Type | Mandatory| Description |
| :------- | :------------------------------- | :--- | :---------------------------------------- |
| :------- | :---------------------------------------------------- | :--- | :---------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the photo output error event.|
| callback | ErrorCallback<PhotoOutputError\> | Yes | Callback used to return the photo output errors. |
| callback | ErrorCallback<[PhotoOutputError](#photooutputerror)\> | Yes | Callback used to return the error information. |
**Example**
```
```js
photoOutput.on('error', (photoOutputError) => {
console.log('Photo output error code: ' + photoOutputError.code);
})
```
### FrameShutterInfo
## FrameShutterInfo
Frame shutter callback info which provides **captureId** & **timestamp** parameteres & indicates the frame shutter event.
Defines the frame shutter information.
**Parameteres**
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Mandatory| Description |
| :------- | :------------------------------- | :--- | :---------------------------------------- |
| captureId | number | Yes | Capture id.|
| timestamp | number | Yes | Timestamp for frame.
| --------- | ------ | ---- | ----------------------------- |
| captureId | number | Yes | ID of this capture action.|
| timestamp | number | Yes | Timestamp when the frame shutter event is triggered. |
### CaptureEndInfo
## CaptureEndInfo
Capture end info which provides **captureId** & **frameCount** parameteres & indicates the photo capture end event.
Defines the capture end information.
**Parameteres**
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Mandatory| Description |
| :------- | :------------------------------- | :--- | :---------------------------------------- |
| captureId | number | Yes | Capture id.|
| frameCount | number | Yes | Frame count.
| ---------- | ------ | ---- | ----------------------------- |
| captureId | number | Yes | ID of this capture action.|
| frameCount | number | Yes | Number of frames captured. |
## PhotoOutputErrorCode
Enumerates the PhotoOutput error code.
Enumerates the **PhotoOutput** error codes.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| Name | Value | Description |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1 | Unknown error.|
## PhotoOutputError
Photo output error object which extends **Error** interface.
Defines a **PhotoOutput** error object.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| code | [PhotoOutputErrorCode](#photooutputerrorcode) | Used to get error code in PhotoOutput on('error') callback.|
| Name| Type | Description |
| ---- | ------------------------------------- | ----------------------- |
| code | [PhotoOutputError](#photooutputerror) | **PhotoOutput** error code.|
## camera.createVideoOutput
......@@ -2477,7 +2471,7 @@ Creates a **VideoOutput** instance. This API uses an asynchronous callback to re
**Example**
```
```js
camera.createVideoOutput(("surfaceId"), (err, videoOutput) => {
if (err) {
console.error('Failed to create the VideoOutput instance. ${err.message}');
......@@ -2509,7 +2503,7 @@ Creates a **VideoOutput** instance. This API uses a promise to return the instan
**Example**
```
```js
camera.createVideoOutput("surfaceId"
).then((videoOutput) => {
console.log('Promise returned with the VideoOutput instance');
......@@ -2536,7 +2530,7 @@ Starts the video output. This API uses an asynchronous callback to return the re
**Example**
```
```js
videoOutput.start((err) => {
if (err) {
console.error('Failed to start the video output ${err.message}');
......@@ -2563,7 +2557,7 @@ Starts the video output. This API uses a promise to return the result.
**Example**
```
```js
videoOutput.start().then(() => {
console.log('Promise returned to indicate that start method execution success.');
})
......@@ -2585,7 +2579,7 @@ Stops the video output. This API uses an asynchronous callback to return the res
**Example**
```
```js
videoOutput.stop((err) => {
if (err) {
console.error('Failed to stop the video output ${err.message}');
......@@ -2611,7 +2605,7 @@ Stops the video output. This API uses a promise to return the result.
**Example**
```
```js
videoOutput.start().then(() => {
console.log('Promise returned to indicate that stop method execution success.');
})
......@@ -2633,7 +2627,7 @@ Releases this **VideoOutput** instance. This API uses an asynchronous callback t
**Example**
```
```js
videoOutput.release((err) => {
if (err) {
console.error('Failed to release the VideoOutput instance ${err.message}');
......@@ -2660,7 +2654,7 @@ Releases this **VideoOutput** instance. This API uses a promise to return the re
**Example**
```
```js
videoOutput.release().then(() => {
console.log('Promise returned to indicate that the VideoOutput instance is released successfully.');
})
......@@ -2670,7 +2664,7 @@ videoOutput.release().then(() => {
on(type: 'frameStart', callback: AsyncCallback<void\>): void
Listens for video frame start events. This API uses a callback to return the event information.
Listens for video frame start events. This API uses an asynchronous callback to return the event information.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -2683,7 +2677,7 @@ Listens for video frame start events. This API uses a callback to return the eve
**Example**
```
```js
videoOutput.on('frameStart', () => {
console.log('Video frame started');
})
......@@ -2693,7 +2687,7 @@ videoOutput.on('frameStart', () => {
on(type: 'frameEnd', callback: AsyncCallback<void\>): void
Listens for video frame end events. This API uses a callback to return the event information.
Listens for video frame end events. This API uses an asynchronous callback to return the event information.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -2706,7 +2700,7 @@ Listens for video frame end events. This API uses a callback to return the event
**Example**
```
```js
videoOutput.on('frameEnd', () => {
console.log('Video frame ended');
})
......@@ -2723,13 +2717,13 @@ Listens for **VideoOutput** errors. This API uses a callback to return the error
**Parameters**
| Name | Type | Mandatory| Description |
| :------- | :-------------------------- | :--- | :-------------------------------------------- |
| :------- | :----------------------------------------------- | :--- | :-------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the video output error event.|
| callback | Callback<VideoOutputError\> | Yes | Callback used to return the video output errors. |
| callback | Callback<[VideoOutputError](#videooutputerror)\> | Yes | Callback used to return the error information. |
**Example**
```
```js
videoOutput.on('error', (VideoOutputError) => {
console.log('Video output error code: ' + VideoOutputError.code);
})
......@@ -2737,22 +2731,20 @@ videoOutput.on('error', (VideoOutputError) => {
## VideoOutputErrorCode
Enumerates the VideoOutput error code.
Enumerates the **VideoOutput** error codes.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| Name | Value | Description |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1 | Unknown error.|
## VideoOutputError
Photo output error object which extends **Error** interface.
Defines a **VideoOutput** error object.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| code | [VideoOutputErrorCode](#videooutputerrorcode) | Used to get error code in VideoOutput on('error') callback.|
\ No newline at end of file
| Name| Type | Description |
| ---- | ------------------------------------- | ----------------------- |
| code | [PhotoOutputError](#photooutputerror) | **VideoOutput** error code.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册