forked from github/cordova-android
Added Media.seekTo(int milliseconds);
This commit is contained in:
parent
58ecac335b
commit
b94eedaf07
@ -155,6 +155,13 @@ Media.prototype.stop = function() {
|
|||||||
return PhoneGap.exec(null, null, "Media", "stopPlayingAudio", [this.id]);
|
return PhoneGap.exec(null, null, "Media", "stopPlayingAudio", [this.id]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seek or jump to a new time in the track.
|
||||||
|
*/
|
||||||
|
Media.prototype.seekTo = function(milliseconds) {
|
||||||
|
PhoneGap.exec(null, null, "Media", "seekToAudio", [this.id, milliseconds]);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pause playing audio file.
|
* Pause playing audio file.
|
||||||
*/
|
*/
|
||||||
|
@ -63,6 +63,9 @@ public class AudioHandler extends Plugin {
|
|||||||
else if (action.equals("startPlayingAudio")) {
|
else if (action.equals("startPlayingAudio")) {
|
||||||
this.startPlayingAudio(args.getString(0), args.getString(1));
|
this.startPlayingAudio(args.getString(0), args.getString(1));
|
||||||
}
|
}
|
||||||
|
else if (action.equals("seekToAudio")) {
|
||||||
|
this.seekToAudio(args.getString(0), args.getInt(1));
|
||||||
|
}
|
||||||
else if (action.equals("pausePlayingAudio")) {
|
else if (action.equals("pausePlayingAudio")) {
|
||||||
this.pausePlayingAudio(args.getString(0));
|
this.pausePlayingAudio(args.getString(0));
|
||||||
}
|
}
|
||||||
@ -181,6 +184,19 @@ public class AudioHandler extends Plugin {
|
|||||||
audio.startPlaying(file);
|
audio.startPlaying(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seek to a location.
|
||||||
|
*
|
||||||
|
* @param id The id of the audio player
|
||||||
|
* @param miliseconds int: number of milliseconds to skip 1000 = 1 second
|
||||||
|
*/
|
||||||
|
public void seekToAudio(String id, int milliseconds) {
|
||||||
|
AudioPlayer audio = this.players.get(id);
|
||||||
|
if (audio != null) {
|
||||||
|
audio.seekToPlaying(milliseconds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pause playing.
|
* Pause playing.
|
||||||
*
|
*
|
||||||
|
@ -233,6 +233,15 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seek or jump to a new time in the track.
|
||||||
|
*/
|
||||||
|
public void seekToPlaying(int milliseconds) {
|
||||||
|
if (this.mPlayer != null) {
|
||||||
|
this.mPlayer.seekTo(milliseconds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pause playing.
|
* Pause playing.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user