diff --git a/framework/assets/js/media.js b/framework/assets/js/media.js index 0b9155cb..de077cd9 100755 --- a/framework/assets/js/media.js +++ b/framework/assets/js/media.js @@ -155,6 +155,13 @@ Media.prototype.stop = function() { 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. */ diff --git a/framework/gen/com/phonegap/R.java b/framework/gen/com/phonegap/R.java index 7db0ceb3..069b71c4 100644 --- a/framework/gen/com/phonegap/R.java +++ b/framework/gen/com/phonegap/R.java @@ -1,27 +1,27 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package com.phonegap; - -public final class R { - public static final class attr { - } - public static final class drawable { - public static final int icon=0x7f020000; - public static final int splash=0x7f020001; - } - public static final class id { - public static final int appView=0x7f050000; - } - public static final class layout { - public static final int main=0x7f030000; - } - public static final class string { - public static final int app_name=0x7f040000; - public static final int go=0x7f040001; - } -} +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package com.phonegap; + +public final class R { + public static final class attr { + } + public static final class drawable { + public static final int icon=0x7f020000; + public static final int splash=0x7f020001; + } + public static final class id { + public static final int appView=0x7f050000; + } + public static final class layout { + public static final int main=0x7f030000; + } + public static final class string { + public static final int app_name=0x7f040000; + public static final int go=0x7f040001; + } +} diff --git a/framework/src/com/phonegap/AudioHandler.java b/framework/src/com/phonegap/AudioHandler.java index 33d05805..e8cb59f5 100755 --- a/framework/src/com/phonegap/AudioHandler.java +++ b/framework/src/com/phonegap/AudioHandler.java @@ -63,6 +63,9 @@ public class AudioHandler extends Plugin { else if (action.equals("startPlayingAudio")) { 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")) { this.pausePlayingAudio(args.getString(0)); } @@ -181,6 +184,19 @@ public class AudioHandler extends Plugin { 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. * diff --git a/framework/src/com/phonegap/AudioPlayer.java b/framework/src/com/phonegap/AudioPlayer.java index 849ca44d..ddf23cfb 100755 --- a/framework/src/com/phonegap/AudioPlayer.java +++ b/framework/src/com/phonegap/AudioPlayer.java @@ -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. */