未验证 提交 8abe6a9c 编写于 作者: O openharmony_ci 提交者: Gitee

!8220 翻译完成:6967 媒体录制增加描述

Merge pull request !8220 from wusongqing/TR6967
...@@ -57,10 +57,10 @@ function setCallBack(audioPlayer) { ...@@ -57,10 +57,10 @@ function setCallBack(audioPlayer) {
}); });
audioPlayer.on('reset', () => { // Set the 'reset' event callback. audioPlayer.on('reset', () => { // Set the 'reset' event callback.
console.info('audio reset success'); console.info('audio reset success');
audioPlayer.release(); // Release the AudioPlayer resources. audioPlayer.release(); // Release the AudioPlayer instance.
audioPlayer = undefined; audioPlayer = undefined;
}); });
audioPlayer.on('timeUpdate', (seekDoneTime) => {// Set the 'timeUpdate' event callback. audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the 'timeUpdate' event callback.
if (typeof(seekDoneTime) == 'undefined') { if (typeof(seekDoneTime) == 'undefined') {
console.info('audio seek fail'); console.info('audio seek fail');
return; return;
...@@ -92,10 +92,10 @@ function setCallBack(audioPlayer) { ...@@ -92,10 +92,10 @@ function setCallBack(audioPlayer) {
} }
async function audioPlayerDemo() { async function audioPlayerDemo() {
// 1. Create an audioPlayer instance. // 1. Create an AudioPlayer instance.
let audioPlayer = media.createAudioPlayer(); let audioPlayer = media.createAudioPlayer();
setCallBack(audioPlayer); // Set the event callbacks. setCallBack(audioPlayer); // Set the event callbacks.
// 2. Set the URI of the audio file selected by the user. // 2. Set the URI of the audio file.
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/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3';
...@@ -128,7 +128,7 @@ export class AudioDemo { ...@@ -128,7 +128,7 @@ export class AudioDemo {
}); });
audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete.
console.info('audio play finish'); console.info('audio play finish');
audioPlayer.release(); // Release the AudioPlayer resources. audioPlayer.release(); // Release the AudioPlayer instance.
audioPlayer = undefined; audioPlayer = undefined;
}); });
} }
...@@ -228,7 +228,7 @@ export class AudioDemo { ...@@ -228,7 +228,7 @@ export class AudioDemo {
audioPlayer.loop = true; // Set the loop playback attribute. audioPlayer.loop = true; // Set the loop playback attribute.
audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback.
}); });
audioPlayer.on('play', () => { // Sets the 'play' event callback to start loop playback. audioPlayer.on('play', () => { // Set the 'play' event callback to start loop playback.
console.info('audio play success'); console.info('audio play success');
}); });
} }
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
> >
> 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:
...@@ -106,7 +105,7 @@ media.createVideoPlayer().then((video) => { ...@@ -106,7 +105,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. Only one **AudioRecorder** instance can be created per device.
**System capability**: SystemCapability.Multimedia.Media.AudioRecorder **System capability**: SystemCapability.Multimedia.Media.AudioRecorder
...@@ -215,12 +214,12 @@ For details about the audio playback demo, see [Audio Playback Development](../. ...@@ -215,12 +214,12 @@ For details about the audio playback demo, see [Audio Playback Development](../.
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer **System capability**: SystemCapability.Multimedia.Media.AudioPlayer
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ----------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | | ------------------------------- | ----------------------------------- | ---- | ---- | ------------------------------------------------------------ |
| 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.| | src | string | Yes | Yes | Audio file URI. The mainstream audio formats (MPEG-4, MPEG-TS, WebM, and MKV) 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>**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. |
| state | [AudioState](#audiostate) | Yes | No | Audio playback state. | | 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()**.|
### play<a name=audioplayer_play></a> ### play<a name=audioplayer_play></a>
...@@ -560,7 +559,7 @@ audioPlayer.seek(30000); // Seek to 30000 ms. ...@@ -560,7 +559,7 @@ audioPlayer.seek(30000); // Seek to 30000 ms.
on(type: 'error', callback: ErrorCallback): void on(type: 'error', callback: ErrorCallback): void
Subscribes to the audio playback error event. Subscribes to audio playback error events.
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer **System capability**: SystemCapability.Multimedia.Media.AudioPlayer
...@@ -589,13 +588,14 @@ Enumerates the audio playback states. You can obtain the state through the **sta ...@@ -589,13 +588,14 @@ Enumerates the audio playback states. You can obtain the state through the **sta
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer **System capability**: SystemCapability.Multimedia.Media.AudioPlayer
| Name | Type | Description | | Name | Type | Description |
| ------------------ | ------ | -------------- | | ------------------ | ------ | ---------------------------------------------- |
| idle | string | The audio player is idle.| | idle | string | No audio playback is in progress.|
| playing | string | Audio playback is in progress.| | playing | string | Audio playback is in progress. |
| paused | string | Audio playback is paused.| | paused | string | Audio playback is paused. |
| stopped | string | Audio playback is stopped.| | stopped | string | Audio playback is stopped. |
| error<sup>8+</sup> | string | Audio playback is in the error state. | | error<sup>8+</sup> | string | Audio playback is in the error state. |
## VideoPlayer<sup>8+</sup> ## 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 call [createVideoPlayer()](#mediacreatevideoplayer8) to create a [VideoPlayer](#videoplayer8) instance.
...@@ -608,10 +608,10 @@ For details about the video playback demo, see [Video Playback Development](../. ...@@ -608,10 +608,10 @@ 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. 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.| | 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>**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 mode. |
| state<sup>8+</sup> | [VideoPlayState](#videoplaystate8) | Yes | No | Video playback state. | | state<sup>8+</sup> | [VideoPlayState](#videoplaystate8) | Yes | No | Video playback state. |
| width<sup>8+</sup> | number | Yes | No | Video width. | | width<sup>8+</sup> | number | Yes | No | Video width. |
| height<sup>8+</sup> | number | Yes | No | Video height. | | height<sup>8+</sup> | number | Yes | No | Video height. |
...@@ -1353,7 +1353,7 @@ videoPlayer.on('videoSizeChanged', (width, height) => { ...@@ -1353,7 +1353,7 @@ videoPlayer.on('videoSizeChanged', (width, height) => {
on(type: 'error', callback: ErrorCallback): void on(type: 'error', callback: ErrorCallback): void
Subscribes to the video playback error event. Subscribes to video playback error events.
**System capability**: SystemCapability.Multimedia.Media.VideoPlayer **System capability**: SystemCapability.Multimedia.Media.VideoPlayer
...@@ -1656,7 +1656,7 @@ audioRecorder.prepare(audioRecorderConfig) ...@@ -1656,7 +1656,7 @@ audioRecorder.prepare(audioRecorderConfig)
on(type: 'error', callback: ErrorCallback): void on(type: 'error', callback: ErrorCallback): void
Subscribes to the audio recording error event. Subscribes to audio recording error events.
**System capability**: SystemCapability.Multimedia.Media.AudioRecorder **System capability**: SystemCapability.Multimedia.Media.AudioRecorder
...@@ -1692,7 +1692,7 @@ Describes audio recording configurations. ...@@ -1692,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.
先完成此消息的编辑!
想要评论请 注册