From b94eedaf07e1fd9fafff599a5c73016f9a8d923a Mon Sep 17 00:00:00 2001 From: kernelsandirs Date: Tue, 3 May 2011 21:27:08 -0700 Subject: [PATCH 1/2] Added Media.seekTo(int milliseconds); --- framework/assets/js/media.js | 7 +++ framework/gen/com/phonegap/R.java | 54 ++++++++++---------- framework/src/com/phonegap/AudioHandler.java | 16 ++++++ framework/src/com/phonegap/AudioPlayer.java | 9 ++++ 4 files changed, 59 insertions(+), 27 deletions(-) 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. */ From ffbc010d7bd7503bbfcfb8889f66b4565486dd71 Mon Sep 17 00:00:00 2001 From: kernelsandirs Date: Wed, 4 May 2011 11:51:26 -0700 Subject: [PATCH 2/2] Added Media.seekTo(int milliseconds); --- framework/assets/js/media.js | 2 +- framework/src/com/phonegap/AudioHandler.java | 1 + framework/src/com/phonegap/AudioPlayer.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/assets/js/media.js b/framework/assets/js/media.js index de077cd9..c16a8d71 100755 --- a/framework/assets/js/media.js +++ b/framework/assets/js/media.js @@ -156,7 +156,7 @@ Media.prototype.stop = function() { }; /** - * Seek or jump to a new time in the track. + * Seek or jump to a new time in the track.. */ Media.prototype.seekTo = function(milliseconds) { PhoneGap.exec(null, null, "Media", "seekToAudio", [this.id, milliseconds]); diff --git a/framework/src/com/phonegap/AudioHandler.java b/framework/src/com/phonegap/AudioHandler.java index e8cb59f5..cd16b1b9 100755 --- a/framework/src/com/phonegap/AudioHandler.java +++ b/framework/src/com/phonegap/AudioHandler.java @@ -186,6 +186,7 @@ public class AudioHandler extends Plugin { /** * Seek to a location. + * * * @param id The id of the audio player * @param miliseconds int: number of milliseconds to skip 1000 = 1 second diff --git a/framework/src/com/phonegap/AudioPlayer.java b/framework/src/com/phonegap/AudioPlayer.java index ddf23cfb..f0b3da14 100755 --- a/framework/src/com/phonegap/AudioPlayer.java +++ b/framework/src/com/phonegap/AudioPlayer.java @@ -238,7 +238,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On */ public void seekToPlaying(int milliseconds) { if (this.mPlayer != null) { - this.mPlayer.seekTo(milliseconds); + this.mPlayer.seekTo(milliseconds); } }