提交 a998a7ca 编写于 作者: W wusongqing

update docs against 6864

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 6c623538
# Image Processing # Image Processing
The **Image** module provides APIs for image processing. You can use the APIs to create a **PixelMap** object with specified properties or read image pixel data (even in an area).
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -35,7 +37,7 @@ Creates a **PixelMap** object. This API uses a promise to return the result. ...@@ -35,7 +37,7 @@ Creates a **PixelMap** object. This API uses a promise to return the result.
```js ```js
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color); let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts) image.createPixelMap(color, opts)
.then((pixelmap) => { .then((pixelmap) => {
...@@ -62,7 +64,7 @@ Creates a **PixelMap** object. This API uses an asynchronous callback to return ...@@ -62,7 +64,7 @@ Creates a **PixelMap** object. This API uses an asynchronous callback to return
```js ```js
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color); let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (pixelmap) => { image.createPixelMap(color, opts, (pixelmap) => {
}) })
...@@ -78,7 +80,7 @@ Provides APIs to read or write image pixel map data and obtain image pixel map i ...@@ -78,7 +80,7 @@ Provides APIs to read or write image pixel map data and obtain image pixel map i
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ---------- | ------- | ---- | ---- | -------------------------- | | ---------- | ------- | ---- | ---- | -------------------------- |
| isEditable<sup>7+</sup> | boolean | Yes | No | Whether the image pixel map is editable.| | isEditable | boolean | Yes | No | Whether the image pixel map is editable.|
### readPixelsToBuffer<sup>7+</sup> ### readPixelsToBuffer<sup>7+</sup>
...@@ -92,7 +94,7 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u ...@@ -92,7 +94,7 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ----------- | ---- | ----------------------------------------------------------------------------------------------------- | | ------ | ----------- | ---- | ----------------------------------------------------------------------------------------------------- |
| dst | ArrayBuffer | Yes | Buffer to which the image pixel map data will be written. | | dst | ArrayBuffer | Yes | Buffer to which the image pixel map data will be written. The buffer size is obtained by calling **getPixelBytesNumber**.|
**Return value** **Return value**
...@@ -123,7 +125,7 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u ...@@ -123,7 +125,7 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ----------------------------------------------------------------------------------------------------- | | -------- | -------------------- | ---- | ----------------------------------------------------------------------------------------------------- |
| dst | ArrayBuffer | Yes | Buffer to which the image pixel map data will be written.| | dst | ArrayBuffer | Yes | Buffer to which the image pixel map data will be written. The buffer size is obtained by calling **getPixelBytesNumber**.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned. | | callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned. |
**Example** **Example**
...@@ -189,7 +191,7 @@ Reads image pixel map data in an area. This API uses an asynchronous callback to ...@@ -189,7 +191,7 @@ Reads image pixel map data in an area. This API uses an asynchronous callback to
```js ```js
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color); let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => { image.createPixelMap(color, opts, (err, pixelmap) => {
if(pixelmap == undefined){ if(pixelmap == undefined){
...@@ -230,7 +232,7 @@ Writes image pixel map data to an area. This API uses a promise to return the op ...@@ -230,7 +232,7 @@ Writes image pixel map data to an area. This API uses a promise to return the op
```js ```js
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color); let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts) image.createPixelMap(color, opts)
.then( pixelmap => { .then( pixelmap => {
...@@ -318,7 +320,7 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj ...@@ -318,7 +320,7 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj
```js ```js
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
const pixelMap = new ArrayBuffer(400); const pixelMap = new ArrayBuffer(400);
let bufferArr = new Unit8Array(color); let bufferArr = new Uint8Array(color);
pixelMap.writeBufferToPixels(color).then(() => { pixelMap.writeBufferToPixels(color).then(() => {
console.log("Succeeded in writing data from a buffer to a PixelMap."); console.log("Succeeded in writing data from a buffer to a PixelMap.");
}).catch((err) => { }).catch((err) => {
...@@ -346,7 +348,7 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj ...@@ -346,7 +348,7 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj
```js ```js
const color = new ArrayBuffer(96);\ const color = new ArrayBuffer(96);\
const pixelMap = new ArrayBuffer(400); const pixelMap = new ArrayBuffer(400);
let bufferArr = new Unit8Array(color); let bufferArr = new Uint8Array(color);
pixelMap.writeBufferToPixels(color, function(err) { pixelMap.writeBufferToPixels(color, function(err) {
if (err) { if (err) {
console.error("Failed to write data from a buffer to a PixelMap."); console.error("Failed to write data from a buffer to a PixelMap.");
...@@ -400,7 +402,7 @@ Obtains pixel map information of this image. This API uses an asynchronous callb ...@@ -400,7 +402,7 @@ Obtains pixel map information of this image. This API uses an asynchronous callb
```js ```js
pixelmap.getImageInfo((imageInfo) => { pixelmap.getImageInfo((imageInfo) => {
console.log("Succeeded in obtaining the image pixel map information.."); console.log("Succeeded in obtaining the image pixel map information.");
}) })
``` ```
...@@ -422,7 +424,7 @@ Obtains the number of bytes per row of this image pixel map. ...@@ -422,7 +424,7 @@ Obtains the number of bytes per row of this image pixel map.
```js ```js
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color); let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err,pixelmap) => { image.createPixelMap(color, opts, (err,pixelmap) => {
let rowCount = pixelmap.getBytesNumberPerRow(); let rowCount = pixelmap.getBytesNumberPerRow();
...@@ -467,7 +469,7 @@ Releases this **PixelMap** object. This API uses a promise to return the result. ...@@ -467,7 +469,7 @@ Releases this **PixelMap** object. This API uses a promise to return the result.
```js ```js
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color); let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (pixelmap) => { image.createPixelMap(color, opts, (pixelmap) => {
pixelmap.release().then(() => { pixelmap.release().then(() => {
...@@ -496,7 +498,7 @@ Releases this **PixelMap** object. This API uses an asynchronous callback to ret ...@@ -496,7 +498,7 @@ Releases this **PixelMap** object. This API uses an asynchronous callback to ret
```js ```js
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color); let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (pixelmap) => { image.createPixelMap(color, opts, (pixelmap) => {
pixelmap.release().then(() => { pixelmap.release().then(() => {
...@@ -1010,7 +1012,7 @@ imagePackerApi.packing(pixelMapApi, packOpts) ...@@ -1010,7 +1012,7 @@ imagePackerApi.packing(pixelMapApi, packOpts)
.then( data => { .then( data => {
console.log('Succeeded in packing the image.'); console.log('Succeeded in packing the image.');
}).catch(error => { }).catch(error => {
console.log('Failed to pack the image..'); console.log('Failed to pack the image.');
}) })
``` ```
...@@ -1117,7 +1119,7 @@ Defines pixel map initialization options. ...@@ -1117,7 +1119,7 @@ Defines pixel map initialization options.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ------------------------ | ---------------------------------- | ---- | ---- | -------------- | | ------------------------ | ---------------------------------- | ---- | ---- | -------------- |
| alphaType<sup>9+</sup> | [AlphaType](#alphatype9) | Yes | Yes | Alpha type. | | editable | boolean | Yes | Yes | Whether the image is editable. |
| pixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel map format. | | pixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel map format. |
| size | [Size](#size) | Yes | Yes | Image size.| | size | [Size](#size) | Yes | Yes | Image size.|
...@@ -1173,7 +1175,7 @@ Describes image properties. ...@@ -1173,7 +1175,7 @@ Describes image properties.
## PropertyKey<sup>7+</sup> ## PropertyKey<sup>7+</sup>
Describes the exchangeable image file format (Exif) information of an image. Describes the exchangeable image file format (EXIF) information of an image.
**System capability**: SystemCapability.Multimedia.Image.Core **System capability**: SystemCapability.Multimedia.Image.Core
...@@ -1213,7 +1215,7 @@ Enumerates the response codes returned upon build errors. ...@@ -1213,7 +1215,7 @@ Enumerates the response codes returned upon build errors.
| ERR_IMAGE_CROP | 62980109 | An error occurs during image cropping. | | ERR_IMAGE_CROP | 62980109 | An error occurs during image cropping. |
| ERR_IMAGE_SOURCE_DATA | 62980110 | The image source data is incorrect. | | ERR_IMAGE_SOURCE_DATA | 62980110 | The image source data is incorrect. |
| ERR_IMAGE_SOURCE_DATA_INCOMPLETE | 62980111 | The image source data is incomplete. | | ERR_IMAGE_SOURCE_DATA_INCOMPLETE | 62980111 | The image source data is incomplete. |
| ERR_IMAGE_MISMATCHED_FORMAT | 62980112 | The image format does not match. | | ERR_IMAGE_MISMATCHED_FORMAT | 62980112 | The image formats do not match. |
| ERR_IMAGE_UNKNOWN_FORMAT | 62980113 | Unknown image format. | | ERR_IMAGE_UNKNOWN_FORMAT | 62980113 | Unknown image format. |
| ERR_IMAGE_SOURCE_UNRESOLVED | 62980114 | The image source is not parsed. | | ERR_IMAGE_SOURCE_UNRESOLVED | 62980114 | The image source is not parsed. |
| ERR_IMAGE_INVALID_PARAMETER | 62980115 | Invalid image parameter. | | ERR_IMAGE_INVALID_PARAMETER | 62980115 | Invalid image parameter. |
...@@ -1229,4 +1231,4 @@ Enumerates the response codes returned upon build errors. ...@@ -1229,4 +1231,4 @@ Enumerates the response codes returned upon build errors.
| ERR_IMAGE_READ_PIXELMAP_FAILED | 62980246 | Failed to read the pixel map. | | ERR_IMAGE_READ_PIXELMAP_FAILED | 62980246 | Failed to read the pixel map. |
| ERR_IMAGE_WRITE_PIXELMAP_FAILED | 62980247 | Failed to write the pixel map. | | ERR_IMAGE_WRITE_PIXELMAP_FAILED | 62980247 | Failed to write the pixel map. |
| ERR_IMAGE_PIXELMAP_NOT_ALLOW_MODIFY | 62980248 | Modification to the pixel map is not allowed. | | ERR_IMAGE_PIXELMAP_NOT_ALLOW_MODIFY | 62980248 | Modification to the pixel map is not allowed. |
| ERR_IMAGE_CONFIG_FAILED | 62980259 | The software parameter setting is incorrect. | | ERR_IMAGE_CONFIG_FAILED | 62980259 | The configuration is incorrect. |
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
> >
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The multimedia subsystem provides a set of simple and easy-to-use APIs for you to access the system and use media resources. The multimedia subsystem provides a set of simple and easy-to-use APIs for you to access the system and use media resources.
This subsystem offers various media services covering audio and video, which provide the following capabilities: This subsystem offers various media services covering audio and video, which provide the following capabilities:
...@@ -105,6 +106,7 @@ media.createVideoPlayer().then((video) => { ...@@ -105,6 +106,7 @@ media.createVideoPlayer().then((video) => {
createAudioRecorder(): AudioRecorder createAudioRecorder(): AudioRecorder
Creates an **AudioRecorder** instance to control audio recording. Creates an **AudioRecorder** instance to control audio recording.
Only one **AudioRecorder** instance can be created for a device.
**System capability**: SystemCapability.Multimedia.Media.AudioRecorder **System capability**: SystemCapability.Multimedia.Media.AudioRecorder
...@@ -214,7 +216,7 @@ For details about the audio playback demo, see [Audio Playback Development](../. ...@@ -214,7 +216,7 @@ For details about the audio playback demo, see [Audio Playback Development](../.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ----------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | | ----------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
| src | string | Yes | Yes | Audio media URI. The mainstream audio formats (MPEG-4, AAC, MPEG-3, OGG, and WAV) are supported.<br>**Example of supported URIs**:<br>1. FD playback: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP network playback: http://xx<br>3. HLS network playback: under development<br>**Note**:<br>To use media materials, you must declare the read permission. Otherwise, the media materials cannot be played properly. | | src | string | Yes | Yes | Audio media URL. The mainstream video formats (MPEG-4, MPEG-TS, WebM, and MKV) are supported.<br>**Example of supported URIs**:<br>1. FD playback: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP network playback: http://xx<br>3. HTTPS network playback: https://xx<br>4. HLS network playback: http://xx or https://xx<br>**Note**:<br>To use media materials, you must declare the read permission. Otherwise, the media materials cannot be played properly.|
| loop | boolean | Yes | Yes | Whether to loop audio playback. The value **true** means to loop audio playback, and **false** means the opposite. | | loop | boolean | Yes | Yes | Whether to loop audio playback. The value **true** means to loop audio playback, and **false** means the opposite. |
| currentTime | number | Yes | No | Current audio playback position. | | currentTime | number | Yes | No | Current audio playback position. |
| duration | number | Yes | No | Audio duration. | | duration | number | Yes | No | Audio duration. |
...@@ -606,7 +608,7 @@ For details about the video playback demo, see [Video Playback Development](../. ...@@ -606,7 +608,7 @@ For details about the video playback demo, see [Video Playback Development](../.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ------------------------ | ---------------------------------- | ---- | ---- | ------------------------------------------------------------ | | ------------------------ | ---------------------------------- | ---- | ---- | ------------------------------------------------------------ |
| url<sup>8+</sup> | string | Yes | Yes | Video media URL. The mainstream video formats (MPEG-4, MPEG-TS, WebM, and MKV) are supported.<br>**Example of supported URIs**:<br>1. FD playback: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP network playback: http://xx<br>3. HLS network playback: under development<br>**Note**:<br>To use media materials, you must declare the read permission. Otherwise, the media materials cannot be played properly. | | url<sup>8+</sup> | string | Yes | Yes | Video media URL. The mainstream video formats (MPEG-4, MPEG-TS, WebM, and MKV) are supported.<br>**Example of supported URIs**:<br>1. FD playback: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP network playback: http://xx<br>3. HTTPS network playback: https://xx<br>4. HLS network playback: http://xx or https://xx<br>**Note**:<br>To use media materials, you must declare the read permission. Otherwise, the media materials cannot be played properly.|
| loop<sup>8+</sup> | boolean | Yes | Yes | Whether to loop video playback. The value **true** means to loop video playback, and **false** means the opposite. | | loop<sup>8+</sup> | boolean | Yes | Yes | Whether to loop video playback. The value **true** means to loop video playback, and **false** means the opposite. |
| currentTime<sup>8+</sup> | number | Yes | No | Current video playback position. | | currentTime<sup>8+</sup> | number | Yes | No | Current video playback position. |
| duration<sup>8+</sup> | number | Yes | No | Video duration. The value **-1** indicates the live streaming mode. | | duration<sup>8+</sup> | number | Yes | No | Video duration. The value **-1** indicates the live streaming mode. |
...@@ -1604,7 +1606,7 @@ Subscribes to the audio recording events. ...@@ -1604,7 +1606,7 @@ Subscribes to the audio recording events.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------------------------------------------ | | -------- | -------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The following events are supported: 'prepare'\|'start'\| 'pause' \| 'resume' \|'stop'\|'release'\|'reset'<br>- The 'prepare' event is triggered when the [prepare](#audiorecorder_prepare) API is called and the audio recording parameters are set.<br>- The 'start' event is triggered when the [start](#audiorecorder_start) API is called and audio recording starts.<br>- The 'pause' event is triggered when the [pause](#audiorecorder_pause) API is called and audio recording is paused.<br>- The 'resume' event is triggered when the [resume](#audiorecorder_resume) API is called and audio recording is resumed.<br>- The 'stop' event is triggered when the [stop](#audiorecorder_stop) API is called and audio recording stops.<br>- The 'release' event is triggered when the [release](#audiorecorder_release) API is called and the recording resource is released.<br>- The 'reset' event is triggered when the [reset](#audiorecorder_reset) API is called and audio recording is reset.| | type | string | Yes | Event type. The following events are supported:<br>- 'prepare': triggered when the [prepare](#audiorecorder_prepare) API is called and the audio recording parameters are set.<br>- 'start': triggered when the [start](#audiorecorder_start) API is called and audio recording starts.<br>- 'pause': triggered when the [pause](#audiorecorder_pause) API is called and audio recording is paused.<br>- 'resume': triggered when the [resume](#audiorecorder_resume) API is called and audio recording is resumed.<br>- 'stop': triggered when the [stop](#audiorecorder_stop) API is called and audio recording stops.<br>- 'release': triggered when the [release](#audiorecorder_release) API is called and the recording resource is released.<br>- 'reset': triggered when the [reset](#audiorecorder_reset) API is called and audio recording is reset. |
| callback | ()=>void | Yes | Callback invoked when the event is triggered. | | callback | ()=>void | Yes | Callback invoked when the event is triggered. |
**Example** **Example**
...@@ -1620,34 +1622,34 @@ let audioRecorderConfig = { ...@@ -1620,34 +1622,34 @@ let audioRecorderConfig = {
uri : 'fd://xx', // The file must be created by the caller and granted with proper permissions. uri : 'fd://xx', // The file must be created by the caller and granted with proper permissions.
location : { latitude : 30, longitude : 130}, location : { latitude : 30, longitude : 130},
} }
audioRecorder.on('error', (error) => { // Set the error event callback. audioRecorder.on('error', (error) => { // Set the 'error' event callback.
console.info(`audio error called, errName is ${error.name}`); console.info(`audio error called, errName is ${error.name}`);
console.info(`audio error called, errCode is ${error.code}`); console.info(`audio error called, errCode is ${error.code}`);
console.info(`audio error called, errMessage is ${error.message}`); console.info(`audio error called, errMessage is ${error.message}`);
}); });
audioRecorder.on('prepare', () => { // Set the prepare event callback. audioRecorder.on('prepare', () => { // Set the 'prepare' event callback.
console.log('prepare success'); console.log('prepare success');
audioRecorder.start(); // Start recording and trigger the start event callback. audioRecorder.start(); // Start recording and trigger the 'start' event callback.
}); });
audioRecorder.on('start', () => { // Set the start event callback. audioRecorder.on('start', () => { // Set the 'start' event callback.
console.log('audio recorder start success'); console.log('audio recorder start success');
}); });
audioRecorder.on('pause', () => { // Set the pause event callback. audioRecorder.on('pause', () => { // Set the 'pause' event callback.
console.log('audio recorder pause success'); console.log('audio recorder pause success');
}); });
audioRecorder.on('resume', () => { // Set the resume event callback. audioRecorder.on('resume', () => { // Set the 'resume' event callback.
console.log('audio recorder resume success'); console.log('audio recorder resume success');
}); });
audioRecorder.on('stop', () => { // Set the stop event callback. audioRecorder.on('stop', () => { // Set the 'stop' event callback.
console.log('audio recorder stop success'); console.log('audio recorder stop success');
}); });
audioRecorder.on('release', () => { // Set the release event callback. audioRecorder.on('release', () => { // Set the 'release' event callback.
console.log('audio recorder release success'); console.log('audio recorder release success');
}); });
audioRecorder.on('reset', () => { // Set the reset event callback. audioRecorder.on('reset', () => { // Set the 'reset' event callback.
console.log('audio recorder reset success'); console.log('audio recorder reset success');
}); });
audioRecorder.prepare(audioRecorderConfig) // Set recording parameters and trigger the prepare event callback. audioRecorder.prepare(audioRecorderConfig) // Set recording parameters and trigger the 'prepare' event callback.
``` ```
### on('error') ### on('error')
...@@ -1668,12 +1670,12 @@ Subscribes to the audio recording error event. ...@@ -1668,12 +1670,12 @@ Subscribes to the audio recording error event.
**Example** **Example**
```js ```js
audioRecorder.on('error', (error) => { // Set the error event callback. audioRecorder.on('error', (error) => { // Set the 'error' event callback.
console.info(`audio error called, errName is ${error.name}`); // Print the error name. console.info(`audio error called, errName is ${error.name}`); // Print the error name.
console.info(`audio error called, errCode is ${error.code}`); // Print the error code. console.info(`audio error called, errCode is ${error.code}`); // Print the error code.
console.info(`audio error called, errMessage is ${error.message}`); // Print the detailed description of the error type. console.info(`audio error called, errMessage is ${error.message}`); // Print the detailed description of the error type.
}); });
audioRecorder.prepare(); // Do no set any parameter in prepare and trigger the error event callback. audioRecorder.prepare(); // Do no set any parameter in prepare and trigger the 'error' event callback.
``` ```
## AudioRecorderConfig ## AudioRecorderConfig
...@@ -1690,7 +1692,7 @@ Describes audio recording configurations. ...@@ -1690,7 +1692,7 @@ Describes audio recording configurations.
| numberOfChannels | number | No | Number of audio channels. The default value is **2**. | | numberOfChannels | number | No | Number of audio channels. The default value is **2**. |
| format<sup>(deprecated)</sup> | [AudioOutputFormat](#audiooutputformat) | No | Audio output format. The default value is **MPEG_4**.<br>**Note**: This parameter is deprecated since API version 8. Use **fileFormat** instead. | | format<sup>(deprecated)</sup> | [AudioOutputFormat](#audiooutputformat) | No | Audio output format. The default value is **MPEG_4**.<br>**Note**: This parameter is deprecated since API version 8. Use **fileFormat** instead. |
| location | [Location](#location) | No | Geographical location of the recorded audio. | | location | [Location](#location) | No | Geographical location of the recorded audio. |
| uri | string | Yes | Audio output URI. Supported: fd://xx (fd number)<br>![](figures/en-us_image_url.png) <br>The file must be created by the caller and granted with proper permissions.| | uri | string | Yes | Audio output URI. Supported: fd://xx (fd number)<br>![](figures/en-us_image_url.png)<br>The file must be created by the caller and granted with proper permissions.|
| audioEncoderMime<sup>8+</sup> | [CodecMimeType](#codecmimetype8) | No | Audio encoding format. | | audioEncoderMime<sup>8+</sup> | [CodecMimeType](#codecmimetype8) | No | Audio encoding format. |
| fileFormat<sup>8+</sup> | [ContainerFormatType](#containerformattype8) | No | Audio encoding format. | | fileFormat<sup>8+</sup> | [ContainerFormatType](#containerformattype8) | No | Audio encoding format. |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册