Name
|
-Description
+ | Description
|
-playing
+ |
idle
+ |
+Audio playback is idle.
+ |
+
+playing
|
-The audio is being played.
+ | The audio is being played.
|
-paused
+ |
paused
|
-Audio playback is paused.
+ | Audio playback is paused.
|
-stopped
+ |
stopped
|
-Audio playback is stopped.
+ | Audio playback is stopped.
|
diff --git a/en/application-dev/media/development-guidelines-on-audio-playback.md b/en/application-dev/media/development-guidelines-on-audio-playback.md
index 724dda64ec919e3ef0217350bca9039cfbbbc0b7..e9b79f166c2af74fd79bc562f4314e1c9ec98b1c 100755
--- a/en/application-dev/media/development-guidelines-on-audio-playback.md
+++ b/en/application-dev/media/development-guidelines-on-audio-playback.md
@@ -63,6 +63,11 @@ You use audio playback APIs to convert audio data into audible analog signals, p
Stops playback.
|
+reset()7+
+ |
+Resets the audio source to be played.
+ |
+
setVolume(vol: number)
|
Sets playback volume.
@@ -78,17 +83,12 @@ You use audio playback APIs to convert audio data into audible analog signals, p
| Defines the URI of an audio file to play.
|
-state:string
+ |
state:AudioState
|
Defines a playback state.
|
-autoplay:boolean
- |
-Defines whether playback starts automatically.
- |
-
-currenttime:number
+ |
currentTime:number
|
Defines the current playback position.
|
@@ -103,11 +103,6 @@ You use audio playback APIs to convert audio data into audible analog signals, p
Defines whether to loop audio playback.
|
-muted:boolean
- |
-Defines whether to mute the audio.
- |
-
on('play', function callback)
|
Listens for the playback start event.
@@ -123,7 +118,12 @@ You use audio playback APIs to convert audio data into audible analog signals, p
| Listens for the playback stop event.
|
-on('ended',function callback)
+ |
on('reset', function callback)
+ |
+Listens for the playback reset event.
+ |
+
+on('finish',function callback)
|
Listens for the playback end event.
|
@@ -133,7 +133,7 @@ You use audio playback APIs to convert audio data into audible analog signals, p
Listens for the playback error event.
|
-on('loaderdata', function callback)
+ |
on('dataload', function callback)
|
Listens for the data loading event.
|
@@ -143,7 +143,7 @@ You use audio playback APIs to convert audio data into audible analog signals, p
Listens for the volume change event.
|
-on('timeupdate', function callback)
+ |
on('timeUpdate', function callback)
|
Listens for the progress change event.
|
@@ -162,73 +162,70 @@ You use audio playback APIs to convert audio data into audible analog signals, p
```
player.on('play', (err, action) => {
if (err) {
- console.log(`err returned in play() callback`);
+ console.error('Error returned in the play() callback.');
return;
}
- console.info('Current Song duration: '+duration);
- console.log(`In play callback current time: ${player.currentTime}`);
- console.info('Current Player Status: '+player.state);
- console.info('Pause Mp3');
+ console.info('Current player duration: '+ player.duration);
+ console.info('Current player time: ' + player.currentTime);
+ console.info('Current player status: '+player.state);
+ console.info('Pause MP3');
player.pause();
});
player.on('pause', (err, action) => {
if (err) {
- console.log(`err returned in pause() callback`);
+ console.error('Error returned in the pause() callback.');
return;
}
- console.log(`pause callback, state: ${player.state}`);
- console.info('Current Player Status: '+player.state);
- var currentTime = player.currenTime;
- console.info('Current Player Time: '+currentTime);
- player.seek(30000); //seek for 30 seconds
+ console.info('Current player status: ' + player.state);
+ console.info('Current player time: ' + player.currentTime);
+ player.seek(30000); // Seek for 30 seconds.
});
player.on('stop', (err, action) => {
if (err) {
- console.log(`err returned in stop() callback`);
+ console.error('Error returned in the stop() callback.');
return;
}
- console.log(`stop callback, state: ${player.state}`);
+ console.info('stop callback invoked. State:' + player.state);
+ player.reset();
});
player.on('dataLoad', (err, action) => {
if (err) {
- console.log(`err returned in dataLoad() callback`);
+ console.error('Error returned in the dataLoad() callback.');
return;
}
- console.log(`dataLoad callback is called, current time: ${player.currentTime}`);
- console.log(`Duration of the source: ${player.duration}`);
+ console.info('dataLoad callback invoked. Current time: ' + player.currentTime);
+ console.info('Duration of the source:' + player.duration);
+ player.play();
+ });
+ player.on('reset', (err, action) => {
+ if (err) {
+ console.error('Error returned in the reset() callback.');
+ return;
+ }
+ console.info('reset callback invoked.');
+ player.release();
});
player.on('finish', (err, action) => {
if (err) {
- console.log(`err returned in finish() callback`);
+ console.error('Error returned in the finish() callback.');
return;
}
- console.log(`Player finish callback is called`);
+ console.info('finish callback invoked.');
});
- player.on('timeUpdate', (err, action) => {
- if (err) {
- console.log(`err returned in timeUpdate() callback`);
- return;
- }
- console.log(`In timeupdate callback current time: ${player.currentTime}`);
+ player.on('timeUpdate', (seekTime, action) => {
+ console.info('Seek time: ' + seekTime);
+ console.info('Current player time: ' + player.currentTime);
var newTime = player.currentTime;
- if(newTime = 30000) {
- console.info('Seek success, new time : '+newTime);
+ if(newTime == 30000) {
+ console.info('Seek succeeded. New time: ' + newTime);
} else {
- console.info('Seek Failed');
+ console.error('Seek failed: ', + newTime);
}
player.stop();
});
- player.on('durationchange', (err, action) => {
- if (err) {
- console.log(`err returned in durationchange callback`);
- return;
- }
- console.log(`Durationchange callback is called`);
- });
player.on('error', (err) => {
- console.error(`player error: ${err.message}`);
+ console.error('Player error: ${err.message}');
});
-
```
3. Start playback.
@@ -237,7 +234,6 @@ You use audio playback APIs to convert audio data into audible analog signals, p
var audioSourceMp3 = 'file://test.mp3';
player.src = audioSourceMp3;
player.loop = true;
- player.play();
```
diff --git a/en/application-dev/media/figures/playback-status.png b/en/application-dev/media/figures/playback-status.png
index 8723a59a5edcbadec16133c71bc772907882c54a..e0777e28838f6d2455233f2068339f8548f50c67 100755
Binary files a/en/application-dev/media/figures/playback-status.png and b/en/application-dev/media/figures/playback-status.png differ