From 28f125ae64434a72c72c08f3bcf87a65d46c619b Mon Sep 17 00:00:00 2001 From: Penn Su Date: Mon, 3 Nov 2014 21:46:26 -0800 Subject: [PATCH 1/3] Send EXTRA_OUTPUT for captureVideo as well to fix a bug where the video file is not saved correctly --- src/android/Capture.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/android/Capture.java b/src/android/Capture.java index a32a9e68..68b9f0b5 100644 --- a/src/android/Capture.java +++ b/src/android/Capture.java @@ -253,6 +253,18 @@ private void captureVideo(int duration) { if(Build.VERSION.SDK_INT > 7){ intent.putExtra("android.intent.extra.durationLimit", duration); } + + // Specify file so video is captured and returned + File video = new File(getTempDirectoryPath(), "Capture.mp4"); + try { + // the ACTION_IMAGE_CAPTURE is run under different credentials and has to be granted write permissions + createWritableFile(video); + } catch (IOException ex) { + this.fail(createErrorObject(CAPTURE_INTERNAL_ERR, ex.toString())); + return; + } + intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(video)); + this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_VIDEO); } @@ -367,7 +379,7 @@ public void run() { } if( data == null){ - File movie = new File(getTempDirectoryPath(), "Capture.avi"); + File movie = new File(getTempDirectoryPath(), "Capture.mp4"); data = Uri.fromFile(movie); } From 2514e401c029ebb5a2cf9d203a65a292cecd3769 Mon Sep 17 00:00:00 2001 From: Penn Su Date: Mon, 3 Nov 2014 22:05:37 -0800 Subject: [PATCH 2/3] Change tmpdirectory to externalsotragedirectory --- src/android/Capture.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/android/Capture.java b/src/android/Capture.java index 68b9f0b5..f6c32695 100644 --- a/src/android/Capture.java +++ b/src/android/Capture.java @@ -206,14 +206,7 @@ private void captureAudio() { } private String getTempDirectoryPath() { - File cache = null; - - // Use internal storage - cache = cordova.getActivity().getCacheDir(); - - // Create the cache directory if it doesn't exist - cache.mkdirs(); - return cache.getAbsolutePath(); + return Environment.getExternalStorageDirectory().getAbsolutePath() } /** From 37a394540e006d93fe4216fe3284be9671df744f Mon Sep 17 00:00:00 2001 From: Penn Su Date: Mon, 3 Nov 2014 22:10:00 -0800 Subject: [PATCH 3/3] Add the missing semicolon --- src/android/Capture.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/Capture.java b/src/android/Capture.java index f6c32695..b72b0b74 100644 --- a/src/android/Capture.java +++ b/src/android/Capture.java @@ -206,7 +206,7 @@ private void captureAudio() { } private String getTempDirectoryPath() { - return Environment.getExternalStorageDirectory().getAbsolutePath() + return Environment.getExternalStorageDirectory().getAbsolutePath(); } /**