From f9675c4c9aaceb0e288b025c6ca0308765a78b24 Mon Sep 17 00:00:00 2001 From: wusongqing Date: Wed, 23 Mar 2022 15:53:05 +0800 Subject: [PATCH] updated docs Signed-off-by: wusongqing --- en/application-dev/media/audio-playback.md | 18 ++++++++--------- en/application-dev/media/audio-recorder.md | 14 ++++++------- en/application-dev/media/video-playback.md | 23 +++++++++++----------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/en/application-dev/media/audio-playback.md b/en/application-dev/media/audio-playback.md index 922e215887..a8ea5a537f 100644 --- a/en/application-dev/media/audio-playback.md +++ b/en/application-dev/media/audio-playback.md @@ -20,7 +20,7 @@ For details about the APIs used for audio playback, see [js-apis-media.md](../re ### Full-Process Scenario -The full audio playback process includes creating an instance, setting the URI, playing audio, seeking to the playback position, setting the volume, pausing playback, obtaining track information, stopping playback, resetting resources, and releasing resources. +The full audio playback process includes creating an instance, setting the URI, playing audio, seeking to the playback position, setting the volume, pausing playback, obtaining track information, stopping playback, resetting the player, and releasing resources. For details about the **src** media source input types supported by **AudioPlayer**, see the [src attribute](../reference/apis/js-apis-media.md#audioplayer_attributes). @@ -82,7 +82,7 @@ function printfDescription(obj) { // 1. Create an audioPlayer instance. let audioPlayer = media.createAudioPlayer(); SetCallBack(audioPlayer); // Set the event callbacks. -// 2. Set the URI of the audio file. +// 2. Set the URI of the audio file selected by the user. let fdPath = 'fd://' let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; await fileIO.open(path).then(fdNumber) => { @@ -95,8 +95,8 @@ await fileIO.open(path).then(fdNumber) => { }); audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. -// 3. Play the audio. -audioPlayer.play(); // The play() method can be invoked only after the 'dataLoad' event callback is complete. The 'play' event callback is triggered. +// 3. Play the audio file. +audioPlayer.play(); // The play() API can be invoked only after the 'dataLoad' event callback is complete. The 'play' event callback is triggered. // 4. Seek to the playback position. audioPlayer.seek(30000); // Trigger the 'timeUpdate' event callback, and seek to 30000 ms for playback. // 5. Set the volume. @@ -113,9 +113,9 @@ audioPlayer.getTrackDescription((error, arrlist) => { // Obtain the audio track console.log(`audio getTrackDescription fail, error:${error.message}`); } }); -// 8. Stop playback. +// 8. Stop the playback. audioPlayer.stop(); // Trigger the 'stop' event callback. -// 9. Reset the playback resources. +// 9. Reset the player. audioPlayer.reset(); // Trigger the 'reset' event callback, and reconfigure the src attribute to switch to the next song. // 10. Release the resource. audioPlayer.release(); // Release the AudioPlayer instance. @@ -131,7 +131,7 @@ import fileIO from '@ohos.fileio' function SetCallBack(audioPlayer) { audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); - audioPlayer.play(); // Call the play() method 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', () => { // Set the 'play' event callback. console.info('audio play success'); @@ -169,7 +169,7 @@ import fileIO from '@ohos.fileio' function SetCallBack(audioPlayer) { audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); - audioPlayer.play(); // Call the play() method 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', () => { // Set the 'play' event callback. console.info('audio play success'); @@ -222,7 +222,7 @@ import fileIO from '@ohos.fileio' function SetCallBack(audioPlayer) { audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); - audioPlayer.play(); // Call the play() method 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', () => { // Set the 'play' event callback. console.info('audio play success'); diff --git a/en/application-dev/media/audio-recorder.md b/en/application-dev/media/audio-recorder.md index 0eed7ce6e2..138b1de2de 100644 --- a/en/application-dev/media/audio-recorder.md +++ b/en/application-dev/media/audio-recorder.md @@ -103,15 +103,15 @@ let audioRecorderConfig = { } audioRecorder.prepare(audioRecorderConfig); // 4. Start recording. -audioRecorder.start(); // The start method can be called to trigger the 'start' event callback only after the 'prepare' event callback is complete. +audioRecorder.start(); // The start API can be called to trigger the 'start' event callback only after the 'prepare' event callback is complete. // 5. Pause recording. -audioRecorder.pause(); // The pause method can be called to trigger the 'pause' event callback only after the 'start' event callback is complete. +audioRecorder.pause(); // The pause API can be called to trigger the 'pause' event callback only after the 'start' event callback is complete. // 6. Resume recording. -audioRecorder.resume(); // The resume method can be called to trigger the 'resume' event callback only after the 'pause' event callback is complete. +audioRecorder.resume(); // The resume API can be called to trigger the 'resume' event callback only after the 'pause' event callback is complete. // 7. Stop recording. -audioRecorder.stop(); // The stop method can be called to trigger the 'stop' event callback only after the 'start' or 'resume' event callback is complete. +audioRecorder.stop(); // The stop API can be called to trigger the 'stop' event callback only after the 'start' or 'resume' event callback is complete. // 8. Reset recording. -audioRecorder.reset(); // The prepare method can be called for another recording only after the 'reset' event callback is complete. +audioRecorder.reset(); // The prepare API can be called for another recording only after the 'reset' event callback is complete. // 9. Release resources. audioRecorder.release(); // The AudioRecorder resource is destroyed. audioRecorder = undefined; @@ -185,9 +185,9 @@ let audioRecorderConfig = { } audioRecorder.prepare(audioRecorderConfig) // 4. Start recording. -audioRecorder.start(); // The start method can be called to trigger the 'start' event callback only after the 'prepare' event callback is complete. +audioRecorder.start(); // The start API can be called to trigger the 'start' event callback only after the 'prepare' event callback is complete. // 5. Stop recording. -audioRecorder.stop(); // The stop method can be called to trigger the 'stop' event callback only after the 'start' or 'resume' event callback is complete. +audioRecorder.stop(); // The stop API can be called to trigger the 'stop' event callback only after the 'start' or 'resume' event callback is complete. // 6. Release resources. audioRecorder.release(); // The AudioRecorder resource is destroyed. audioRecorder = undefined; diff --git a/en/application-dev/media/video-playback.md b/en/application-dev/media/video-playback.md index 29a31dcc5f..05b002296f 100644 --- a/en/application-dev/media/video-playback.md +++ b/en/application-dev/media/video-playback.md @@ -36,10 +36,10 @@ For details about how to create an Xcomponent, see [Xcomponent Creation](#Xcompo import media from '@ohos.multimedia.media' import fileIO from '@ohos.fileio' -let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer method. +let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API. let surfaceID = undefined; // Used to save the surface ID returned by the Xcomponent interface. -// The LoadXcomponent() method is used to obtain the surface ID and save it to the **surfaceID** variable. This method is automatically called when the Xcomponent is loaded. +// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the Xcomponent is loaded. LoadXcomponent() { surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); console.info('LoadXcomponent surfaceID is' + surfaceID); @@ -170,10 +170,10 @@ surfaceID = undefined; import media from '@ohos.multimedia.media' import fileIO from '@ohos.fileio' -let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer method. +let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API. let surfaceID = undefined; // Used to save the surface ID returned by the Xcomponent interface. -// The LoadXcomponent() method is used to obtain the surface ID and save it to the **surfaceID** variable. This method is automatically called when the Xcomponent is loaded. +// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the Xcomponent is loaded. LoadXcomponent() { surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); console.info('LoadXcomponent surfaceID is' + surfaceID); @@ -256,10 +256,10 @@ await videoPlayer.play().then(() => { import media from '@ohos.multimedia.media' import fileIO from '@ohos.fileio' -let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer method. +let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API. let surfaceID = undefined; // Used to save the surface ID returned by the Xcomponent interface. -// The LoadXcomponent() method is used to obtain the surface ID and save it to the **surfaceID** variable. This method is automatically called when the Xcomponent is loaded. +// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the Xcomponent is loaded. LoadXcomponent() { surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); console.info('LoadXcomponent surfaceID is' + surfaceID); @@ -377,10 +377,10 @@ await videoPlayer.play().then(() => { import media from '@ohos.multimedia.media' import fileIO from '@ohos.fileio' -let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer method. +let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API. let surfaceID = undefined; // Used to save the surface ID returned by the Xcomponent interface. -// The LoadXcomponent() method is used to obtain the surface ID and save it to the **surfaceID** variable. This method is automatically called when the Xcomponent is loaded. +// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the Xcomponent is loaded. LoadXcomponent() { surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); console.info('LoadXcomponent surfaceID is' + surfaceID); @@ -462,12 +462,13 @@ await videoPlayer.play().then(() => { ### Xcomponent Creation -```js The Xcomponent is used to obtain the surface ID during video playback. You need to create an xxx.hml file and add the following code to the xxx.hml file, where xxx is the same as that in the xxx.js file: + +```js // Set the window width, height, and other attributes. ``` -- GitLab