mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-12 18:56:11 +08:00
Merge pull request #78 from kernelsandirs/master
Added Media.seekTo(int milliseconds); Merging this code in now and making some notes to enhance the Media class.
This commit is contained in:
commit
e84c59d23c
@ -157,6 +157,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,20 @@ 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