提交 15dae40e 编写于 作者: G Gloria

Update docs against 11422+11948+11965+12111+11367

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 1eddd8d7
......@@ -2,11 +2,11 @@
## Introduction
You can use audio playback APIs to convert audio data into audible analog signals and play the signals using output devices. You can also manage playback tasks. For example, you can start, suspend, stop playback, release resources, set the volume, seek to a playback position, and obtain track information.
You can use audio playback APIs to convert audio data into audible analog signals and play the signals using output devices. You can also manage playback tasks. For example, you can control the playback and volume, obtain track information, and release resources.
## Working Principles
The following figures show the audio playback status changes and the interaction with external modules for audio playback.
The following figures show the audio playback state transition and the interaction with external modules for audio playback.
**Figure 1** Audio playback state transition
......@@ -28,7 +28,7 @@ For details about the APIs, see [AudioPlayer in the Media API](../reference/apis
> **NOTE**
>
> The method for obtaining the path in the FA model is different from that in the stage model. **pathDir** used in the sample code below is an example. You need to obtain the path based on project requirements. For details about how to obtain the path, see [Application Sandbox Path Guidelines](../reference/apis/js-apis-fileio.md#guidelines).
> The method for obtaining the path in the FA model is different from that in the stage model. For details about how to obtain the path, see [Application Sandbox Path Guidelines](../reference/apis/js-apis-fileio.md#guidelines).
### Full-Process Scenario
......@@ -109,7 +109,7 @@ async function audioPlayerDemo() {
setCallBack(audioPlayer); // Set the event callbacks.
// 2. Set the URI of the audio file.
let fdPath = 'fd://'
let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements.
let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => {
......@@ -151,7 +151,7 @@ export class AudioDemo {
let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance.
this.setCallBack(audioPlayer); // Set the event callbacks.
let fdPath = 'fd://'
let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements.
let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => {
......@@ -199,7 +199,7 @@ export class AudioDemo {
async nextMusic(audioPlayer) {
this.isNextMusic = true;
let nextFdPath = 'fd://'
let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements.
let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\02.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
let nextpath = pathDir + '/02.mp3'
await fileIO.open(nextpath).then((fdNumber) => {
......@@ -217,7 +217,7 @@ export class AudioDemo {
let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance.
this.setCallBack(audioPlayer); // Set the event callbacks.
let fdPath = 'fd://'
let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements.
let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => {
......@@ -256,7 +256,7 @@ export class AudioDemo {
let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance.
this.setCallBack(audioPlayer); // Set the event callbacks.
let fdPath = 'fd://'
let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements.
let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => {
......
# Media
> **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 multimedia subsystem provides a set of simple and easy-to-use APIs for you to access the system and use media resources.
......@@ -52,7 +53,7 @@ Creates a **VideoPlayer** instance. This API uses an asynchronous callback to re
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ------------------------------ |
| callback | AsyncCallback<[VideoPlayer](#videoplayer8)> | Yes | Callback used to return the result. If the operation is successful, the **VideoPlayer** instance is returned; otherwise, **null** is returned. The instance can be used to manage and play video media.|
| callback | AsyncCallback<[VideoPlayer](#videoplayer8)> | Yes | Callback used to return the result. If the operation is successful, the **VideoPlayer** instance is returned; otherwise, **null** is returned. The instance can be used to manage and play video.|
**Example**
......@@ -81,7 +82,7 @@ Creates a **VideoPlayer** instance. This API uses a promise to return the result
| Type | Description |
| ------------------------------------- | ------------------------------------------------------------ |
| Promise<[VideoPlayer](#videoplayer8)> | Promise used to return the result. If the operation is successful, the **VideoPlayer** instance is returned; otherwise, **null** is returned. The instance can be used to manage and play video media.|
| Promise<[VideoPlayer](#videoplayer8)> | Promise used to return the result. If the operation is successful, the **VideoPlayer** instance is returned; otherwise, **null** is returned. The instance can be used to manage and play video.|
**Example**
......@@ -113,7 +114,7 @@ Only one **AudioRecorder** instance can be created per device.
| Type | Description |
| ------------------------------- | ------------------------------------------------------------ |
| [AudioRecorder](#audiorecorder) | Returns the **AudioRecorder** instance if the operation is successful; returns **null** otherwise. The instance can be used to record audio media.|
| [AudioRecorder](#audiorecorder) | Returns the **AudioRecorder** instance if the operation is successful; returns **null** otherwise. The instance can be used to record audio.|
**Example**
......@@ -130,11 +131,21 @@ Only one **AudioRecorder** instance can be created per device.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | ------------------------------ |
| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | Yes | Callback used to return the result. If the operation is successful, the **VideoRecorder** instance is returned; otherwise, **null** is returned. The instance can be used to record video media.|
| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | Yes | Callback used to return the result. If the operation is successful, the **VideoRecorder** instance is returned; otherwise, **null** is returned. The instance can be used to record video.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | ------------------------------ |
| 5400101 | No memory. Return by callback. |
**Example**
......@@ -160,11 +171,21 @@ Only one **AudioRecorder** instance can be created per device.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Return value**
| Type | Description |
| ----------------------------------------- | ------------------------------------------------------------ |
| Promise<[VideoRecorder](#videorecorder9)> | Promise used to return the result. If the operation is successful, the **VideoRecorder** instance is returned; otherwise, **null** is returned. The instance can be used to record video media.|
| Promise<[VideoRecorder](#videorecorder9)> | Promise used to return the result. If the operation is successful, the **VideoRecorder** instance is returned; otherwise, **null** is returned. The instance can be used to record video.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | ----------------------------- |
| 5400101 | No memory. Return by promise. |
**Example**
......@@ -277,7 +298,7 @@ For details about the audio playback demo, see [Audio Playback Development](../.
| Name | Type | Readable| Writable| Description |
| ------------------------------- | ------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
| src | string | Yes | Yes | Audio file URI. The mainstream audio formats (M4A, AAC, MPEG-3, OGG, and WAV) are supported.<br>**Examples of supported URI schemes**:<br>1. FD: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP: http://xx<br>3. HTTPS: https://xx<br>4. HLS: http://xx or https://xx<br>**Required permissions**: ohos.permission.READ_MEDIA or ohos.permission.INTERNET|
| fdSrc<sup>9+</sup> | [AVFileDescriptor](#avfiledescriptor9) | Yes | Yes | Description of the audio file. This attribute is required when audio resources of an application are continuously stored in a file.<br>**Example:**<br>Assume that a music file that stores continuous music resources consists of the following:<br>Music 1 (address offset: 0, byte length: 100)<br>Music 2 (address offset: 101; byte length: 50)<br>Music 3 (address offset: 151, byte length: 150)<br>1. To play music 1: AVFileDescriptor {fd = resource handle; offset = 0; length = 100; }<br>2. To play music 2: AVFileDescriptor {fd = resource handle; offset = 101; length = 50; }<br>3. To play music 3: AVFileDescriptor {fd = resource handle; offset = 151; length = 150; }<br>If the file is an independent music file, use **src=fd://xx**.<br>|
| fdSrc<sup>9+</sup> | [AVFileDescriptor](#avfiledescriptor9) | Yes | Yes | Description of the audio file. This attribute is required when audio resources of an application are continuously stored in a file.<br>**Example:**<br>Assume that a music file that stores continuous music resources consists of the following:<br>Music 1 (address offset: 0, byte length: 100)<br>Music 2 (address offset: 101; byte length: 50)<br>Music 3 (address offset: 151, byte length: 150)<br>1. To play music 1: AVFileDescriptor {fd = resource handle; offset = 0; length = 100; }<br>2. To play music 2: AVFileDescriptor {fd = resource handle; offset = 101; length = 50; }<br>3. To play music 3: AVFileDescriptor {fd = resource handle; offset = 151; length = 150; }<br>To play an independent music file, use **src=fd://xx**.<br>|
| loop | boolean | Yes | Yes | Whether to loop audio playback. The value **true** means to loop audio playback, and **false** means the opposite. |
| audioInterruptMode<sup>9+</sup> | [audio.InterruptMode](js-apis-audio.md#interruptmode9) | Yes | Yes | Audio interruption mode. |
| currentTime | number | Yes | No | Current audio playback position, in ms. |
......@@ -338,7 +359,7 @@ audioPlayer.stop();
reset(): void
Switches the audio resource to be played.
Resets the audio asset to be played.
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer
......@@ -496,7 +517,7 @@ for (let i = 0; i < arrayDescription.length; i++) {
on(type: 'bufferingUpdate', callback: (infoType: [BufferingInfoType](#bufferinginfotype8), value: number) => void): void
Subscribes to the audio buffering update event. Only network playback supports this subscription.
Subscribes to the audio buffering update event. This API works only under online playback.
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer
......@@ -669,7 +690,7 @@ Describes audio and video file resources. It is used to specify a particular res
## VideoPlayer<sup>8+</sup>
Provides APIs to manage and play video. Before calling an API of **VideoPlayer**, you must call [createVideoPlayer()](#mediacreatevideoplayer8) to create a [VideoPlayer](#videoplayer8) instance.
Provides APIs to manage and play video. Before calling an API of **VideoPlayer**, you must use [createVideoPlayer()](#mediacreatevideoplayer8) to create a [VideoPlayer](#videoplayer8) instance.
For details about the video playback demo, see [Video Playback Development](../../media/video-playback.md).
......@@ -679,7 +700,7 @@ For details about the video playback demo, see [Video Playback Development](../.
| 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: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP: http://xx<br>3. HTTPS: https://xx<br>4. HLS: http://xx or https://xx<br>|
| url<sup>8+</sup> | string | Yes | Yes | Video URL. The mainstream video formats (MPEG-4, MPEG-TS, WebM, and MKV) are supported.<br>**Example of supported URIs**:<br>1. FD: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP: http://xx<br>3. HTTPS: https://xx<br>4. HLS: http://xx or https://xx<br>|
| fdSrc<sup>9+</sup> | [AVFileDescriptor](#avfiledescriptor9) | Yes| Yes| Description of a video file. This attribute is required when video resources of an application are continuously stored in a file.<br>**Example:**<br>Assume that a music file that stores continuous music resources consists of the following:<br>Video 1 (address offset: 0, byte length: 100)<br>Video 2 (address offset: 101; byte length: 50)<br>Video 3 (address offset: 151, byte length: 150)<br>1. To play video 1: AVFileDescriptor {fd = resource handle; offset = 0; length = 100; }<br>2. To play video 2: AVFileDescriptor {fd = resource handle; offset = 101; length = 50; }<br>3. To play video 3: AVFileDescriptor {fd = resource handle; offset = 151; length = 150; }<br>To play an independent video file, use **src=fd://xx**.<br>|
| 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. |
| videoScaleType<sup>9+</sup> | [VideoScaleType](#videoscaletype9) | Yes | Yes | Video scale type. |
......@@ -702,10 +723,10 @@ Sets **SurfaceId**. This API uses an asynchronous callback to return the result.
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | -------- | ---- | ------------------------- |
| surfaceId | string | Yes | Surface ID to set. |
| callback | function | Yes | Callback used to return the result.|
| Name | Type | Mandatory| Description |
| --------- | -------------------- | ---- | ------------------------- |
| surfaceId | string | Yes | Surface ID to set. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
......@@ -763,9 +784,9 @@ Prepares for video playback. This API uses an asynchronous callback to return th
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------ |
| callback | function | Yes | Callback used to return the result.|
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
......@@ -813,9 +834,9 @@ Starts to play video resources. This API uses an asynchronous callback to return
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------ |
| callback | function | Yes | Callback used to return the result.|
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
......@@ -863,9 +884,9 @@ Pauses video playback. This API uses an asynchronous callback to return the resu
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------ |
| callback | function | Yes | Callback used to return the result.|
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
......@@ -913,9 +934,9 @@ Stops video playback. This API uses an asynchronous callback to return the resul
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------ |
| callback | function | Yes | Callback used to return the result.|
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
......@@ -957,15 +978,15 @@ videoPlayer.stop().then(() => {
reset(callback: AsyncCallback\<void>): void
Switches the video resource to be played. This API uses an asynchronous callback to return the result.
Resets the video asset to be played. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Media.VideoPlayer
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------ |
| callback | function | Yes | Callback used to return the result.|
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
......@@ -983,7 +1004,7 @@ videoPlayer.reset((err) => {
reset(): Promise\<void>
Switches the video resource to be played. This API uses a promise to return the result.
Resets the video asset to be played. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Media.VideoPlayer
......@@ -1013,10 +1034,10 @@ Seeks to the specified playback position. The next key frame at the specified po
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------------------------------------------ |
| timeMs | number | Yes | Position to seek to, in ms. The value range is [0, duration].|
| callback | function | Yes | Callback used to return the result. |
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| timeMs | number | Yes | Position to seek to, in ms. The value range is [0, duration].|
| callback | AsyncCallback\<number> | Yes | Callback used to return the result. |
**Example**
......@@ -1045,7 +1066,7 @@ Seeks to the specified playback position. This API uses an asynchronous callback
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| timeMs | number | Yes | Position to seek to, in ms. The value range is [0, duration].|
| mode | [SeekMode](#seekmode8) | Yes | Seek mode. |
| callback | function | Yes | Callback used to return the result. |
| callback | AsyncCallback\<number> | Yes | Callback used to return the result. |
**Example**
......@@ -1080,7 +1101,7 @@ Seeks to the specified playback position. If **mode** is not specified, the next
| Type | Description |
| -------------- | ------------------------------------------- |
| Promise\<number> | Promise used to return the playback position, in ms.|
| Promise\<number>| Promise used to return the playback position, in ms.|
**Example**
......@@ -1110,10 +1131,10 @@ Sets the volume. This API uses an asynchronous callback to return the result.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------------------------------------------ |
| vol | number | Yes | Relative volume. The value ranges from 0.00 to 1.00. The value **1** indicates the maximum volume (100%).|
| callback | function | Yes | Callback used to return the result. |
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------------------------------------ |
| vol | number | Yes | Relative volume. The value ranges from 0.00 to 1.00. The value **1** indicates the maximum volume (100%).|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
......@@ -1169,9 +1190,9 @@ Releases the video playback resource. This API uses an asynchronous callback to
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------ |
| callback | function | Yes | Callback used to return the result.|
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
......@@ -1295,10 +1316,10 @@ Sets the video playback speed. This API uses an asynchronous callback to return
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ---------------------------------------------------------- |
| speed | number | Yes | Video playback speed. For details, see [PlaybackSpeed](#playbackspeed8).|
| callback | function | Yes | Callback used to return the result. |
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ---------------------------------------------------------- |
| speed | number | Yes | Video playback speed. For details, see [PlaybackSpeed](#playbackspeed8).|
| callback | AsyncCallback\<number> | Yes | Callback used to return the result. |
**Example**
......@@ -1333,7 +1354,7 @@ Sets the video playback speed. This API uses a promise to return the result.
| Type | Description |
| ---------------- | ------------------------------------------------------------ |
| Promise\<number> | Promise used to return playback speed. For details, see [PlaybackSpeed](#playbackspeed8).|
| Promise\<number>| Promise used to return playback speed. For details, see [PlaybackSpeed](#playbackspeed8).|
**Example**
......@@ -1348,65 +1369,6 @@ videoPlayer.setSpeed(speed).then(() => {
});
```
### selectBitrate<sup>9+</sup>
selectBitrate(bitrate:number, callback: AsyncCallback\<number>): void
Selects a bit rate from available ones, which can be obtained by calling [availableBitratesCollect](#onavailablebitratescollect9). This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Media.VideoPlayer
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ---------------------------------------------------------- |
| bitrate | number | Yes | Bit rate to select, which is used in the HLS multi-bit rate scenario. The unit is bit/s. |
| callback | AsyncCallback\<number> | Yes | Callback used to return the result. If the set value is returned, the operation is successful; otherwise, the operation fails.|
**Example**
```js
let bitrate = 1024000;
videoPlayer.selectBitrate(bitrate, (err, result) => {
if (err == null) {
console.info('selectBitrate success!');
} else {
console.info('selectBitrate fail!');
}
});
```
### selectBitrate<sup>9+</sup>
selectBitrate(bitrate:number): Promise\<number>
Selects a bit rate from available ones, which can be obtained by calling [availableBitratesCollect](#onavailablebitratescollect9). This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Media.VideoPlayer
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | -------------------------------------------- |
| bitrate | number | Yes | Bit rate, which is used in the HLS multi-bit rate scenario. The unit is bit/s.|
**Return value**
| Type | Description |
| ---------------- | --------------------------- |
| Promise\<number> | Promise used to return the bit rate.|
**Example**
```js
let bitrate = 1024000;
videoPlayer.selectBitrate(bitrate).then(() => {
console.info('selectBitrate success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
});
```
### on('playbackCompleted')<sup>8+</sup>
on(type: 'playbackCompleted', callback: Callback\<void>): void
......@@ -1596,7 +1558,7 @@ Enumerates the video scale modes.
**System capability**: SystemCapability.Multimedia.Media.VideoPlayer
| Name | Default Value| Description |
| Name | Value| Description |
| ---------------------------- | ------ | ---------- |
| VIDEO_SCALE_TYPE_FIT | 0 | The video will be stretched to fit the window.|
| VIDEO_SCALE_TYPE_FIT_CROP| 1 | The video will be stretched to fit the window, without changing its aspect ratio. The content may be cropped. |
......@@ -1630,7 +1592,7 @@ audioPlayer.getTrackDescription((error, arrList) => {
## AudioRecorder
Implements audio recording. Before calling an API of **AudioRecorder**, you must call [createAudioRecorder()](#mediacreateaudiorecorder) to create an [AudioRecorder](#audiorecorder) instance.
Implements audio recording. Before calling an API of **AudioRecorder**, you must use [createAudioRecorder()](#mediacreateaudiorecorder) to create an [AudioRecorder](#audiorecorder) instance.
For details about the audio recording demo, see [Audio Recording Development](../../media/audio-recorder.md).
......@@ -1890,13 +1852,13 @@ Enumerates the audio encoding formats.
**System capability**: SystemCapability.Multimedia.Media.AudioRecorder
| Name | Default Value| Description |
| ------- | ------ | ------------------------------------------------------------ |
| DEFAULT | 0 | Default encoding format.<br>This API is defined but not implemented yet.|
| AMR_NB | 1 | AMR-NB.<br>This API is defined but not implemented yet.|
| AMR_WB | 2 | Adaptive Multi Rate-Wide Band Speech Codec (AMR-WB).<br>This API is defined but not implemented yet.|
| AAC_LC | 3 | Advanced Audio Coding Low Complexity (AAC-LC).|
| HE_AAC | 4 | High-Efficiency Advanced Audio Coding (HE_AAC).<br>This API is defined but not implemented yet.|
| Name | Value | Description |
| ------- | ---- | ------------------------------------------------------------ |
| DEFAULT | 0 | Default encoding format.<br>This API is defined but not implemented yet. |
| AMR_NB | 1 | AMR-NB.<br>This API is defined but not implemented yet.|
| AMR_WB | 2 | Adaptive Multi Rate-Wide Band Speech Codec (AMR-WB).<br>This API is defined but not implemented yet.|
| AAC_LC | 3 | Advanced Audio Coding Low Complexity (AAC-LC).|
| HE_AAC | 4 | High-Efficiency Advanced Audio Coding (HE_AAC).<br>This API is defined but not implemented yet.|
## AudioOutputFormat<sup>(deprecated)</sup>
......@@ -1908,13 +1870,13 @@ Enumerates the audio output formats.
**System capability**: SystemCapability.Multimedia.Media.AudioRecorder
| Name | Default Value| Description |
| -------- | ------ | ------------------------------------------------------------ |
| DEFAULT | 0 | Default encapsulation format.<br>This API is defined but not implemented yet.|
| MPEG_4 | 2 | MPEG-4. |
| AMR_NB | 3 | AMR_NB.<br>This API is defined but not implemented yet.|
| AMR_WB | 4 | AMR_WB.<br>This API is defined but not implemented yet.|
| AAC_ADTS | 6 | Audio Data Transport Stream (ADTS), which is a transport stream format of AAC-based audio.|
| Name | Value | Description |
| -------- | ---- | ------------------------------------------------------------ |
| DEFAULT | 0 | Default encapsulation format.<br>This API is defined but not implemented yet. |
| MPEG_4 | 2 | MPEG-4. |
| AMR_NB | 3 | AMR_NB.<br>This API is defined but not implemented yet. |
| AMR_WB | 4 | AMR_WB.<br>This API is defined but not implemented yet. |
| AAC_ADTS | 6 | Audio Data Transport Stream (ADTS), which is a transport stream format of AAC-based audio.|
## VideoRecorder<sup>9+</sup>
......@@ -1926,6 +1888,8 @@ For details about the video recording demo, see [Video Recording Development](..
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
| Name | Type | Readable| Writable| Description |
| ------------------ | -------------------------------------- | ---- | ---- | ---------------- |
| state<sup>9+</sup> | [VideoRecordState](#videorecordstate9) | Yes | No | Video recording state.|
......@@ -1940,6 +1904,8 @@ Sets video recording parameters. This API uses an asynchronous callback to retur
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
......@@ -1947,6 +1913,17 @@ Sets video recording parameters. This API uses an asynchronous callback to retur
| config | [VideoRecorderConfig](#videorecorderconfig9) | Yes | Video recording parameters to set. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | --------------------------------------- |
| 201 | Permission denied. Return by callback. |
| 401 | Parameter error. Return by callback. |
| 5400102 | Operate not permit. Return by callback. |
| 5400105 | Service died. Return by callback. |
**Example**
```js
......@@ -1992,6 +1969,8 @@ Sets video recording parameters. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -2004,6 +1983,17 @@ Sets video recording parameters. This API uses a promise to return the result.
| -------------- | ---------------------------------------- |
| Promise\<void> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | -------------------------------------- |
| 201 | Permission denied. Return by promise. |
| 401 | Parameter error. Return by promise. |
| 5400102 | Operate not permit. Return by promise. |
| 5400105 | Service died. Return by promise. |
**Example**
```js
......@@ -2049,12 +2039,24 @@ This API can be called only after [prepare()](#videorecorder_prepare1) is called
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | --------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to obtain the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | --------------------------------------- |
| 5400102 | Operate not permit. Return by callback. |
| 5400103 | IO error. Return by callback. |
| 5400105 | Service died. Return by callback. |
**Example**
```js
......@@ -2082,12 +2084,24 @@ This API can be called only after [prepare()](#videorecorder_prepare1) is called
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Return value**
| Type | Description |
| ---------------- | -------------------------------- |
| Promise\<string> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | -------------------------------------- |
| 5400102 | Operate not permit. Return by promise. |
| 5400103 | IO error. Return by promise. |
| 5400105 | Service died. Return by promise. |
**Example**
```js
......@@ -2111,12 +2125,24 @@ This API can be called only after [prepare()](#videorecorder_prepare1) and [getI
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | --------------------------------------- |
| 5400102 | Operate not permit. Return by callback. |
| 5400103 | IO error. Return by callback. |
| 5400105 | Service died. Return by callback. |
**Example**
```js
......@@ -2140,12 +2166,24 @@ This API can be called only after [prepare()](#videorecorder_prepare1) and [getI
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Return value**
| Type | Description |
| -------------- | ------------------------------------- |
| Promise\<void> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | -------------------------------------- |
| 5400102 | Operate not permit. Return by promise. |
| 5400103 | IO error. Return by promise. |
| 5400105 | Service died. Return by promise. |
**Example**
```js
......@@ -2167,12 +2205,24 @@ This API can be called only after [start()](#videorecorder_start1) is called. Yo
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | --------------------------------------- |
| 5400102 | Operate not permit. Return by callback. |
| 5400103 | IO error. Return by callback. |
| 5400105 | Service died. Return by callback. |
**Example**
```js
......@@ -2196,12 +2246,24 @@ This API can be called only after [start()](#videorecorder_start1) is called. Yo
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Return value**
| Type | Description |
| -------------- | ------------------------------------- |
| Promise\<void> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | -------------------------------------- |
| 5400102 | Operate not permit. Return by promise. |
| 5400103 | IO error. Return by promise. |
| 5400105 | Service died. Return by promise. |
**Example**
```js
......@@ -2221,12 +2283,24 @@ Resumes video recording. This API uses an asynchronous callback to return the re
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | --------------------------------------- |
| 5400102 | Operate not permit. Return by callback. |
| 5400103 | IO error. Return by callback. |
| 5400105 | Service died. Return by callback. |
**Example**
```js
......@@ -2248,12 +2322,24 @@ Resumes video recording. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Return value**
| Type | Description |
| -------------- | ------------------------------------- |
| Promise\<void> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | -------------------------------------- |
| 5400102 | Operate not permit. Return by promise. |
| 5400103 | IO error. Return by promise. |
| 5400105 | Service died. Return by promise. |
**Example**
```js
......@@ -2275,12 +2361,24 @@ To start another recording, you must call [prepare()](#videorecorder_prepare1) a
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | --------------------------------------- |
| 5400102 | Operate not permit. Return by callback. |
| 5400103 | IO error. Return by callback. |
| 5400105 | Service died. Return by callback. |
**Example**
```js
......@@ -2304,12 +2402,24 @@ To start another recording, you must call [prepare()](#videorecorder_prepare1) a
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Return value**
| Type | Description |
| -------------- | ------------------------------------- |
| Promise\<void> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | -------------------------------------- |
| 5400102 | Operate not permit. Return by promise. |
| 5400103 | IO error. Return by promise. |
| 5400105 | Service died. Return by promise. |
**Example**
```js
......@@ -2329,12 +2439,22 @@ Releases the video recording resource. This API uses an asynchronous callback to
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | --------------------------------- |
| 5400105 | Service died. Return by callback. |
**Example**
```js
......@@ -2356,12 +2476,22 @@ Releases the video recording resource. This API uses a promise to return the res
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Return value**
| Type | Description |
| -------------- | ----------------------------------------- |
| Promise\<void> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | --------------------------------- |
| 5400105 | Service died. Return by callback. |
**Example**
```js
......@@ -2383,12 +2513,23 @@ To start another recording, you must call [prepare()](#videorecorder_prepare1) a
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | --------------------------------- |
| 5400103 | IO error. Return by callback. |
| 5400105 | Service died. Return by callback. |
**Example**
```js
......@@ -2412,12 +2553,23 @@ To start another recording, you must call [prepare()](#videorecorder_prepare1) a
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
**Return value**
| Type | Description |
| -------------- | ------------------------------------- |
| Promise\<void> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | -------------------------------- |
| 5400103 | IO error. Return by promise. |
| 5400105 | Service died. Return by promise. |
**Example**
```js
......@@ -2444,6 +2596,15 @@ Subscribes to video recording error events. After an error event is reported, yo
| type | string | Yes | Event type, which is **'error'** in this case.<br>The **'error'** event is triggered when an error occurs during video recording.|
| callback | ErrorCallback | Yes | Callback invoked when the event is triggered. |
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | --------------------------------- |
| 5400103 | IO error. Return by callback. |
| 5400105 | Service died. Return by callback. |
**Example**
```js
......@@ -2459,6 +2620,8 @@ Enumerates the video recording states. You can obtain the state through the **st
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
| Name | Type | Description |
| -------- | ------ | ---------------------- |
| idle | string | The video recorder is idle. |
......@@ -2474,7 +2637,9 @@ Describes the video recording parameters.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
| Name | Type | Mandatory| Description |
**System API**: This is a system API.
| Name | Type | Mandatory| Description |
| --------------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ |
| audioSourceType | [AudioSourceType](#audiosourcetype9) | Yes | Type of the audio source for video recording. |
| videoSourceType | [VideoSourceType](#videosourcetype9) | Yes | Type of the video source for video recording. |
......@@ -2489,6 +2654,8 @@ Enumerates the audio source types for video recording.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
| Name | Value | Description |
| ------------------------- | ---- | ---------------------- |
| AUDIO_SOURCE_TYPE_DEFAULT | 0 | Default audio input source.|
......@@ -2500,6 +2667,8 @@ Enumerates the video source types for video recording.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API.
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------- |
| VIDEO_SOURCE_TYPE_SURFACE_YUV | 0 | The input surface carries raw data.|
......@@ -2511,7 +2680,9 @@ Describes the video recording profile.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
| Name | Type | Mandatory| Description |
**System API**: This is a system API.
| Name | Type | Mandatory| Description |
| ---------------- | -------------------------------------------- | ---- | ---------------- |
| audioBitrate | number | Yes | Audio encoding bit rate.|
| audioChannels | number | Yes | Number of audio channels.|
......@@ -2541,7 +2712,7 @@ Describes the geographical location of the recorded video.
**System capability**: SystemCapability.Multimedia.Media.Core
| Name | Type| Mandatory| Description |
| --------- | -------- | ---- | ---------------- |
| latitude | number | Yes | Latitude of the geographical location.|
| longitude | number | Yes | Longitude of the geographical location.|
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ---------------- |
| latitude | number | Yes | Latitude of the geographical location.|
| longitude | number | Yes | Longitude of the geographical location.|
# Media Error Codes
## 5400101 Memory Allocation Failed
**Error Message**
No memory.
**Description**
Failed to allocate memory.
**Possible Causes**
1. The number of instances exceeds 16.
2. The new or malloc process fails, causing a null pointer.
**Solution**
Destroy this instance and re-create it. If the re-creation fails, stop related operations.
## 5400102 Unsupported Operation
**Error Message**
Operate not permit.
**Description**
This operation is not allowed.
**Possible Causes**
This operation is not allowed in the current state.
**Solution**
Switch the instance to the correct state and perform the operation.
## 5400103 I/O Error
**Error Message**
IO error.
**Description**
An I/O error occurs.
**Possible Causes**
The data interaction between the media and other modules (graphics, audio, network, HDI, and camera) is abnormal.
**Solution**
Ensure that the network is normal, destroy this instance, and re-create it. If the re-creation fails, stop related operations.
## 5400104 Operation Timeout
**Error Message**
Time out.
**Description**
The operation timed out.
**Possible Causes**
1. The network connection times out.
2. Accessing other modules times out.
**Solution**
1. Check whether the network is normal.
2. Destroy this instance and re-create it. If the re-creation fails, stop related operations.
## 5400105 Play Service Dead
**Error Message**
Service died.
**Description**
The playback service is dead.
**Possible Causes**
The playback service is dead.
**Solution**
Destroy this instance and re-create it. If the re-creation fails, stop related operations.
## 5400106 Format Not Supported
**Error Message**
Unsupport format.
**Description**
The format is not supported.
**Possible Causes**
The file format is not supported.
**Solution**
Use a supported format.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册