cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [5/8] git commit: CB-6051: Android: Allow media plugin to handle invalid file locations
Date Fri, 28 Feb 2014 21:36:15 GMT
CB-6051: Android: Allow media plugin to handle invalid file locations


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/commit/b365d09e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/tree/b365d09e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/diff/b365d09e

Branch: refs/heads/master
Commit: b365d09ec3f3c61f0922f3ba1d8c12ccf4300dab
Parents: f96f2ac
Author: Ian Clelland <iclelland@chromium.org>
Authored: Fri Feb 21 13:18:23 2014 -0500
Committer: Ian Clelland <iclelland@chromium.org>
Committed: Fri Feb 21 13:20:03 2014 -0500

----------------------------------------------------------------------
 src/android/AudioHandler.java | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/b365d09e/src/android/AudioHandler.java
----------------------------------------------------------------------
diff --git a/src/android/AudioHandler.java b/src/android/AudioHandler.java
index 40f7ea9..45e6837 100644
--- a/src/android/AudioHandler.java
+++ b/src/android/AudioHandler.java
@@ -71,15 +71,29 @@ public class AudioHandler extends CordovaPlugin {
         String result = "";
 
         if (action.equals("startRecordingAudio")) {
-            Uri fileUri = resourceApi.remapUri(Uri.parse(args.getString(1)));
-            this.startRecordingAudio(args.getString(0), FileHelper.stripFileProtocol(fileUri.toString()));
+            String target = args.getString(1);
+            String fileUriStr;
+            try {
+                Uri targetUri = resourceApi.remapUri(Uri.parse(target));
+                fileUriStr = targetUri.toString();
+            } catch (IllegalArgumentException e) {
+                fileUriStr = target;
+            }
+            this.startRecordingAudio(args.getString(0), FileHelper.stripFileProtocol(fileUriStr));
         }
         else if (action.equals("stopRecordingAudio")) {
             this.stopRecordingAudio(args.getString(0));
         }
         else if (action.equals("startPlayingAudio")) {
-            Uri fileUri = resourceApi.remapUri(Uri.parse(args.getString(1)));
-            this.startPlayingAudio(args.getString(0), FileHelper.stripFileProtocol(fileUri.toString()));
+            String target = args.getString(1);
+            String fileUriStr;
+            try {
+                Uri targetUri = resourceApi.remapUri(Uri.parse(target));
+                fileUriStr = targetUri.toString();
+            } catch (IllegalArgumentException e) {
+                fileUriStr = target;
+            }
+            this.startPlayingAudio(args.getString(0), FileHelper.stripFileProtocol(fileUriStr));
         }
         else if (action.equals("seekToAudio")) {
             this.seekToAudio(args.getString(0), args.getInt(1));


Mime
View raw message