提交 531b12a8 编写于 作者: G Gloria

Update docs against 11324+11569+11993+11346+11485+11812

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 578c5ce2
...@@ -84,7 +84,7 @@ Defines the camera profile. ...@@ -84,7 +84,7 @@ Defines the camera profile.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Read Only| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------- |---- | ------------- | | -------- | ----------------------------- |---- | ------------- |
| format | [CameraFormat](#cameraformat) | Yes | Output format. | | format | [CameraFormat](#cameraformat) | Yes | Output format. |
| size | [Size](#size) | Yes | Resolution. | | size | [Size](#size) | Yes | Resolution. |
...@@ -95,7 +95,7 @@ Defines the frame rate range. ...@@ -95,7 +95,7 @@ Defines the frame rate range.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Read Only| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------- |---- | ------------- | | -------- | ----------------------------- |---- | ------------- |
| min | number | Yes | Minimum frame rate. | | min | number | Yes | Minimum frame rate. |
| max | number | Yes | Maximum frame rate. | | max | number | Yes | Maximum frame rate. |
...@@ -106,7 +106,7 @@ Defines the video profile. ...@@ -106,7 +106,7 @@ Defines the video profile.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Read Only| Description | | Name | Type | Mandatory| Description |
| ------------------------- | ----------------------------------------- | --- |----------- | | ------------------------- | ----------------------------------------- | --- |----------- |
| frameRateRange | [FrameRateRange](#frameraterange) | Yes | Frame rate range. | | frameRateRange | [FrameRateRange](#frameraterange) | Yes | Frame rate range. |
...@@ -116,7 +116,7 @@ Defines the camera output capability. ...@@ -116,7 +116,7 @@ Defines the camera output capability.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Read Only| Description | | Name | Type | Mandatory| Description |
| ----------------------------- | -------------------------------------------------- | --- |------------------- | | ----------------------------- | -------------------------------------------------- | --- |------------------- |
| previewProfiles | Array<[Profile](#profile)\> | Yes | Supported preview profiles. | | previewProfiles | Array<[Profile](#profile)\> | Yes | Supported preview profiles. |
| photoProfiles | Array<[Profile](#profile)\> | Yes | Supported shooting profiles. | | photoProfiles | Array<[Profile](#profile)\> | Yes | Supported shooting profiles. |
...@@ -171,8 +171,8 @@ Obtains supported cameras. This API uses a promise to return the result. ...@@ -171,8 +171,8 @@ Obtains supported cameras. This API uses a promise to return the result.
**Example** **Example**
```js ```js
cameraManager.getSupportedCameras().then((cameraArray) => { cameraManager.getSupportedCameras().then((cameras) => {
console.log(`Promise returned with an array of supported cameras: ${cameraArray.length}`); console.log(`Promise returned with an array of supported cameras: ${cameras.length}`);
}) })
``` ```
...@@ -188,18 +188,21 @@ Obtains the output capability supported by a camera. This API uses an asynchrono ...@@ -188,18 +188,21 @@ Obtains the output capability supported by a camera. This API uses an asynchrono
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------ |--------------------------------------------------------------- | -- | -------------------------- | | ------------ |--------------------------------------------------------------- | -- | -------------------------- |
| CameraDevice | [CameraDevice](#cameradevice) | Yes| Camera device. | | cameraDevice | [CameraDevice](#cameradevice) | Yes| Target camera, which is obtained through **getSupportedCameras**. |
| callback | AsyncCallback<[CameraOutputCapability](#cameraoutputcapability)\> | Yes| Callback used to return the output capability.| | callback | AsyncCallback<[CameraOutputCapability](#cameraoutputcapability)\> | Yes| Callback used to return the output capability.|
**Example** **Example**
```js ```js
cameraManager.getSupportedOutputCapability(cameradevice, (err, cameras) => { cameraManager.getSupportedCameras().then((cameras) => {
if (err) { let cameraDevice = cameras[0];
console.error(`Failed to get the cameras. ${err.message}`); cameraManager.getSupportedOutputCapability(cameraDevice, (err, CameraOutputCapability) => {
return; if (err) {
} console.error(`Failed to get the outputCapability. ${err.message}`);
console.log('Callback returned with an array of supported outputCapability'); return;
}
console.log('Callback returned with an array of supported outputCapability');
})
}) })
``` ```
...@@ -215,7 +218,7 @@ Obtains the output capability supported by a camera. This API uses a promise to ...@@ -215,7 +218,7 @@ Obtains the output capability supported by a camera. This API uses a promise to
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | --------------------------------- | ---- | ---------- | | -------- | --------------------------------- | ---- | ---------- |
| camera | [CameraDevice](#cameradevice) | Yes | Camera device. | | cameradevice | [CameraDevice](#cameradevice) | Yes | Target camera, which is obtained through **getSupportedCameras**. |
**Return value** **Return value**
...@@ -226,8 +229,11 @@ Obtains the output capability supported by a camera. This API uses a promise to ...@@ -226,8 +229,11 @@ Obtains the output capability supported by a camera. This API uses a promise to
**Example** **Example**
```js ```js
cameraManager.getSupportedOutputCapability(cameradevice).then((cameraoutputcapability) => { cameraManager.getSupportedCameras().then((cameras) => {
console.log('Promise returned with an array of supported outputCapability'); let cameraDevice = cameras[0];
cameraManager.getSupportedOutputCapability(cameraDevice).then((cameraoutputcapability) => {
console.log('Promise returned with an array of supported outputCapability');
})
}) })
``` ```
...@@ -250,7 +256,7 @@ Before calling the API, ensure that the camera can be muted. You can use [isCame ...@@ -250,7 +256,7 @@ Before calling the API, ensure that the camera can be muted. You can use [isCame
**Example** **Example**
```js ```js
let ismuted = await cameraManager.isCameraMuted(); let ismuted = cameraManager.isCameraMuted();
``` ```
### isCameraMuteSupported ### isCameraMuteSupported
...@@ -259,6 +265,8 @@ isCameraMuteSupported(): boolean ...@@ -259,6 +265,8 @@ isCameraMuteSupported(): boolean
Checks whether the camera can be muted. Checks whether the camera can be muted.
This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Return value** **Return value**
...@@ -270,7 +278,7 @@ Checks whether the camera can be muted. ...@@ -270,7 +278,7 @@ Checks whether the camera can be muted.
**Example** **Example**
```js ```js
let ismutesuppotred = await cameraManager.isCameraMuteSupported(); let ismutesuppotred = cameraManager.isCameraMuteSupported();
``` ```
### muteCamera ### muteCamera
...@@ -279,6 +287,8 @@ muteCamera(mute: boolean): void ...@@ -279,6 +287,8 @@ muteCamera(mute: boolean): void
Mutes or unmutes the camera. Mutes or unmutes the camera.
This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters** **Parameters**
...@@ -290,6 +300,7 @@ Mutes or unmutes the camera. ...@@ -290,6 +300,7 @@ Mutes or unmutes the camera.
**Example** **Example**
```js ```js
let mute = true;
cameraManager.muteCamera(mute); cameraManager.muteCamera(mute);
``` ```
...@@ -299,8 +310,6 @@ createCameraInput(camera: CameraDevice, callback: AsyncCallback<CameraInput\>): ...@@ -299,8 +310,6 @@ createCameraInput(camera: CameraDevice, callback: AsyncCallback<CameraInput\>):
Creates a **CameraInput** instance with the specified **CameraDevice** object. This API uses an asynchronous callback to return the result. Creates a **CameraInput** instance with the specified **CameraDevice** object. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permissions**: ohos.permission.CAMERA **Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -309,13 +318,14 @@ This is a system API. ...@@ -309,13 +318,14 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | --------------------------------- | | -------- | ------------------------------------------- | ---- | --------------------------------- |
| camera | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object. | | cameraDevice | [CameraDevice](#cameradevice) | Yes | Target **CameraDevice** object, which is obtained through **getSupportedCameras**. |
| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance. | | callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance. |
**Example** **Example**
```js ```js
cameraManager.createCameraInput(camera, (err, cameraInput) => { let cameraDevice = cameras[0];
cameraManager.createCameraInput(cameraDevice, (err, cameraInput) => {
if (err) { if (err) {
console.error(`Failed to create the CameraInput instance. ${err.message}`); console.error(`Failed to create the CameraInput instance. ${err.message}`);
return; return;
...@@ -326,12 +336,10 @@ cameraManager.createCameraInput(camera, (err, cameraInput) => { ...@@ -326,12 +336,10 @@ cameraManager.createCameraInput(camera, (err, cameraInput) => {
### createCameraInput ### createCameraInput
createCameraInput(camera: CameraDevice): Promise<CameraInput\> createCameraInput(cameraDevice: CameraDevice): Promise<CameraInput\>
Creates a **CameraInput** instance with the specified **CameraDevice** object. This API uses a promise to return the result. Creates a **CameraInput** instance with the specified **CameraDevice** object. This API uses a promise to return the result.
This is a system API.
**Required permissions**: ohos.permission.CAMERA **Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -340,7 +348,7 @@ This is a system API. ...@@ -340,7 +348,7 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ---------- | | -------- | ----------------------------- | ---- | ---------- |
| camera | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object.| | cameraDevice | [CameraDevice](#cameradevice) | Yes | Target **CameraDevice** object, which is obtained through **getSupportedCameras**.|
**Return value** **Return value**
...@@ -351,7 +359,8 @@ This is a system API. ...@@ -351,7 +359,8 @@ This is a system API.
**Example** **Example**
```js ```js
cameraManager.createCameraInput(camera).then((cameraInput) => { let cameraDevice = cameras[0];
cameraManager.createCameraInput(cameraDevice).then((cameraInput) => {
console.log('Promise returned with the CameraInput instance'); console.log('Promise returned with the CameraInput instance');
}) })
``` ```
...@@ -362,8 +371,6 @@ createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCal ...@@ -362,8 +371,6 @@ createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCal
Creates a **CameraInput** instance with the specified camera position and type. This API uses an asynchronous callback to return the result. Creates a **CameraInput** instance with the specified camera position and type. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permissions**: ohos.permission.CAMERA **Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -372,14 +379,17 @@ This is a system API. ...@@ -372,14 +379,17 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | --------------------------------- | | -------- | ------------------------------------------- | ---- | --------------------------------- |
| position | [CameraPosition](#cameraposition) | Yes | Camera position. | | position | [CameraPosition](#cameraposition) | Yes | Camera position, which is obtained through **getSupportedCameras**. This API obtains a **CameraDevice** object, which contains the camera position information. |
| type | [CameraType](#cameratype) | Yes | Camera type. | | type | [CameraType](#cameratype) | Yes | Camera type, which is obtained through **getSupportedCameras**. This API obtains a **CameraDevice** object, which contains the camera type information. |
| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance. | | callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance. |
**Example** **Example**
```js ```js
cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => { let cameraDevice = cameras[0];
let position = cameraDevice.cameraPosition;
let type = cameraDevice.cameraType;
cameraManager.createCameraInput(position, type, (err, cameraInput) => {
if (err) { if (err) {
console.error(`Failed to create the CameraInput instance. ${err.message}`); console.error(`Failed to create the CameraInput instance. ${err.message}`);
return; return;
...@@ -394,8 +404,6 @@ createCameraInput(position: CameraPosition, type:CameraType ): Promise<CameraInp ...@@ -394,8 +404,6 @@ createCameraInput(position: CameraPosition, type:CameraType ): Promise<CameraInp
Creates a **CameraInput** instance with the specified camera position and type. This API uses a promise to return the result. Creates a **CameraInput** instance with the specified camera position and type. This API uses a promise to return the result.
This is a system API.
**Required permissions**: ohos.permission.CAMERA **Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -404,8 +412,8 @@ This is a system API. ...@@ -404,8 +412,8 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------- | ---- | ------------ | | -------- | --------------------------------- | ---- | ------------ |
| position | [CameraPosition](#cameraposition) | Yes | Camera position. | | position | [CameraPosition](#cameraposition) | Yes | Camera position, which is obtained through **getSupportedCameras**. This API obtains a **CameraDevice** object, which contains the camera position information. |
| type | [CameraType](#cameratype) | Yes | Camera type. | | type | [CameraType](#cameratype) | Yes | Camera type, which is obtained through **getSupportedCameras**. This API obtains a **CameraDevice** object, which contains the camera type information. |
**Return value** **Return value**
...@@ -416,7 +424,10 @@ This is a system API. ...@@ -416,7 +424,10 @@ This is a system API.
**Example** **Example**
```js ```js
cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => { let cameraDevice = cameras[0];
let position = cameraDevice.cameraPosition;
let type = cameraDevice.cameraType;
cameraManager.createCameraInput(position, type).then((cameraInput) => {
console.log('Promise returned with the CameraInput instance'); console.log('Promise returned with the CameraInput instance');
}) })
``` ```
...@@ -433,14 +444,15 @@ Creates a **PreviewOutput** instance. This API uses an asynchronous callback to ...@@ -433,14 +444,15 @@ Creates a **PreviewOutput** instance. This API uses an asynchronous callback to
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | ------------------------------- | | -------- | ----------------------------------------------- | ---- | ------------------------------- |
| profile | [Profile](#profile) | Yes | Supported preview profile. | | profile | [Profile](#profile) | Yes | Supported preview profiles, which are obtained through **getSupportedOutputCapability**.|
| surfaceId| string | Yes | Surface ID, which is obtained from **[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)** or **[ImageReceiver](js-apis-image.md#imagereceiver9)**.| | surfaceId| string | Yes | Surface ID, which is obtained from [XComponent](../arkui-ts/ts-basic-components-xcomponent.md) or [ImageReceiver](js-apis-image.md#imagereceiver9).|
| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | Yes | Callback used to return the **PreviewOutput** instance.| | callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | Yes | Callback used to return the **PreviewOutput** instance.|
**Example** **Example**
```js ```js
cameraManager.createPreviewOutput(profile, surfaceId, (err, previewoutput) => { let profile = cameraoutputcapability.previewProfiles[0];
cameraManager.createPreviewOutput(profile, surfaceId, (err, previewOutput) => {
if (err) { if (err) {
console.error(`Failed to gcreate previewOutput. ${err.message}`); console.error(`Failed to gcreate previewOutput. ${err.message}`);
return; return;
...@@ -461,8 +473,8 @@ Creates a **PreviewOutput** instance. This API uses a promise to return the resu ...@@ -461,8 +473,8 @@ Creates a **PreviewOutput** instance. This API uses a promise to return the resu
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------| ---- | ----------------- | | -------- | ---------------------------------| ---- | ----------------- |
| profile | [Profile](#profile) | Yes | Supported preview profile. | | profile | [Profile](#profile) | Yes | Supported preview profiles, which are obtained through **getSupportedOutputCapability**.|
| surfaceId| string | Yes | Surface ID, which is obtained from **[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)** or **[ImageReceiver](js-apis-image.md#imagereceiver9)**.| | surfaceId| string | Yes | Surface ID, which is obtained from [XComponent](../arkui-ts/ts-basic-components-xcomponent.md) or [ImageReceiver](js-apis-image.md#imagereceiver9).|
**Return value** **Return value**
...@@ -473,7 +485,8 @@ Creates a **PreviewOutput** instance. This API uses a promise to return the resu ...@@ -473,7 +485,8 @@ Creates a **PreviewOutput** instance. This API uses a promise to return the resu
**Example** **Example**
```js ```js
cameraManager.createPreviewOutput(profile, surfaceId).then((previewoutput) => { let profile = cameraoutputcapability.previewProfiles[0];
cameraManager.createPreviewOutput(profile, surfaceId).then((previewOutput) => {
console.log('Promise returned with previewOutput created.'); console.log('Promise returned with previewOutput created.');
}) })
``` ```
...@@ -490,14 +503,15 @@ Creates a **PhotoOutput** instance. This API uses an asynchronous callback to re ...@@ -490,14 +503,15 @@ Creates a **PhotoOutput** instance. This API uses an asynchronous callback to re
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ----------------------------------- | | -------- | ------------------------------------------- | ---- | ----------------------------------- |
| profile | [Profile](#profile) | Yes | Supported shooting profile. | | profile | [Profile](#profile) | Yes | Supported shooting profiles, which are obtained through **getSupportedOutputCapability**.|
| surfaceId| string | Yes | Surface ID, which is obtained from **[ImageReceiver](js-apis-image.md#imagereceiver9)**.| | surfaceId| string | Yes | Surface ID, which is obtained from [ImageReceiver](js-apis-image.md#imagereceiver9).|
| callback | AsyncCallback<[PhotoOutput](#photooutput)\> | Yes | Callback used to return the **PhotoOutput** instance. | | callback | AsyncCallback<[PhotoOutput](#photooutput)\> | Yes | Callback used to return the **PhotoOutput** instance. |
**Example** **Example**
```js ```js
cameraManager.createPhotoOutput(profile, surfaceId, (err, photooutput) => { let profile = cameraoutputcapability.photoProfiles[0];
cameraManager.createPhotoOutput(profile, surfaceId, (err, photoOutput) => {
if (err) { if (err) {
console.error(`Failed to create photoOutput. ${err.message}`); console.error(`Failed to create photoOutput. ${err.message}`);
return; return;
...@@ -518,8 +532,8 @@ Creates a **PhotoOutput** instance. This API uses a promise to return the result ...@@ -518,8 +532,8 @@ Creates a **PhotoOutput** instance. This API uses a promise to return the result
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------| ---- | ----------- | | -------- | ---------------------------------| ---- | ----------- |
| profile | [Profile](#profile) | Yes | Supported shooting profile. | | profile | [Profile](#profile) | Yes | Supported shooting profiles, which are obtained through **getSupportedOutputCapability**.|
| surfaceId| string | Yes | Surface ID, which is obtained from **[ImageReceiver](js-apis-image.md#imagereceiver9)**.| | surfaceId| string | Yes | Surface ID, which is obtained from [ImageReceiver](js-apis-image.md#imagereceiver9).|
**Return value** **Return value**
...@@ -530,7 +544,8 @@ Creates a **PhotoOutput** instance. This API uses a promise to return the result ...@@ -530,7 +544,8 @@ Creates a **PhotoOutput** instance. This API uses a promise to return the result
**Example** **Example**
```js ```js
cameraManager.createPhotoOutput(profile, surfaceId).then((photooutput) => { let profile = cameraoutputcapability.photoProfiles[0];
cameraManager.createPhotoOutput(profile, surfaceId).then((photoOutput) => {
console.log('Promise returned with photoOutput created.'); console.log('Promise returned with photoOutput created.');
}) })
``` ```
...@@ -547,14 +562,15 @@ Creates a **VideoOutput** instance. This API uses an asynchronous callback to re ...@@ -547,14 +562,15 @@ Creates a **VideoOutput** instance. This API uses an asynchronous callback to re
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ------------------------------ | | -------- | ------------------------------------------- | ---- | ------------------------------ |
| profile | [VideoProfile](#videoprofile) | Yes | Supported video recording profile. | | profile | [VideoProfile](#videoprofile) | Yes | Supported video recording profiles, which are obtained through **getSupportedOutputCapability**.|
| surfaceId| string | Yes | Surface ID, which is obtained from **[VideoRecorder](js-apis-media.md#videorecorder9)**.| | surfaceId| string | Yes | Surface ID, which is obtained from [VideoRecorder](js-apis-media.md#videorecorder9).|
| callback | AsyncCallback<[VideoOutput](#videooutput)\> | Yes | Callback used to return the **VideoOutput** instance.| | callback | AsyncCallback<[VideoOutput](#videooutput)\> | Yes | Callback used to return the **VideoOutput** instance.|
**Example** **Example**
```js ```js
cameraManager.createVideoOutput(profile, surfaceId, (err, videooutput) => { let profile = cameraoutputcapability.videoProfiles[0];
cameraManager.createVideoOutput(profile, surfaceId, (err, videoOutput) => {
if (err) { if (err) {
console.error(`Failed to create videoOutput. ${err.message}`); console.error(`Failed to create videoOutput. ${err.message}`);
return; return;
...@@ -575,8 +591,8 @@ Creates a **VideoOutput** instance. This API uses a promise to return the result ...@@ -575,8 +591,8 @@ Creates a **VideoOutput** instance. This API uses a promise to return the result
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------| ---- | ---------- | | -------- | ---------------------------------| ---- | ---------- |
| profile | [VideoProfile](#videoprofile) | Yes | Supported video recording profile. | | profile | [VideoProfile](#videoprofile) | Yes | Supported video recording profiles, which are obtained through **getSupportedOutputCapability**.|
| surfaceId| string | Yes | Surface ID, which is obtained from **[VideoRecorder](js-apis-media.md#videorecorder9)**.| | surfaceId| string | Yes | Surface ID, which is obtained from [VideoRecorder](js-apis-media.md#videorecorder9).|
**Return value** **Return value**
...@@ -587,7 +603,8 @@ Creates a **VideoOutput** instance. This API uses a promise to return the result ...@@ -587,7 +603,8 @@ Creates a **VideoOutput** instance. This API uses a promise to return the result
**Example** **Example**
```js ```js
cameraManager.createVideoOutput(profile, surfaceId).then((videooutput) => { let profile = cameraoutputcapability.videoProfiles[0];
cameraManager.createVideoOutput(profile, surfaceId).then((videoOutput) => {
console.log('Promise returned with videoOutput created.'); console.log('Promise returned with videoOutput created.');
}) })
``` ```
...@@ -604,13 +621,14 @@ Creates a **MetadataOutput** instance. This API uses an asynchronous callback to ...@@ -604,13 +621,14 @@ Creates a **MetadataOutput** instance. This API uses an asynchronous callback to
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------------- | -------------------------------------------------- | --- | ---------------------------- | | -------------------- | -------------------------------------------------- | --- | ---------------------------- |
| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes | Metadata object types. | | metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes | Metadata object types, which are obtained through **getSupportedOutputCapability**.|
| callback | AsyncCallback<[MetadataOutput](#metadataoutput)\> | Yes | Callback used to return the **MetadataOutput** instance. | | callback | AsyncCallback<[MetadataOutput](#metadataoutput)\> | Yes | Callback used to return the **MetadataOutput** instance. |
**Example** **Example**
```js ```js
cameraManager.createMetadataOutput(metadataObjectTypes, (err, metadataoutput) => { let metadataObjectTypes = cameraoutputcapability.supportedMetadataObjectTypes;
cameraManager.createMetadataOutput(metadataObjectTypes, (err, metadataOutput) => {
if (err) { if (err) {
console.error(`Failed to create metadataOutput. ${err.message}`); console.error(`Failed to create metadataOutput. ${err.message}`);
return; return;
...@@ -631,7 +649,7 @@ Creates a **MetadataOutput** instance. This API uses a promise to return the res ...@@ -631,7 +649,7 @@ Creates a **MetadataOutput** instance. This API uses a promise to return the res
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------------- | -------------------------------------------------- | --- | -------------------- | | -------------------- | -------------------------------------------------- | --- | -------------------- |
| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes | Metadata object types. | | metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes | Metadata object types, which are obtained through **getSupportedOutputCapability**. |
**Return value** **Return value**
...@@ -642,7 +660,8 @@ Creates a **MetadataOutput** instance. This API uses a promise to return the res ...@@ -642,7 +660,8 @@ Creates a **MetadataOutput** instance. This API uses a promise to return the res
**Example** **Example**
```js ```js
cameraManager.createMetadataOutput().then((metadataoutput) => { let metadataObjectTypes = cameraoutputcapability.supportedMetadataObjectTypes;
cameraManager.createMetadataOutput(metadataObjectTypes).then((metadataOutput) => {
console.log('Promise returned with metadataOutput created.'); console.log('Promise returned with metadataOutput created.');
}) })
``` ```
...@@ -664,7 +683,7 @@ Creates a **CaptureSession** instance. This API uses an asynchronous callback to ...@@ -664,7 +683,7 @@ Creates a **CaptureSession** instance. This API uses an asynchronous callback to
**Example** **Example**
```js ```js
cameraManager.createCaptureSession((err, capturesession) => { cameraManager.createCaptureSession((err, captureSession) => {
if (err) { if (err) {
console.error(`Failed to create captureSession. ${err.message}`); console.error(`Failed to create captureSession. ${err.message}`);
return; return;
...@@ -690,7 +709,7 @@ Creates a **CaptureSession** instance. This API uses a promise to return the res ...@@ -690,7 +709,7 @@ Creates a **CaptureSession** instance. This API uses a promise to return the res
**Example** **Example**
```js ```js
cameraManager.createCaptureSession().then((capturesession) => { cameraManager.createCaptureSession().then((captureSession) => {
console.log('Promise returned with captureSession created.'); console.log('Promise returned with captureSession created.');
}) })
``` ```
...@@ -729,6 +748,8 @@ on(type: 'cameraMute', callback: AsyncCallback<boolean\>): void ...@@ -729,6 +748,8 @@ on(type: 'cameraMute', callback: AsyncCallback<boolean\>): void
Listens for camera mute status changes. This API uses an asynchronous callback to return the result. Listens for camera mute status changes. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters** **Parameters**
...@@ -736,12 +757,12 @@ Listens for camera mute status changes. This API uses an asynchronous callback t ...@@ -736,12 +757,12 @@ Listens for camera mute status changes. This API uses an asynchronous callback t
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------- | ---- | --------- | | -------- | --------------- | ---- | --------- |
| type | string | Yes | Event type. The value is fixed at **'cameraMute'**, indicating the camera mute status change event.| | type | string | Yes | Event type. The value is fixed at **'cameraMute'**, indicating the camera mute status change event.|
| callback | boolean | Yes | Callback used to return the camera mute status. | | callback | AsyncCallback<boolean> | Yes | Callback used to return the camera mute status. |
**Example** **Example**
```js ```js
cameraManager.on('cameraMute', (err, cameraStatusInfo) => { cameraManager.on('cameraMute', (err, curMuetd) => {
if (err) { if (err) {
console.error(`Failed to get cameraMute callback. ${err.message}`); console.error(`Failed to get cameraMute callback. ${err.message}`);
return; return;
...@@ -755,10 +776,10 @@ Describes the camera status information. ...@@ -755,10 +776,10 @@ Describes the camera status information.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ------ | ----------------------------- | ---------- | | ------ | ----------------------------- | -------------- | ---------- |
| camera | [CameraDevice](#cameradevice) | Camera object.| | camera | [CameraDevice](#cameradevice) | Yes | Camera object.|
| status | [CameraStatus](#camerastatus) | Camera status.| | status | [CameraStatus](#camerastatus) | Yes | Camera status.|
## CameraPosition ## CameraPosition
...@@ -804,27 +825,13 @@ Defines the camera device information. ...@@ -804,27 +825,13 @@ Defines the camera device information.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Read Only| Description | | Name | Type | Mandatory| Description |
| -------------- | --------------------------------- | ---- | ---------- | | -------------- | --------------------------------- | ---- | ---------- |
| cameraId | string | Yes | **CameraDevice** object.| | cameraId | string | Yes | **CameraDevice** object.|
| cameraPosition | [CameraPosition](#cameraposition) | Yes | Camera position. | | cameraPosition | [CameraPosition](#cameraposition) | Yes | Camera position. |
| cameraType | [CameraType](#cameratype) | Yes | Camera type. | | cameraType | [CameraType](#cameratype) | Yes | Camera type. |
| connectionType | [ConnectionType](#connectiontype) | Yes | Camera connection type.| | connectionType | [ConnectionType](#connectiontype) | Yes | Camera connection type.|
**Example**
```js
async function getCameraInfo("cameraId") {
let cameraManager = await camera.getCameraManager(context);
let cameras = await cameraManager.getSupportedCameras();
let cameraObj = cameras[0];
let cameraId = cameraObj.cameraId;
let cameraPosition = cameraObj.cameraPosition;
let cameraType = cameraObj.cameraType;
let connectionType = cameraObj.connectionType;
}
```
## Size ## Size
Enumerates the camera output capability. Enumerates the camera output capability.
...@@ -853,7 +860,7 @@ Enumerates the camera output formats. ...@@ -853,7 +860,7 @@ Enumerates the camera output formats.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value | Description | | Name | Value | Description |
| ----------------------- | --------- | ------------ | | ----------------------- | --------- | ------------ |
| CAMERA_FORMAT_RGBA_8888 | 3 | RGB image. | | CAMERA_FORMAT_RGBA_8888 | 3 | RGB image. |
| CAMERA_FORMAT_YUV_420_SP| 1003 | YUV 420 SP image. | | CAMERA_FORMAT_YUV_420_SP| 1003 | YUV 420 SP image. |
...@@ -1009,7 +1016,7 @@ cameraInput.release().then(() => { ...@@ -1009,7 +1016,7 @@ cameraInput.release().then(() => {
### on('error') ### on('error')
on(type: 'error', camera:CameraDevice, callback: ErrorCallback<CameraInputError\>): void on(type: 'error', cameraDevice:CameraDevice, callback: ErrorCallback<CameraInputError\>): void
Listens for **CameraInput** errors. This API uses a callback to return the result. Listens for **CameraInput** errors. This API uses a callback to return the result.
...@@ -1020,13 +1027,14 @@ Listens for **CameraInput** errors. This API uses a callback to return the resul ...@@ -1020,13 +1027,14 @@ Listens for **CameraInput** errors. This API uses a callback to return the resul
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------- | --- | ------------------------------------------- | | -------- | -------------------------------- | --- | ------------------------------------------- |
| type | string | Yes | Event type. The value is fixed at **'error'**, indicating the camera input error event.| | type | string | Yes | Event type. The value is fixed at **'error'**, indicating the camera input error event.|
| camera | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object.| | cameraDevice | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object.|
| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | Yes | Callback used to return the result. | | callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
cameraInput.on('error', camera, (cameraInputError) => { let cameraDevice = cameras[0];
cameraInput.on('error', cameraDevice, (cameraInputError) => {
console.log(`Camera input error code: ${cameraInputError.code}`); console.log(`Camera input error code: ${cameraInputError.code}`);
}) })
``` ```
...@@ -1052,9 +1060,9 @@ Defines an error object used for **[CameraInput](#camerainput)**. ...@@ -1052,9 +1060,9 @@ Defines an error object used for **[CameraInput](#camerainput)**.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
| Name| Type | Description | | Name| Type | Mandatory | Description |
| ---- | --------------------------------------------- | --------------------- | | ---- | --------------------------------------------- | ------------ |--------------------- |
| code | [CameraInputErrorCode](#camerainputerrorcode) | **CameraInput** error code.| | code | [CameraInputErrorCode](#camerainputerrorcode) | Yes |**CameraInput** error code.|
## FlashMode ## FlashMode
...@@ -1334,9 +1342,9 @@ captureSession.removeInput(cameraInput).then(() => { ...@@ -1334,9 +1342,9 @@ captureSession.removeInput(cameraInput).then(() => {
### addOutput ### addOutput
addOutput\(cameraOutput: CameraOutput, callback: AsyncCallback<void\>\): void addOutput\(previewOutput: CameraOutput, callback: AsyncCallback<void\>\): void
Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. This API uses an asynchronous callback to return the result. Adds a [CameraOutput](#cameraoutput) instance to this **CaptureSession**. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -1344,13 +1352,13 @@ Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. Th ...@@ -1344,13 +1352,13 @@ Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. Th
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | ------------------------------- | ---- | ------------------------ | | ------------- | ------------------------------- | ---- | ------------------------ |
| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to add.| | previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to add.|
| callback | AsyncCallback<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback<void\> | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
captureSession.addOutput(cameraOutput, (err) => { captureSession.addOutput(previewOutput, (err) => {
if (err) { if (err) {
console.error(`Failed to add output. ${err.message}`); console.error(`Failed to add output. ${err.message}`);
return; return;
...@@ -1361,9 +1369,9 @@ captureSession.addOutput(cameraOutput, (err) => { ...@@ -1361,9 +1369,9 @@ captureSession.addOutput(cameraOutput, (err) => {
### addOutput ### addOutput
addOutput\(cameraOutput: CameraOutput\): Promise<void\> addOutput\(previewOutput: CameraOutput\): Promise<void\>
Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. This API uses a promise to return the result. Adds a [CameraOutput](#cameraoutput) instance to this **CaptureSession**. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -1371,7 +1379,7 @@ Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. Th ...@@ -1371,7 +1379,7 @@ Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. Th
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | ------------------------------- | ---- | ------------------------- | | ------------- | ------------------------------- | ---- | ------------------------- |
| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to add.| | previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to add.|
**Return value** **Return value**
...@@ -1382,16 +1390,16 @@ Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. Th ...@@ -1382,16 +1390,16 @@ Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. Th
**Example** **Example**
```js ```js
captureSession.addOutput(cameraOutput).then(() => { captureSession.addOutput(previewOutput).then(() => {
console.log('Promise returned with cameraOutput added.'); console.log('Promise returned with cameraOutput added.');
}) })
``` ```
### removeOutput ### removeOutput
removeOutput\(cameraOutput: CameraOutput, callback: AsyncCallback<void\>\): void removeOutput\(previewOutput: CameraOutput, callback: AsyncCallback<void\>\): void
Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession**. This API uses an asynchronous callback to return the result. Removes a [CameraOutput](#cameraoutput) instance from this **CaptureSession**. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -1399,13 +1407,13 @@ Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession* ...@@ -1399,13 +1407,13 @@ Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession*
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | ------------------------------- | ---- | ------------------------ | | ------------- | ------------------------------- | ---- | ------------------------ |
| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to remove.| | previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to remove.|
| callback | AsyncCallback<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback<void\> | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
captureSession.removeOutput(cameraOutput, (err) => { captureSession.removeOutput(previewOutput, (err) => {
if (err) { if (err) {
console.error(`Failed to remove the CameraOutput instance. ${err.message}`); console.error(`Failed to remove the CameraOutput instance. ${err.message}`);
return; return;
...@@ -1416,9 +1424,9 @@ captureSession.removeOutput(cameraOutput, (err) => { ...@@ -1416,9 +1424,9 @@ captureSession.removeOutput(cameraOutput, (err) => {
### removeOutput ### removeOutput
removeOutput(cameraOutput: CameraOutput): Promise<void\> removeOutput(previewOutput: CameraOutput): Promise<void\>
Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession**. This API uses a promise to return the result. Removes a [CameraOutput](#cameraoutput) instance from this **CaptureSession**. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -1426,7 +1434,7 @@ Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession* ...@@ -1426,7 +1434,7 @@ Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession*
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | ------------------------------- | ---- | ------------------------- | | ------------- | ------------------------------- | ---- | ------------------------- |
| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to remove.| | previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to remove.|
**Return value** **Return value**
...@@ -1439,7 +1447,7 @@ Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession* ...@@ -1439,7 +1447,7 @@ Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession*
**Example** **Example**
```js ```js
captureSession.removeOutput(cameraOutput).then(() => { captureSession.removeOutput(previewOutput).then(() => {
console.log('Promise returned to indicate that the CameraOutput instance is removed.'); console.log('Promise returned to indicate that the CameraOutput instance is removed.');
}) })
``` ```
...@@ -2106,8 +2114,8 @@ Obtains the exposure compensation values. This API uses a promise to return the ...@@ -2106,8 +2114,8 @@ Obtains the exposure compensation values. This API uses a promise to return the
**Example** **Example**
```js ```js
captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then((isSupported) => { captureSession.getExposureBiasRange().then((biasRangeArray) => {
console.log(`Promise returned with exposure mode supported : ${isSupported}`); console.log('Promise returned with the array of compenstation range: ' + JSON.stringify(biasRangeArray));
}) })
``` ```
...@@ -2125,13 +2133,14 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure ...@@ -2125,13 +2133,14 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------| ---- | ------------------- | | -------- | -------------------------------| ---- | ------------------- |
| exposureBias | number | Yes | Compensation value. | | exposureBias | number | Yes | Compensation value. You can use **getExposureBiasRange** to obtain the supported values.|
| callback | AsyncCallback<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback<void\> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
captureSession.setExposureBias(-4,(err) => { let exposureBias = biasRangeArray[0];
captureSession.setExposureBias(exposureBias,(err) => {
if (err) { if (err) {
console.log(`Failed to set the exposure bias ${err.message}`); console.log(`Failed to set the exposure bias ${err.message}`);
return ; return ;
...@@ -2154,7 +2163,7 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure ...@@ -2154,7 +2163,7 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------- | --------- | ---- | --------- | | -------------- | --------- | ---- | --------- |
| exposureBias | number | Yes | Compensation value. | | exposureBias | number | Yes | Compensation value. You can use **getExposureBiasRange** to obtain the supported values. |
**Return value** **Return value**
...@@ -2165,7 +2174,8 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure ...@@ -2165,7 +2174,8 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure
**Example** **Example**
```js ```js
captureSession.setExposureBias(-4).then(() => { let exposureBias = biasRangeArray[0];
captureSession.setExposureBias(exposureBias).then(() => {
console.log('Promise returned with the successful execution of setExposureBias.'); console.log('Promise returned with the successful execution of setExposureBias.');
}) })
``` ```
...@@ -2595,13 +2605,14 @@ Sets a zoom ratio. This API uses an asynchronous callback to return the result. ...@@ -2595,13 +2605,14 @@ Sets a zoom ratio. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | -------------------- | ---- | ------------------- | | --------- | -------------------- | ---- | ------------------- |
| zoomRatio | number | Yes | Zoom ratio. | | zoomRatio | number | Yes | Zoom ratio. You can use **getZoomRatioRange** to obtain the supported values.|
| callback | AsyncCallback<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback<void\> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
captureSession.setZoomRatio(1, (err) => { let zoomRatio = zoomRatioRange[0];
captureSession.setZoomRatio(zoomRatio, (err) => {
if (err) { if (err) {
console.error(`Failed to set the zoom ratio value ${err.message}`); console.error(`Failed to set the zoom ratio value ${err.message}`);
return; return;
...@@ -2622,7 +2633,7 @@ Sets a zoom ratio. This API uses a promise to return the result. ...@@ -2622,7 +2633,7 @@ Sets a zoom ratio. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ------ | ---- | --------- | | --------- | ------ | ---- | --------- |
| zoomRatio | number | Yes | Zoom ratio.| | zoomRatio | number | Yes | Zoom ratio. You can use **getZoomRatioRange** to obtain the supported values.|
**Return value** **Return value**
...@@ -2633,7 +2644,8 @@ Sets a zoom ratio. This API uses a promise to return the result. ...@@ -2633,7 +2644,8 @@ Sets a zoom ratio. This API uses a promise to return the result.
**Example** **Example**
```js ```js
captureSession.setZoomRatio(1).then(() => { let zoomRatio = zoomRatioRange[0];
captureSession.setZoomRatio(zoomRatio).then(() => {
console.log('Promise returned with the successful execution of setZoomRatio.'); console.log('Promise returned with the successful execution of setZoomRatio.');
}) })
``` ```
...@@ -2902,45 +2914,49 @@ Defines a **CaptureSession** error. ...@@ -2902,45 +2914,49 @@ Defines a **CaptureSession** error.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
| Name| Type | Description | | Name| Type | Mandatory | Description |
| ---- | ------------------------------------------- | -------------------------- | | ---- | ------------------------------------------- | -------------------------- |-------------------------- |
| code | [CaptureSessionError](#capturesessionerror) | **CaptureSession** error code.| | code | [CaptureSessionError](#capturesessionerror) | Yes |**CaptureSession** error code.|
## CameraOutput ## CameraOutput
Implements output information used in a **[CaptureSession](#capturesession)**. It is the base class of **output**. Implements output information used in a **[CaptureSession](#capturesession)**. It is the base class of **output**.
### release ## PreviewOutput
release(callback: AsyncCallback<void\>): void Implements preview output. It inherits **[CameraOutput](#cameraoutput)**.
Releases output resources. This API uses an asynchronous callback to return the result. ### start
start(callback: AsyncCallback<void\>): void
Starts to output preview streams. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------- | | -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback<void\> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
cameraOutput.release((err) => { previewOutput.start((err) => {
if (err) { if (err) {
console.error(`Failed to release the PreviewOutput instance ${err.message}`); console.error(`Failed to start the previewOutput. ${err.message}`);
return; return;
} }
console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); console.log('Callback returned with previewOutput started.');
}); })
``` ```
### release ### start
release(): Promise<void\> start(): Promise<void\>
Releases output resources. This API uses a promise to return the result. Starts to output preview streams. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -2953,20 +2969,16 @@ Releases output resources. This API uses a promise to return the result. ...@@ -2953,20 +2969,16 @@ Releases output resources. This API uses a promise to return the result.
**Example** **Example**
```js ```js
cameraOutput.release().then(() => { previewOutput.start().then(() => {
console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); console.log('Promise returned with previewOutput started.');
}) })
``` ```
## PreviewOutput ### stop
Implements preview output. It inherits **[CameraOutput](#cameraoutput)**.
### start
start(callback: AsyncCallback<void\>): void stop(callback: AsyncCallback<void\>): void
Starts to output preview streams. This API uses an asynchronous callback to return the result. Stops outputting preview streams. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -2979,82 +2991,82 @@ Starts to output preview streams. This API uses an asynchronous callback to retu ...@@ -2979,82 +2991,82 @@ Starts to output preview streams. This API uses an asynchronous callback to retu
**Example** **Example**
```js ```js
previewOutput.start((err) => { previewOutput.stop((err) => {
if (err) { if (err) {
console.error(`Failed to start the previewOutput. ${err.message}`); console.error(`Failed to stop the previewOutput. ${err.message}`);
return; return;
} }
console.log('Callback returned with previewOutput started.'); console.log('Callback returned with previewOutput stopped.');
}) })
``` ```
### start ### stop
start(): Promise<void\> stop(): Promise<void\>
Starts to output preview streams. This API uses a promise to return the result. Stops outputting preview streams. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ----------------------- | | -------------- | ------------------------ |
| Promise<void\>| Promise used to return the result.| | Promise<void\>| Promise used to return the result.|
**Example** **Example**
```js ```js
previewOutput.start().then(() => { previewOutput.stop().then(() => {
console.log('Promise returned with previewOutput started.'); console.log('Callback returned with previewOutput stopped.');
}) })
``` ```
### stop ### release
stop(callback: AsyncCallback<void\>): void release(callback: AsyncCallback<void\>): void
Stops outputting preview streams. This API uses an asynchronous callback to return the result. Releases output resources. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- | | -------- | -------------------- | ---- | ------------------- |
| callback | AsyncCallback<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback<void\> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
previewOutput.stop((err) => { previewOutput.release((err) => {
if (err) { if (err) {
console.error(`Failed to stop the previewOutput. ${err.message}`); console.error(`Failed to release the PreviewOutput instance ${err.message}`);
return; return;
} }
console.log('Callback returned with previewOutput stopped.'); console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.');
}) });
``` ```
### stop ### release
stop(): Promise<void\> release(): Promise<void\>
Stops outputting preview streams. This API uses a promise to return the result. Releases output resources. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ------------------------ | | -------------- | ----------------------- |
| Promise<void\>| Promise used to return the result.| | Promise<void\>| Promise used to return the result.|
**Example** **Example**
```js ```js
previewOutput.stop().then(() => { previewOutput.release().then(() => {
console.log('Callback returned with previewOutput stopped.'); console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.');
}) })
``` ```
...@@ -3143,9 +3155,9 @@ Defines the preview output error. ...@@ -3143,9 +3155,9 @@ Defines the preview output error.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
| Name| Type | Description | | Name| Type | Mandatory | Description |
| ---- | ------------------------------------------------- | ---------------------- | | ---- | ------------------------------------------------- | ---------------- |---------------------- |
| code | [PreviewOutputErrorCode](#previewoutputerrorcode) | **PreviewOutput** error code.| | code | [PreviewOutputErrorCode](#previewoutputerrorcode) | Yes |**PreviewOutput** error code.|
## ImageRotation ## ImageRotation
...@@ -3191,16 +3203,16 @@ Defines the settings for photo capture. ...@@ -3191,16 +3203,16 @@ Defines the settings for photo capture.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ----------------- | -----------------| | -------- | ------------------------------- | ---- | -----------------|
| quality | [QualityLevel](#qualitylevel) | No | QUALITY_LEVEL_HIGH| Photo quality. | | quality | [QualityLevel](#qualitylevel) | No | Photo quality. |
| rotation | [ImageRotation](#imagerotation) | No | ROTATION_0 | Rotation angle of the photo. | | rotation | [ImageRotation](#imagerotation) | No | Rotation angle of the photo. |
| location | [Location](#location) | No | (0,0,0) | Geolocation information of the photo. | | location | [Location](#location) | No | Geolocation information of the photo. |
| mirror | boolean | No | false |Whether mirroring is enabled. By default, mirroring is disabled.| | mirror | boolean | No |Whether mirroring is enabled. By default, mirroring is disabled.|
## PhotoOutput ## PhotoOutput
Implements output information used in a **CaptureSession**. Implements output information used in a shooting session. This class inherits from [CameraOutput](#cameraoutput).
### capture ### capture
...@@ -3246,9 +3258,16 @@ Captures a photo with the specified shooting parameters. This API uses an asynch ...@@ -3246,9 +3258,16 @@ Captures a photo with the specified shooting parameters. This API uses an asynch
**Example** **Example**
```js ```js
let settings:PhotoCaptureSetting = { let captureLocation = {
quality = 1, latitude: 0,
rotation = 0 longitude: 0,
altitude: 0,
}
let settings = {
quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
rotation: camera.ImageRotation.ROTATION_0,
location: captureLocation,
mirror: false
} }
photoOutput.capture(settings, (err) => { photoOutput.capture(settings, (err) => {
if (err) { if (err) {
...@@ -3314,6 +3333,54 @@ photoOutput.isMirrorSupported((err, isSupported) => { ...@@ -3314,6 +3333,54 @@ photoOutput.isMirrorSupported((err, isSupported) => {
}) })
``` ```
### release
release(callback: AsyncCallback<void\>): void
Releases output resources. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------- |
| callback | AsyncCallback<void\> | Yes | Callback used to return the result.|
**Example**
```js
photoOutput.release((err) => {
if (err) {
console.error(`Failed to release the PreviewOutput instance ${err.message}`);
return;
}
console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.');
});
```
### release
release(): Promise<void\>
Releases output resources. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Return value**
| Type | Description |
| -------------- | ----------------------- |
| Promise<void\>| Promise used to return the result.|
**Example**
```js
photoOutput.release().then(() => {
console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.');
})
```
### isMirrorSupported ### isMirrorSupported
isMirrorSupported(): Promise<boolean\> isMirrorSupported(): Promise<boolean\>
...@@ -3471,13 +3538,13 @@ Defines a photo output error. ...@@ -3471,13 +3538,13 @@ Defines a photo output error.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
| Name| Type | Description | | Name| Type | Mandatory |Description |
| ---- | ------------------------------------- | ----------------------- | | ---- | ------------------------------------- | --------- | ----------------------- |
| code | [PhotoOutputErrorCode](#photooutputerrorcode) | **PhotoOutput** error code.| | code | [PhotoOutputErrorCode](#photooutputerrorcode) | Yes | **PhotoOutput** error code.|
## VideoOutput ## VideoOutput
Implements output information used in a video recording session. Implements output information used in a video recording session. This class inherits from [CameraOutput](#cameraoutput).
### start ### start
...@@ -3576,6 +3643,54 @@ videoOutput.stop().then(() => { ...@@ -3576,6 +3643,54 @@ videoOutput.stop().then(() => {
}) })
``` ```
### release
release(callback: AsyncCallback<void\>): void
Releases output resources. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------- |
| callback | AsyncCallback<void\> | Yes | Callback used to return the result.|
**Example**
```js
videoOutput.release((err) => {
if (err) {
console.error(`Failed to release the PreviewOutput instance ${err.message}`);
return;
}
console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.');
});
```
### release
release(): Promise<void\>
Releases output resources. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Return value**
| Type | Description |
| -------------- | ----------------------- |
| Promise<void\>| Promise used to return the result.|
**Example**
```js
videoOutput.release().then(() => {
console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.');
})
```
### on('frameStart') ### on('frameStart')
on(type: 'frameStart', callback: AsyncCallback<void\>): void on(type: 'frameStart', callback: AsyncCallback<void\>): void
...@@ -3662,348 +3777,354 @@ Defines a video output error. ...@@ -3662,348 +3777,354 @@ Defines a video output error.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
| Name| Type | Description | | Name| Type | Mandatory | Description |
| ---- | ------------------------------------- | ----------------------- | | ---- | ------------------------------------- | ----------------- | ----------------------- |
| code | [PhotoOutputErrorCode](#photooutputerrorcode) | **VideoOutput** error code.| | code | [PhotoOutputErrorCode](#photooutputerrorcode) | Yes | **VideoOutput** error code.|
## MetadataObjectType
Enumerates metadata streams.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Value | Description |
| ------------------------- | ---- | ----------------- |
| FACE_DETECTION | 0 | Metadata object type.|
## Rect
Defines a rectangle.
**System capability**: SystemCapability.Multimedia.Camera.Core ## MetadataOutput
| Name | Type | Description |
| -------- | ------ | -------------------- |
| topLeftX | number | X-axis coordinate of the upper left corner of the rectangle. |
| topLeftY | number | Y-axis coordinate of the upper left corner of the rectangle. |
| width | number | Width of the rectangle. |
| height | number | Height of the rectangle. |
## MetadataObject
Implements camera metadata, which is the data source of **[CameraInput](#camerainput)**. Implements metadata streams. It inherits **[CameraOutput](#cameraoutput)**.
### getType ### start
getType(callback: AsyncCallback<MetadataObjectType\>): void start(callback: AsyncCallback<void\>): void
Obtains the metadata object type. This API uses an asynchronous callback to return the result. Starts to output metadata. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | --- | -------------------- | | -------- | ----------------------------------------------------------- | ---- | ------------------- |
| callback | AsyncCallback<[MetadataObjectType](#metadataobjecttype)\> | Yes | Callback used to return the result.| | callback | AsyncCallback<void\> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
metadataObject.getType((err, metadataObjectType) => { metadataOutput.start((err) => {
if (err) { if (err) {
console.error(`Failed to get type. ${err.message}`); console.error(`Failed to start metadataOutput. ${err.message}`);
return; return;
} }
console.log('Callback returned with an array of metadataObjectType.'); console.log('Callback returned with metadataOutput started.');
}) })
``` ```
### getType ### start
getType(): Promise<MetadataObjectType\> start(): Promise<void\>
Obtains the metadata object type. This API uses a promise to return the result. Starts to output metadata. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------------------- | --------------------------- | | ---------------------- | ------------------------ |
| Promise<[MetadataObjectType](#metadataobjecttype)\> | Promise used to return the result.| | Promise<void\> | Promise used to return the result.|
**Example** **Example**
```js ```js
metadataObject.getType().then((metadataObjectType) => { metadataOutput.start().then(() => {
console.log('Callback returned with an array of metadataObjectType.'); console.log('Callback returned with metadataOutput started.');
}) })
``` ```
### getTimestamp ### stop
getTimestamp(callback: AsyncCallback<number\>): void stop(callback: AsyncCallback<void\>): void
Obtains the metadata timestamp. This API uses an asynchronous callback to return the result. Stops outputting metadata. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------- | ---- | ------------------------ | | -------- | -------------------------- | ---- | ------------------- |
| callback | AsyncCallback<number\> | Yes | Callback used to return the result.| | callback | AsyncCallback<void\> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
metadataObject.getTimestamp((err,timestamp) => { metadataOutput.stop((err) => {
if (err) { if (err) {
console.error(`Failed to get timestamp. ${err.message}`); console.error(`Failed to stop the metadataOutput. ${err.message}`);
return; return;
} }
console.log('Callback returned with timestamp getted timestamp : ${timestamp}'); console.log('Callback returned with metadataOutput stopped.');
}) })
``` ```
### getTimestamp ### stop
getTimestamp(): Promise<number\> stop(): Promise<void\>
Obtains the metadata timestamp. This API uses a promise to return the result. Stops outputting metadata. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------- | --------------------------- | | ---------------------- | --------------------------- |
| Promise<number)\> | Promise used to return the result.| | Promise<void\> | Promise used to return the result.|
**Example** **Example**
```js ```js
metadataObject.getTimestamp().then((timestamp) => { metadataOutput.stop().then(() => {
console.log('Callback returned with timestamp getted timestamp : ${timestamp}'); console.log('Callback returned with metadataOutput stopped.');
}) })
``` ```
### getBoundingBox ### on('metadataObjectsAvailable')
getBoundingBox(callback: AsyncCallback<Rect\>): void on(type: 'metadataObjectsAvailable', callback: AsyncCallback<Array<MetadataObject\>\>): void
Obtains the bounding box of metadata. This API uses an asynchronous callback to return the result. Listens for metadata objects. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------- | ---- | ------------------------ | | -------- | ------------------------------------------------ | ---- | ------------------------------------ |
| callback | AsyncCallback<[Rect](#rect)\> | Yes | Callback used to return the result.| | type | string | Yes | Event type. The value is fixed at **'metadataObjectsAvailable'**, that is, the metadata object.|
| callback | Callback<Array<[MetadataObject](#metadataobject)\>\> | Yes | Callback used to return the error information. |
**Example** **Example**
```js ```js
metadataObject.getBoundingBox((err, rect) => { metadataOutput.on('metadataObjectsAvailable', (metadataObjectArr) => {
if (err) { console.log(`metadata output metadataObjectsAvailable`);
console.error(`Failed to get boundingBox. ${err.message}`);
return;
}
console.log('Callback returned with boundingBox getted.');
}) })
``` ```
### getBoundingBox ### on('error')
getBoundingBox(): Promise<Rect\> on(type: 'error', callback: ErrorCallback<MetadataOutputError\>): void
Obtains the bounding box of metadata. This API uses a promise to return the result. Listens for metadata errors. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Return value** **Parameters**
| Type | Description | | Name | Type | Mandatory| Description |
| ---------------------- | --------------------------- | | -------- | ------------------------------------------------ | ---- | --------------------------------------- |
| Promise<[Rect](#rect)\> | Promise used to return the result.| | type | string | Yes | Event type. The value is fixed at **'error'**, that is, the metadata error.|
| callback | Callback<[MetadataOutputError](#metadataoutputerror)\> | Yes | Callback used to return the error information. |
**Example** **Example**
```js ```js
metadataObject.getBoundingBox().then((rect) => { metadataOutput.on('error', (metadataOutputError) => {
console.log('Callback returned with boundingBox getted.'); console.log(`Metadata output error code: ${metadataOutputError.code}`);
}) })
``` ```
## MetadataFaceObject ## MetadataOutputErrorCode
Implements the face object of metadata. It inherits [MetadataObject](#metadataobject). Enumerates the codes used for metadata output errors.
## MetadataOutput **System capability**: SystemCapability.Multimedia.Camera.Core
Implements metadata streams. It inherits **[CameraOutput](#cameraoutput)**. | Name | Value | Description |
| ------------------------------- | ---- | -------- |
| ERROR_UNKNOWN | -1 | Unknown error.|
| ERROR_INSUFFICIENT_RESOURCES | 0 | Insufficient resources.|
### start ## MetadataOutputError
start(callback: AsyncCallback<void\>): void Defines a metadata output error.
Starts to output metadata. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core
| Name| Type | Mandatory | Description |
| ---- | ------------------------------------- | ----------------- | ----------------------- |
| code | [MetadataOutputErrorCode](#metadataoutputerrorcode) | Yes | **MetadataOutput** error code.|
## MetadataObjectType
Enumerates metadata streams.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Value | Description |
| ------------------------- | ---- | ----------------- |
| FACE_DETECTION | 0 | Metadata object type.|
## Rect
Defines a rectangle.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Mandatory | Description |
| -------- | ------ | --------------- | -------------------- |
| topLeftX | number | Yes | X-axis coordinate of the upper left corner of the rectangle. |
| topLeftY | number | Yes | Y-axis coordinate of the upper left corner of the rectangle. |
| width | number | Yes | Width of the rectangle. |
| height | number | Yes |Height of the rectangle. |
## MetadataObject
Implements camera metadata, which is the data source of [CameraInput](#camerainput). The metadata is obtained through metadataOutput.on('metadataObjectsAvailable').
### getType
getType(callback: AsyncCallback<MetadataObjectType\>): void
Obtains the metadata object type. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------- | ---- | ------------------- | | -------- | --------------------------------------------------------- | --- | -------------------- |
| callback | AsyncCallback<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback<[MetadataObjectType](#metadataobjecttype)\> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
metadataOutput.start((err) => { let metadataObject = metadataObjectArr[0];
metadataObject.getType((err, metadataObjectType) => {
if (err) { if (err) {
console.error(`Failed to start metadataOutput. ${err.message}`); console.error(`Failed to get type. ${err.message}`);
return; return;
} }
console.log('Callback returned with metadataOutput started.'); console.log('Callback returned with an array of metadataObjectType.');
}) })
``` ```
### start ### getType
start(): Promise<void\> getType(): Promise<MetadataObjectType\>
Starts to output metadata. This API uses a promise to return the result. Obtains the metadata object type. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | ------------------------ | | --------------------------------------------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.| | Promise<[MetadataObjectType](#metadataobjecttype)\> | Promise used to return the result.|
**Example** **Example**
```js ```js
metadataOutput.start().then(() => { let metadataObject = metadataObjectArr[0];
console.log('Callback returned with metadataOutput started.'); metadataObject.getType().then((metadataObjectType) => {
console.log('Callback returned with an array of metadataObjectType.');
}) })
``` ```
### stop ### getTimestamp
stop(callback: AsyncCallback<void\>): void getTimestamp(callback: AsyncCallback<number\>): void
Stops outputting metadata. This API uses an asynchronous callback to return the result. Obtains the metadata timestamp. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------- | ---- | ------------------- | | -------- | ----------------------------------------------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback<number\> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
metadataOutput.stop((err) => { let metadataObject = metadataObjectArr[0];
metadataObject.getTimestamp((err,timestamp) => {
if (err) { if (err) {
console.error(`Failed to stop the metadataOutput. ${err.message}`); console.error(`Failed to get timestamp. ${err.message}`);
return; return;
} }
console.log('Callback returned with metadataOutput stopped.'); console.log('Callback returned with timestamp getted timestamp : ${timestamp}');
}) })
``` ```
### stop ### getTimestamp
stop(): Promise<void\> getTimestamp(): Promise<number\>
Stops outputting metadata. This API uses a promise to return the result. Obtains the metadata timestamp. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | --------------------------- | | ---------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.| | Promise<number)\> | Promise used to return the result.|
**Example** **Example**
```js ```js
metadataOutput.stop().then(() => { let metadataObject = metadataObjectArr[0];
console.log('Callback returned with metadataOutput stopped.'); metadataObject.getTimestamp().then((timestamp) => {
console.log('Callback returned with timestamp getted timestamp : ${timestamp}');
}) })
``` ```
### on('metadataObjectsAvailable') ### getBoundingBox
on(type: 'metadataObjectsAvailable', callback: AsyncCallback<Array<MetadataObject\>\>): void getBoundingBox(callback: AsyncCallback<Rect\>): void
Listens for metadata objects. This API uses an asynchronous callback to return the result. Obtains the bounding box of metadata. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ------------------------------------ | | -------- | ----------------------------------------------------------- | ---- | ------------------------ |
| type | string | Yes | Event type. The value is fixed at **'metadataObjectsAvailable'**, that is, the metadata object.| | callback | AsyncCallback<[Rect](#rect)\> | Yes | Callback used to return the result.|
| callback | Callback<Array<[MetadataObject](#metadataobject)\>\> | Yes | Callback used to return the error information. |
**Example** **Example**
```js ```js
metadataOutput.on('metadataObjectsAvailable', (metadataObject) => { let metadataObject = metadataObjectArr[0];
console.log(`metadata output error code: ${metadataObject.code}`); metadataObject.getBoundingBox((err, rect) => {
if (err) {
console.error(`Failed to get boundingBox. ${err.message}`);
return;
}
console.log('Callback returned with boundingBox getted.');
}) })
``` ```
### on('error') ### getBoundingBox
on(type: 'error', callback: ErrorCallback<MetadataOutputError\>): void getBoundingBox(): Promise<Rect\>
Listens for metadata errors. This API uses an asynchronous callback to return the result. Obtains the bounding box of metadata. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters** **Return value**
| Name | Type | Mandatory| Description | | Type | Description |
| -------- | ------------------------------------------------ | ---- | --------------------------------------- | | ---------------------- | --------------------------- |
| type | string | Yes | Event type. The value is fixed at **'error'**, that is, the metadata error.| | Promise<[Rect](#rect)\> | Promise used to return the result.|
| callback | Callback<[MetadataOutputError](#metadataoutputerror)\> | Yes | Callback used to return the error information. |
**Example** **Example**
```js ```js
metadataOutput.on('error', (metadataOutputError) => { let metadataObject = metadataObjectArr[0];
console.log(`Metadata output error code: ${metadataOutputError.code}`); metadataObject.getBoundingBox().then((rect) => {
console.log('Callback returned with boundingBox getted.');
}) })
``` ```
## MetadataOutputErrorCode ## MetadataFaceObject
Enumerates the codes used for metadata output errors.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Value | Description |
| ------------------------------- | ---- | -------- |
| ERROR_UNKNOWN | -1 | Unknown error.|
| ERROR_INSUFFICIENT_RESOURCES | 0 | Insufficient resources.|
## MetadataOutputError
Defines a metadata output error.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name| Type | Description | Implements the face object of metadata. It inherits [MetadataObject](#metadataobject).
| ---- | ------------------------------------- | ----------------------- |
| code | [MetadataOutputErrorCode](#metadataoutputerrorcode) | **MetadataOutput** error code.|
# Vibrator # Vibrator
The **Vibrator** module provides APIs for triggering or stopping vibration. The **vibrator** module provides APIs for starting or stopping vibration.
> **NOTE** > **NOTE**
> >
...@@ -17,7 +17,7 @@ import vibrator from '@ohos.vibrator'; ...@@ -17,7 +17,7 @@ import vibrator from '@ohos.vibrator';
startVibration(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallback&lt;void&gt;): void startVibration(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallback&lt;void&gt;): void
Triggers vibration with the specified effect and attribute. This API uses a promise to return the result. Starts vibration with the specified effect and attribute. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.VIBRATE **Required permissions**: ohos.permission.VIBRATE
...@@ -29,35 +29,35 @@ Triggers vibration with the specified effect and attribute. This API uses a prom ...@@ -29,35 +29,35 @@ Triggers vibration with the specified effect and attribute. This API uses a prom
| --------- | -------------------------------------- | ---- | :--------------------------------------------------------- | | --------- | -------------------------------------- | ---- | :--------------------------------------------------------- |
| effect | [VibrateEffect](#vibrateeffect9) | Yes | Vibration effect. | | effect | [VibrateEffect](#vibrateeffect9) | Yes | Vibration effect. |
| attribute | [VibrateAttribute](#vibrateattribute9) | Yes | Vibration attribute. | | attribute | [VibrateAttribute](#vibrateattribute9) | Yes | Vibration attribute. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to the result. If the vibration starts, **err** is **undefined**. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the vibration starts, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes** **Error codes**
For details about the error codes, see [Vibrator Error Codes](../errorcodes/errorcode-vibrator.md). For details about the error codes, see [Vibrator Error Codes](../errorcodes/errorcode-vibrator.md).
| ID| Error Message | | ID| Error Message |
| -------- | ------------------------- | | -------- | ------------------------ |
| 14600101 | Device operation failed.| | 14600101 | Device operation failed. |
**Example** **Example**
```js ```js
try { try {
vibrator.startVibration({ vibrator.startVibration({
type:'time', type: 'time',
duration:1000, duration: 1000,
},{ }, {
id:0, id: 0,
usage: 'alarm' usage: 'alarm'
}, (error)=>{ }, (error) => {
if(error){ if (error) {
console.log('vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message); console.error('vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message);
}else{ return;
console.log('Callback returned to indicate a successful vibration.');
} }
console.log('Callback returned to indicate a successful vibration.');
}); });
} catch(err) { } catch (err) {
console.info('errCode: ' + err.code + ' ,msg: ' + err.message); console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
} }
``` ```
...@@ -65,7 +65,7 @@ try { ...@@ -65,7 +65,7 @@ try {
startVibration(effect: VibrateEffect, attribute: VibrateAttribute): Promise&lt;void&gt; startVibration(effect: VibrateEffect, attribute: VibrateAttribute): Promise&lt;void&gt;
Triggers vibration with the specified effect and attribute. This API uses a promise to return the result. Starts vibration with the specified effect and attribute. This API uses a promise to return the result.
**Required permissions**: ohos.permission.VIBRATE **Required permissions**: ohos.permission.VIBRATE
...@@ -88,27 +88,27 @@ Triggers vibration with the specified effect and attribute. This API uses a prom ...@@ -88,27 +88,27 @@ Triggers vibration with the specified effect and attribute. This API uses a prom
For details about the error codes, see [Vibrator Error Codes](../errorcodes/errorcode-vibrator.md). For details about the error codes, see [Vibrator Error Codes](../errorcodes/errorcode-vibrator.md).
| ID| Error Message | | ID| Error Message |
| -------- | ------------------------- | | -------- | ------------------------ |
| 14600101 | Device operation failed.| | 14600101 | Device operation failed. |
**Example** **Example**
```js ```js
try { try {
vibrator.startVibration({ vibrator.startVibration({
type: 'time', type: 'time',
duration: 1000 duration: 1000
}, { }, {
id: 0, id: 0,
usage: 'alarm' usage: 'alarm'
}).then(()=>{ }).then(() => {
console.log('Promise returned to indicate a successful vibration'); console.log('Promise returned to indicate a successful vibration');
}).catch((error)=>{ }, (error) => {
console.log('error.code' + error.code + 'error.message' + error.message); console.error('error.code' + error.code + 'error.message' + error.message);
}) });
} catch(err) { } catch (err) {
console.info('errCode: ' + err.code + ' ,msg: ' + err.message); console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
} }
``` ```
...@@ -116,7 +116,7 @@ try { ...@@ -116,7 +116,7 @@ try {
stopVibration(stopMode: VibratorStopMode, callback: AsyncCallback&lt;void&gt;): void stopVibration(stopMode: VibratorStopMode, callback: AsyncCallback&lt;void&gt;): void
Stops the vibration with the specified **stopMode**. This API uses a promise to return the result. If the specified **stopMode** is different from the mode used to trigger the vibration, this API fails to be called. Stops vibration in the specified mode. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.VIBRATE **Required permissions**: ohos.permission.VIBRATE
...@@ -127,21 +127,41 @@ Stops the vibration with the specified **stopMode**. This API uses a promise to ...@@ -127,21 +127,41 @@ Stops the vibration with the specified **stopMode**. This API uses a promise to
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------- | ---- | ------------------------------------------------------------ |
| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Mode to stop the vibration. | | stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Mode to stop the vibration. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to the result. If the vibration stops, **err** is **undefined**. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the vibration stops, **err** is **undefined**; otherwise, **err** is an error object.|
**Example** **Example**
```js ```js
try { try {
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){ // Start vibration at a fixed duration.
if(error){ vibrator.startVibration({
type: 'time',
duration: 1000,
}, {
id: 0,
usage: 'alarm'
}, (error) => {
if (error) {
console.error('vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message);
return;
}
console.log('Callback returned to indicate a successful vibration.');
});
} catch (err) {
console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
}
try {
// Stop vibration in VIBRATOR_STOP_MODE_TIME mode.
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message); console.log('error.code' + error.code + 'error.message' + error.message);
}else{ return;
console.log('Callback returned to indicate successful.');
} }
console.log('Callback returned to indicate successful.');
}) })
} catch(err) { } catch (err) {
console.info('errCode: ' + err.code + ' ,msg: ' + err.message); console.info('errCode: ' + err.code + ' ,msg: ' + err.message);
} }
``` ```
...@@ -149,7 +169,7 @@ try { ...@@ -149,7 +169,7 @@ try {
stopVibration(stopMode: VibratorStopMode): Promise&lt;void&gt; stopVibration(stopMode: VibratorStopMode): Promise&lt;void&gt;
Stops the vibration with the specified **stopMode**. This API uses a promise to return the result. If the specified **stopMode** is different from the mode used to trigger the vibration, this API fails to be called. Stops vibration in the specified mode. This API uses a promise to return the result.
**Required permissions**: ohos.permission.VIBRATE **Required permissions**: ohos.permission.VIBRATE
...@@ -171,25 +191,43 @@ Stops the vibration with the specified **stopMode**. This API uses a promise to ...@@ -171,25 +191,43 @@ Stops the vibration with the specified **stopMode**. This API uses a promise to
```js ```js
try { try {
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{ // Start vibration at a fixed duration.
console.log('Promise returned to indicate a successful vibration.'); vibrator.startVibration({
}, (error)=>{ type: 'time',
duration: 1000
}, {
id: 0,
usage: 'alarm'
}).then(() => {
console.log('Promise returned to indicate a successful vibration');
}, (error) => {
console.error('error.code' + error.code + 'error.message' + error.message);
});
} catch (err) {
console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
}
try {
// Stop vibration in VIBRATOR_STOP_MODE_TIME mode.
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(() => {
console.log('Promise returned to indicate a successful vibration.');
}, (error) => {
console.log('error.code' + error.code + 'error.message' + error.message); console.log('error.code' + error.code + 'error.message' + error.message);
}); });
} catch(err) { } catch (err) {
console.info('errCode: ' + err.code + ' ,msg: ' + err.message); console.info('errCode: ' + err.code + ' ,msg: ' + err.message);
} }
``` ```
## EffectId ## EffectId
Describes the vibration effect ID. Describes the preset vibration effect ID.
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
| Name | Default Value | Description | | Name | Value | Description |
| ------------------ | -------------------- | ------------------ | | ------------------ | -------------------- | -------------------------------- |
| EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Preset vibration effect ID.| | EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Vibration effect of the vibrator when a user adjusts the timer.|
## VibratorStopMode ## VibratorStopMode
...@@ -198,10 +236,10 @@ Enumerates the modes available to stop the vibration. ...@@ -198,10 +236,10 @@ Enumerates the modes available to stop the vibration.
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
| Name | Default Value | Description | | Name | Value | Description |
| ------------------------- | -------- | ------------------------------------------------------------ | | ------------------------- | -------- | ------------------------------ |
| VIBRATOR_STOP_MODE_TIME | "time" | The vibration to stop is in **duration** mode. This vibration is triggered with the parameter **duration** of the **number** type.| | VIBRATOR_STOP_MODE_TIME | "time" | The vibration to stop is in **duration** mode.|
| VIBRATOR_STOP_MODE_PRESET | "preset" | The vibration to stop is in **EffectId** mode. This vibration is triggered with the parameter **effectId** of the **EffectId** type.| | VIBRATOR_STOP_MODE_PRESET | "preset" | The vibration to stop is in **EffectId** mode.|
## VibrateEffect<sup>9+</sup> ## VibrateEffect<sup>9+</sup>
...@@ -220,7 +258,7 @@ Describes the vibration with the specified duration. ...@@ -220,7 +258,7 @@ Describes the vibration with the specified duration.
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
| Name | Default Value| Description | | Name | Value| Description |
| -------- | ------ | ------------------------------ | | -------- | ------ | ------------------------------ |
| type | "time" | Vibration with the specified duration.| | type | "time" | Vibration with the specified duration.|
| duration | - | Vibration duration, in ms. | | duration | - | Vibration duration, in ms. |
...@@ -231,7 +269,7 @@ Describes the vibration with a preset effect. ...@@ -231,7 +269,7 @@ Describes the vibration with a preset effect.
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
| Name | Default Value | Description | | Name | Value | Description |
| -------- | -------- | ------------------------------ | | -------- | -------- | ------------------------------ |
| type | "preset" | Vibration with the specified effect.| | type | "preset" | Vibration with the specified effect.|
| effectId | - | Preset vibration effect ID. | | effectId | - | Preset vibration effect ID. |
...@@ -243,7 +281,7 @@ Describes the vibration attribute. ...@@ -243,7 +281,7 @@ Describes the vibration attribute.
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
| Name | Default Value| Description | | Name | Value| Description |
| ----- | ------ | -------------- | | ----- | ------ | -------------- |
| id | 0 | Vibrator ID. | | id | 0 | Vibrator ID. |
| usage | - | Vibration scenario.| | usage | - | Vibration scenario.|
...@@ -293,9 +331,9 @@ This API is deprecated since API version 9. You are advised to use [vibrator.sta ...@@ -293,9 +331,9 @@ This API is deprecated since API version 9. You are advised to use [vibrator.sta
**Example** **Example**
```js ```js
vibrator.vibrate(1000).then(()=>{ vibrator.vibrate(1000).then(() => {
console.log('Promise returned to indicate a successful vibration.'); console.log('Promise returned to indicate a successful vibration.');
}, (error)=>{ }, (error) => {
console.log('error.code' + error.code + 'error.message' + error.message); console.log('error.code' + error.code + 'error.message' + error.message);
}); });
``` ```
...@@ -317,15 +355,15 @@ This API is deprecated since API version 9. You are advised to use [vibrator.sta ...@@ -317,15 +355,15 @@ This API is deprecated since API version 9. You are advised to use [vibrator.sta
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------------------------------------------------------- | | -------- | ------------------------- | ---- | ---------------------------------------------------------- |
| duration | number | Yes | Vibration duration, in ms. | | duration | number | Yes | Vibration duration, in ms. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to the result. If the vibration starts, **err** is **undefined**. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | No | Callback used to return the result. If the vibration starts, **err** is **undefined**; otherwise, **err** is an error object.|
**Example** **Example**
```js ```js
vibrator.vibrate(1000,function(error){ vibrator.vibrate(1000, function (error) {
if(error){ if (error) {
console.log('error.code' + error.code + 'error.message' + error.message); console.log('error.code' + error.code + 'error.message' + error.message);
}else{ } else {
console.log('Callback returned to indicate a successful vibration.'); console.log('Callback returned to indicate a successful vibration.');
} }
}) })
...@@ -359,9 +397,9 @@ This API is deprecated since API version 9. You are advised to use [vibrator.sta ...@@ -359,9 +397,9 @@ This API is deprecated since API version 9. You are advised to use [vibrator.sta
**Example** **Example**
```js ```js
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{ vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(() => {
console.log('Promise returned to indicate a successful vibration.'); console.log('Promise returned to indicate a successful vibration.');
}, (error)=>{ }, (error) => {
console.log('error.code' + error.code + 'error.message' + error.message); console.log('error.code' + error.code + 'error.message' + error.message);
}); });
``` ```
...@@ -384,15 +422,15 @@ This API is deprecated since API version 9. You are advised to use [vibrator.sta ...@@ -384,15 +422,15 @@ This API is deprecated since API version 9. You are advised to use [vibrator.sta
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------------------------------------------------------- | | -------- | ------------------------- | ---- | ---------------------------------------------------------- |
| effectId | [EffectId](#effectid) | Yes | Preset vibration effect ID. | | effectId | [EffectId](#effectid) | Yes | Preset vibration effect ID. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to the result. If the vibration starts, **err** is **undefined**. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | No | Callback used to return the result. If the vibration starts, **err** is **undefined**; otherwise, **err** is an error object.|
**Example** **Example**
```js ```js
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){ vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function (error) {
if(error){ if (error) {
console.log('error.code' + error.code + 'error.message' + error.message); console.log('error.code' + error.code + 'error.message' + error.message);
}else{ } else {
console.log('Callback returned to indicate a successful vibration.'); console.log('Callback returned to indicate a successful vibration.');
} }
}) })
...@@ -402,7 +440,7 @@ vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){ ...@@ -402,7 +440,7 @@ vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){
stop(stopMode: VibratorStopMode): Promise&lt;void&gt; stop(stopMode: VibratorStopMode): Promise&lt;void&gt;
Stops the vibration with the specified **stopMode**. This API uses a promise to return the result. If the specified **stopMode** is different from the mode used to trigger the vibration, this API fails to be called. Stops vibration in the specified mode. This API uses a promise to return the result.
This API is deprecated since API version 9. You are advised to use [vibrator.stopVibration](#vibratorstopvibration9-1) instead. This API is deprecated since API version 9. You are advised to use [vibrator.stopVibration](#vibratorstopvibration9-1) instead.
...@@ -425,9 +463,18 @@ This API is deprecated since API version 9. You are advised to use [vibrator.sto ...@@ -425,9 +463,18 @@ This API is deprecated since API version 9. You are advised to use [vibrator.sto
**Example** **Example**
```js ```js
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{ // Start vibration based on the specified effect ID.
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
} else {
console.log('Callback returned to indicate a successful vibration.');
}
})
// Stop vibration in VIBRATOR_STOP_MODE_PRESET mode.
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(() => {
console.log('Promise returned to indicate a successful vibration.'); console.log('Promise returned to indicate a successful vibration.');
}, (error)=>{ }, (error) => {
console.log('error.code' + error.code + 'error.message' + error.message); console.log('error.code' + error.code + 'error.message' + error.message);
}); });
``` ```
...@@ -437,7 +484,7 @@ vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{ ...@@ -437,7 +484,7 @@ vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{
stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void
Stops the vibration with the specified **stopMode**. This API uses a promise to return the result. If the specified **stopMode** is different from the mode used to trigger the vibration, this API fails to be called. Stops vibration in the specified mode. This API uses an asynchronous callback to return the result.
This API is deprecated since API version 9. You are advised to use [vibrator.stopVibration](#vibratorstopvibration9) instead. This API is deprecated since API version 9. You are advised to use [vibrator.stopVibration](#vibratorstopvibration9) instead.
...@@ -450,15 +497,24 @@ This API is deprecated since API version 9. You are advised to use [vibrator.sto ...@@ -450,15 +497,24 @@ This API is deprecated since API version 9. You are advised to use [vibrator.sto
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------- | ---- | ------------------------------------------------------------ |
| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Mode to stop the vibration. | | stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Mode to stop the vibration. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to the result. If the vibration stops, **err** is **undefined**. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | No | Callback used to return the result. If the vibration stops, **err** is **undefined**; otherwise, **err** is an error object.|
**Example** **Example**
```js ```js
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){ // Start vibration based on the specified effect ID.
if(error){ vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
} else {
console.log('Callback returned to indicate a successful vibration.');
}
})
// Stop vibration in VIBRATOR_STOP_MODE_PRESET mode.
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message); console.log('error.code' + error.code + 'error.message' + error.message);
}else{ } else {
console.log('Callback returned to indicate successful.'); console.log('Callback returned to indicate successful.');
} }
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册