From 369d1400407729dada9467f27921bbf799f07dfe Mon Sep 17 00:00:00 2001 From: macdonst Date: Wed, 12 Oct 2011 10:17:32 -0400 Subject: [PATCH 1/4] Return MediaError object instead of value --- framework/assets/js/media.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/assets/js/media.js b/framework/assets/js/media.js index f530025c..cdae8451 100755 --- a/framework/assets/js/media.js +++ b/framework/assets/js/media.js @@ -211,7 +211,7 @@ PhoneGap.Media.onStatus = function(id, msg, value) { } else if (msg === Media.MEDIA_ERROR) { if (media.errorCallback) { - media.errorCallback(value); + media.errorCallback({"code":value}); } } else if (msg == Media.MEDIA_POSITION) { From 551f0f7e4a386feeb9d0a35f2f1a6a8e7aa72601 Mon Sep 17 00:00:00 2001 From: macdonst Date: Wed, 19 Oct 2011 15:22:50 -0400 Subject: [PATCH 2/4] Normalize MediaError's with iOS --- framework/assets/js/media.js | 1 + framework/src/com/phonegap/AudioPlayer.java | 33 ++++++++++----------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/framework/assets/js/media.js b/framework/assets/js/media.js index cdae8451..dc99b171 100755 --- a/framework/assets/js/media.js +++ b/framework/assets/js/media.js @@ -84,6 +84,7 @@ var MediaError = function() { this.message = ""; }; +MediaError.MEDIA_ERR_NONE_ACTIVE = 0; MediaError.MEDIA_ERR_ABORTED = 1; MediaError.MEDIA_ERR_NETWORK = 2; MediaError.MEDIA_ERR_DECODE = 3; diff --git a/framework/src/com/phonegap/AudioPlayer.java b/framework/src/com/phonegap/AudioPlayer.java index e2f10680..b4aa9a14 100755 --- a/framework/src/com/phonegap/AudioPlayer.java +++ b/framework/src/com/phonegap/AudioPlayer.java @@ -45,16 +45,13 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On private static int MEDIA_POSITION = 3; private static int MEDIA_ERROR = 9; - // AudioPlayer error codes - private static int MEDIA_ERROR_PLAY_MODE_SET = 1; - private static int MEDIA_ERROR_ALREADY_RECORDING = 2; - private static int MEDIA_ERROR_STARTING_RECORDING = 3; - private static int MEDIA_ERROR_RECORD_MODE_SET = 4; - private static int MEDIA_ERROR_STARTING_PLAYBACK = 5; - private static int MEDIA_ERROR_RESUME_STATE = 6; - private static int MEDIA_ERROR_PAUSE_STATE = 7; - private static int MEDIA_ERROR_STOP_STATE = 8; - + // Media error codes + private static int MEDIA_ERR_NONE_ACTIVE = 0; + private static int MEDIA_ERR_ABORTED = 1; + private static int MEDIA_ERR_NETWORK = 2; + private static int MEDIA_ERR_DECODE = 3; + private static int MEDIA_ERR_NONE_SUPPORTED = 4; + private AudioHandler handler; // The AudioHandler object private String id; // The id of this player (used to identify Media object in JavaScript) private int state = MEDIA_NONE; // State of recording or playback @@ -108,7 +105,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On public void startRecording(String file) { if (this.mPlayer != null) { Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode."); - this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERROR_PLAY_MODE_SET+");"); + this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");"); } // Make sure we're not already recording @@ -129,11 +126,11 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On } catch (IOException e) { e.printStackTrace(); } - this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERROR_STARTING_RECORDING+");"); + this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");"); } else { Log.d(LOG_TAG, "AudioPlayer Error: Already recording."); - this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERROR_ALREADY_RECORDING+");"); + this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");"); } } @@ -175,7 +172,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On public void startPlaying(String file) { if (this.recorder != null) { Log.d(LOG_TAG, "AudioPlayer Error: Can't play in record mode."); - this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERROR_RECORD_MODE_SET+");"); + this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");"); } // If this is a new request to play audio, or stopped @@ -220,7 +217,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On } catch (Exception e) { e.printStackTrace(); - this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERROR_STARTING_PLAYBACK+");"); + this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");"); } } @@ -234,7 +231,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On } else { Log.d(LOG_TAG, "AudioPlayer Error: startPlaying() called during invalid state: "+this.state); - this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERROR_RESUME_STATE+");"); + this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");"); } } } @@ -262,7 +259,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On } else { Log.d(LOG_TAG, "AudioPlayer Error: pausePlaying() called during invalid state: "+this.state); - this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERROR_PAUSE_STATE+");"); + this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");"); } } @@ -276,7 +273,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On } else { Log.d(LOG_TAG, "AudioPlayer Error: stopPlaying() called during invalid state: "+this.state); - this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERROR_STOP_STATE+");"); + this.handler.sendJavascript("PhoneGap.Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");"); } } From a8db71cd677b30eeceb8147203be243099be5381 Mon Sep 17 00:00:00 2001 From: macdonst Date: Thu, 20 Oct 2011 16:26:30 -0400 Subject: [PATCH 3/4] Updating to use Android 4.0 build environment --- framework/.classpath | 2 +- framework/AndroidManifest.xml | 18 +++--- framework/ant.properties | 17 ++++++ framework/build.xml | 112 ++++++++++++++++++++-------------- framework/default.properties | 2 +- framework/project.properties | 14 +++++ 6 files changed, 107 insertions(+), 58 deletions(-) create mode 100644 framework/ant.properties mode change 100755 => 100644 framework/build.xml create mode 100644 framework/project.properties diff --git a/framework/.classpath b/framework/.classpath index ff33dbc2..ae95abc5 100644 --- a/framework/.classpath +++ b/framework/.classpath @@ -4,5 +4,5 @@ - + diff --git a/framework/AndroidManifest.xml b/framework/AndroidManifest.xml index c0c6e090..73609bea 100644 --- a/framework/AndroidManifest.xml +++ b/framework/AndroidManifest.xml @@ -2,12 +2,12 @@ + android:largeScreens="true" + android:normalScreens="true" + android:smallScreens="true" + android:resizeable="true" + android:anyDensity="true" + /> @@ -31,7 +31,7 @@ + android:debuggable="true"> @@ -46,5 +46,5 @@ - - + + \ No newline at end of file diff --git a/framework/ant.properties b/framework/ant.properties new file mode 100644 index 00000000..ee52d86d --- /dev/null +++ b/framework/ant.properties @@ -0,0 +1,17 @@ +# This file is used to override default values used by the Ant build system. +# +# This file must be checked in Version Control Systems, as it is +# integral to the build system of your project. + +# This file is only used by the Ant script. + +# You can use this to override default values such as +# 'source.dir' for the location of your java source folder and +# 'out.dir' for the location of your output folder. + +# You can also use it define how the release builds are signed by declaring +# the following properties: +# 'key.store' for the location of your keystore and +# 'key.alias' for the name of the key to use. +# The password will be asked during the build when you use the 'release' target. + diff --git a/framework/build.xml b/framework/build.xml old mode 100755 new mode 100644 index 9c9a52b8..afbc7e2f --- a/framework/build.xml +++ b/framework/build.xml @@ -9,70 +9,89 @@ - + It contains the path to the SDK. It should *NOT* be checked into + Version Control Systems. --> + - - - - - + " - - - - - - - - + + - The rules file is imported from - /platforms//templates/android_rules.xml + + - To customize some build steps for your project: - - copy the content of the main node from android_rules.xml - - paste it in this build.xml below the task. - - disable the import by changing the setup task below to - This will ensure that the properties are setup correctly but that your customized - build steps are used. + + + + - + + + @@ -133,7 +152,7 @@ - + @@ -143,5 +162,4 @@ - diff --git a/framework/default.properties b/framework/default.properties index aa2fcdf7..d035c7c6 100644 --- a/framework/default.properties +++ b/framework/default.properties @@ -10,5 +10,5 @@ # Indicates whether an apk should be generated for each density. split.density=false # Project target. -target=android-12 +target=android-14 apk-configurations= diff --git a/framework/project.properties b/framework/project.properties new file mode 100644 index 00000000..16d0a5d9 --- /dev/null +++ b/framework/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "ant.properties", and override values to adapt the script to your +# project structure. + +# Indicates whether an apk should be generated for each density. +split.density=false +# Project target. +target=Google Inc.:Google APIs:9 +apk-configurations= From e26685becf8ecec56909d82934c9044c2a3c11c2 Mon Sep 17 00:00:00 2001 From: macdonst Date: Thu, 20 Oct 2011 16:48:16 -0400 Subject: [PATCH 4/4] Fixing Project Properties file --- framework/project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/project.properties b/framework/project.properties index 16d0a5d9..247ca66e 100644 --- a/framework/project.properties +++ b/framework/project.properties @@ -10,5 +10,5 @@ # Indicates whether an apk should be generated for each density. split.density=false # Project target. -target=Google Inc.:Google APIs:9 +target=android-14 apk-configurations=