提交 91677c39 编写于 作者: G Gloria

Update docs against 9571+9591+9637

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 11a50470
......@@ -277,10 +277,10 @@ 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 and ohos.permission.INTERNET (The latter is required only when online resources are used.)|
| fdSrc<sup>9+</sup> | [AVFileDescriptor](#interruptmode9) | 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> <br>**Required permissions**: ohos.permission.READ_MEDIA|
| 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.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>|
| 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> | [InterruptMode](#interruptmode9) | Yes | Yes | Audio interruption mode. |
| 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. |
| duration | number | Yes | No | Audio duration, in ms. |
| state | [AudioState](#audiostate) | Yes | No | Audio playback state. This state cannot be used as the condition for triggering the call of **play()**, **pause()**, or **stop()**.|
......@@ -442,7 +442,7 @@ function printfDescription(obj) {
}
}
audioPlayer.getTrackDescription((error, arrlist) => {
audioPlayer.getTrackDescription((error, ) => {
if (arrlist != null) {
for (let i = 0; i < arrlist.length; i++) {
printfDescription(arrlist[i]);
......@@ -477,7 +477,7 @@ function printfDescription(obj) {
console.info('audio value is ' + property);
}
}
let arrayDescription = null
audioPlayer.getTrackDescription().then((arrlist) => {
if (arrlist != null) {
arrayDescription = arrlist;
......@@ -535,6 +535,8 @@ Subscribes to the audio playback events.
**Example**
```js
import fileio from '@ohos.fileio'
let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance.
audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully.
console.info('audio set source success');
......@@ -574,11 +576,11 @@ audioPlayer.on('error', (error) => { // Set the 'error' event callback
});
// Set the FD (local playback) of the video file selected by the user.
let fdPath = 'fd://'
let fdPath = 'fd://';
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command.
let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3';
fileIO.open(path).then(fdNumber) => {
fdPath = fdPath + '' + fdNumber;
fileio.open(path).then((fdValue) => {
fdPath = fdPath + '' + fdValue;
console.info('open fd success fd is' + fdPath);
}, (err) => {
console.info('open fd failed err is' + err);
......@@ -646,21 +648,19 @@ Enumerates the audio playback states. You can obtain the state through the **sta
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer
| Name | Type | Description |
| ------------------ | ------ | ---------------------------------------------- |
| idle | string | No audio playback is in progress. The audio player is in this state after the **'dataload'** or **'reset'** event is triggered.|
| playing | string | Audio playback is in progress. The audio player is in this state after the **'play'** event is triggered. |
| paused | string | Audio playback is paused. The audio player is in this state after the **'pause'** event is triggered. |
| stopped | string | Audio playback is stopped. The audio player is in this state after the **'stop'** event is triggered. |
| error<sup>8+</sup> | string | Audio playback is in the error state. |
| Name | Type | Description |
| ------- | ------ | ---------------------------------------------- |
| idle | string | No audio playback is in progress. The audio player is in this state after the **'dataload'** or **'reset'** event is triggered.|
| playing | string | Audio playback is in progress. The audio player is in this state after the **'play'** event is triggered. |
| paused | string | Audio playback is paused. The audio player is in this state after the **'pause'** event is triggered. |
| stopped | string | Audio playback is stopped. The audio player is in this state after the **'stop'** event is triggered. |
| error | string | Audio playback is in the error state. |
## AVFileDescriptor<sup>9+</sup>
Describes audio and video file resources. It is used to specify a particular resource for playback based on its offset and length within a file.
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer
**Parameters**
**System capability**: SystemCapability.Multimedia.Media.Core
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
......@@ -668,17 +668,6 @@ Describes audio and video file resources. It is used to specify a particular res
| offset | number | Yes | Resource offset, which needs to be entered based on the preset resource information. An invalid value causes a failure to parse audio and video resources.|
| length | number | Yes | Resource length, which needs to be entered based on the preset resource information. An invalid value causes a failure to parse audio and video resources.|
## InterruptMode<sup>9+</sup>
Describes the audio interruption mode.
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer
| Name | Default Value| Description |
| ---------------------------- | ------ | ---------- |
| SHARE_MODE | 0 | Shared mode.|
| INDEPENDENT_MODE| 1 | Independent mode. |
## 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.
......@@ -691,11 +680,11 @@ 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>**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.INTERNET (The latter is required only when online resources are used.)|
| fdSrc<sup>9+</sup> | [AVFileDescriptor](#interruptmode9) | 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>**Note**:<br>**Required permissions**: ohos.permission.READ_MEDIA|
| 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>**Required permissions**: ohos.permission.INTERNET|
| 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. |
| audioInterruptMode<sup>9+</sup> | [InterruptMode](#interruptmode9) | Yes | Yes | Audio interruption mode. |
| audioInterruptMode<sup>9+</sup> | [audio.InterruptMode](js-apis-audio.md#interruptmode9) | Yes | Yes | Audio interruption mode. |
| currentTime<sup>8+</sup> | number | Yes | No | Current video playback position, in ms. |
| duration<sup>8+</sup> | number | Yes | No | Video duration, in ms. The value **-1** indicates the live mode. |
| state<sup>8+</sup> | [VideoPlayState](#videoplaystate8) | Yes | No | Video playback state. |
......@@ -722,6 +711,7 @@ Sets **SurfaceId**. This API uses an asynchronous callback to return the result.
**Example**
```js
let surfaceId = null;
videoPlayer.setDisplaySurface(surfaceId, (err) => {
if (err == null) {
console.info('setDisplaySurface success!');
......@@ -756,6 +746,7 @@ Sets **SurfaceId**. This API uses a promise to return the result.
**Example**
```js
let surfaceId = null;
videoPlayer.setDisplaySurface(surfaceId).then(() => {
console.info('setDisplaySurface success');
}).catch((error) => {
......@@ -1062,8 +1053,7 @@ Seeks to the specified playback position. This API uses an asynchronous callback
```js
import media from '@ohos.multimedia.media'
let seekTime = 5000;
let seekMode = media.SeekMode.SEEK_NEXT_SYNC;
videoPlayer.seek(seekTime, seekMode, (err, result) => {
videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC, (err, result) => {
if (err == null) {
console.info('seek success!');
} else {
......@@ -1096,6 +1086,7 @@ Seeks to the specified playback position. If **mode** is not specified, the next
**Example**
```js
import media from '@ohos.multimedia.media'
let seekTime = 5000;
videoPlayer.seek(seekTime).then((seekDoneTime) => { // seekDoneTime indicates the position after the seek operation is complete.
console.info('seek success');
......@@ -1103,7 +1094,7 @@ videoPlayer.seek(seekTime).then((seekDoneTime) => { // seekDoneTime indicates th
console.info(`video catchCallback, error:${error}`);
});
videoPlayer.seek(seekTime, seekMode).then((seekDoneTime) => {
videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
console.info('seek success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
......@@ -1162,7 +1153,7 @@ Sets the volume. This API uses a promise to return the result.
```js
let vol = 0.5;
videoPlayer.setVolume(vol).then() => {
videoPlayer.setVolume(vol).then(() => {
console.info('setVolume success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
......@@ -1212,7 +1203,7 @@ Releases the video playback resource. This API uses a promise to return the resu
**Example**
```js
videoPlayer.release().then() => {
videoPlayer.release().then(() => {
console.info('release success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
......@@ -1245,7 +1236,7 @@ function printfDescription(obj) {
}
videoPlayer.getTrackDescription((error, arrlist) => {
if (arrlist) != null) {
if ((arrlist) != null) {
for (let i = 0; i < arrlist.length; i++) {
printfDescription(arrlist[i]);
}
......@@ -1351,7 +1342,7 @@ Sets the video playback speed. This API uses a promise to return the result.
import media from '@ohos.multimedia.media'
let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X;
videoPlayer.setSpeed(speed).then() => {
videoPlayer.setSpeed(speed).then(() => {
console.info('setSpeed success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
......@@ -1410,7 +1401,7 @@ Selects a bit rate from available ones, which can be obtained by calling [availa
```js
let bitrate = 1024000;
videoPlayer.selectBitrate(bitrate).then() => {
videoPlayer.selectBitrate(bitrate).then(() => {
console.info('selectBitrate success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
......@@ -1613,30 +1604,24 @@ Enumerates the video scale modes.
## MediaDescription<sup>8+</sup>
### [key : string] : Object
Defines media information in key-value mode.
**System capability**: SystemCapability.Multimedia.Media.Core
| Name | Type | Description |
| ----- | ------ | ------------------------------------------------------------ |
| key | string | Key of the media information. For details about the keys, see [MediaDescriptionKey](#mediadescriptionkey8).|
| value | any | Value of the key. For details about the values, see [MediaDescriptionKey](#mediadescriptionkey8).|
**Example**
```js
import media from '@ohos.multimedia.media'
function printfItemDescription(obj, key) {
let property = obj[key];
console.info('audio key is ' + key);
console.info('audio value is ' + property);
console.info('audio key is ' + key); // Specify a key. For details about the keys, see [MediaDescriptionKey].
console.info('audio value is ' + property); // Obtain the value of the key. The value can be any type. For details about the types, see [MediaDescriptionKey].
}
let audioPlayer = media.createAudioPlayer();
audioPlayer.getTrackDescription((error, arrlist) => {
if (arrlist != null) {
for (let i = 0; i < arrlist.length; i++) {
printfItemDescription(arrlist[i], MD_KEY_TRACK_TYPE); // Print the MD_KEY_TRACK_TYPE value of each track.
printfItemDescription(arrlist[i], media.MediaDescriptionKey.MD_KEY_TRACK_TYPE); // Print the MD_KEY_TRACK_TYPE value of each track.
}
} else {
console.log(`audio getTrackDescription fail, error:${error}`);
......@@ -1808,7 +1793,7 @@ Subscribes to the audio recording events.
**Example**
```js
let audiorecorder = media.createAudioRecorder(); // Create an AudioRecorder instance.
let audioRecorder = media.createAudioRecorder(); // Create an AudioRecorder instance.
let audioRecorderConfig = {
audioEncoder : media.AudioEncoder.AAC_LC, ,
audioEncodeBitRate : 22050,
......@@ -1864,10 +1849,19 @@ Subscribes to audio recording error events. After an error event is reported, yo
**Example**
```js
let audioRecorderConfig = {
audioEncoder : media.AudioEncoder.AAC_LC, ,
audioEncodeBitRate : 22050,
audioSampleRate : 22050,
numberOfChannels : 2,
format : media.AudioOutputFormat.AAC_ADTS,
uri : 'fd://xx', // The file must be created by the caller and granted with proper permissions.
location : { latitude : 30, longitude : 130},
}
audioRecorder.on('error', (error) => { // Set the 'error' event callback.
console.info(`audio error called, error: ${error}`);
});
audioRecorder.prepare(); // Do no set any parameter in prepare and trigger the 'error' event callback.
audioRecorder.prepare(audioRecorderConfig); // Do no set any parameter in prepare and trigger the 'error' event callback.
```
## AudioRecorderConfig
......@@ -2058,18 +2052,17 @@ media.createVideoRecorder().then((recorder) => {
if (recorder != null) {
videoRecorder = recorder;
console.info('createVideoRecorder success');
videoRecorder.prepare(videoConfig).then(() => {
console.info('prepare success');
}).catch((err) => {
console.info('prepare failed and catch error is ' + err.message);
});
} else {
console.info('createVideoRecorder failed');
}
}).catch((err) => {
console.info('catch err error message is ' + err.message);
});
videoRecorder.prepare(videoConfig).then(() => {
console.info('prepare success');
}).catch((err) => {
console.info('prepare failed and catch error is ' + err.message);
});
```
### getInputSurface<sup>9+</sup>
......@@ -2484,7 +2477,9 @@ Subscribes to video recording error events. After an error event is reported, yo
```js
videoRecorder.on('error', (error) => { // Set the 'error' event callback.
console.info(`audio error called, error: ${error}`);
}
// This event is reported when an error occurs during the retrieval of videoRecordState.
});
```
## VideoRecordState<sup>9+</sup>
......@@ -2515,7 +2510,7 @@ Describes the video recording parameters.
| profile | [VideoRecorderProfile](#videorecorderprofile9) | Yes | Video recording profile. |
| rotation | number | No | Rotation angle of the recorded video. |
| location | [Location](#location) | No | Geographical location of the recorded video. |
| url | string | Yes | Video output URL. Supported: fd://xx (fd number)<br>![](figures/en-us_image_url.png) <br>**Required permissions**: ohos.permission.READ_MEDIA|
| url | string | Yes | Video output URL. Supported: fd://xx (fd number)<br>![](figures/en-us_image_url.png) |
## AudioSourceType<sup>9+</sup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册