@@ -20,7 +20,7 @@ For details about the APIs used for audio playback, see [js-apis-media.md](../re
...
@@ -20,7 +20,7 @@ For details about the APIs used for audio playback, see [js-apis-media.md](../re
### Full-Process Scenario
### 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).
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) {
...
@@ -82,7 +82,7 @@ function printfDescription(obj) {
// 1. Create an audioPlayer instance.
// 1. Create an audioPlayer instance.
letaudioPlayer=media.createAudioPlayer();
letaudioPlayer=media.createAudioPlayer();
SetCallBack(audioPlayer);// Set the event callbacks.
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.
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.
// 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.
// 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.
// 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.
// 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.
// 9. Release resources.
audioRecorder.release();// The AudioRecorder resource is destroyed.
audioRecorder.release();// The AudioRecorder resource is destroyed.
audioRecorder=undefined;
audioRecorder=undefined;
...
@@ -185,9 +185,9 @@ let audioRecorderConfig = {
...
@@ -185,9 +185,9 @@ let audioRecorderConfig = {
}
}
audioRecorder.prepare(audioRecorderConfig)
audioRecorder.prepare(audioRecorderConfig)
// 4. Start recording.
// 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.
// 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.
// 6. Release resources.
audioRecorder.release();// The AudioRecorder resource is destroyed.
audioRecorder.release();// The AudioRecorder resource is destroyed.
@@ -36,10 +36,10 @@ For details about how to create an Xcomponent, see [Xcomponent Creation](#Xcompo
...
@@ -36,10 +36,10 @@ For details about how to create an Xcomponent, see [Xcomponent Creation](#Xcompo
importmediafrom'@ohos.multimedia.media'
importmediafrom'@ohos.multimedia.media'
importfileIOfrom'@ohos.fileio'
importfileIOfrom'@ohos.fileio'
letvideoPlayer=undefined;// Used to store instances created by calling the createVideoPlayer method.
letvideoPlayer=undefined;// Used to store instances created by calling the createVideoPlayer API.
letsurfaceID=undefined;// Used to save the surface ID returned by the Xcomponent interface.
letsurfaceID=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.
letvideoPlayer=undefined;// Used to store instances created by calling the createVideoPlayer method.
letvideoPlayer=undefined;// Used to store instances created by calling the createVideoPlayer API.
letsurfaceID=undefined;// Used to save the surface ID returned by the Xcomponent interface.
letsurfaceID=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.
letvideoPlayer=undefined;// Used to store instances created by calling the createVideoPlayer method.
letvideoPlayer=undefined;// Used to store instances created by calling the createVideoPlayer API.
letsurfaceID=undefined;// Used to save the surface ID returned by the Xcomponent interface.
letsurfaceID=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.
letvideoPlayer=undefined;// Used to store instances created by calling the createVideoPlayer method.
letvideoPlayer=undefined;// Used to store instances created by calling the createVideoPlayer API.
letsurfaceID=undefined;// Used to save the surface ID returned by the Xcomponent interface.
letsurfaceID=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.
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:
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
<xcomponentid='Xcomponent'
<xcomponentid='Xcomponent'
if="{{isFlush}}"// Refresh the surface ID. To enable automatic loading of the Xcomponent and obtain the new surface ID, assign **false** to **isFlush** and then assign **true** to **isFlush**.
if="{{isFlush}}"// Refresh the surface ID. To enable automatic loading of the Xcomponent and obtain the new surface ID, assign **false** to **isFlush** and then assign **true** to **isFlush**.