Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/android/Capture.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -253,6 +246,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);
}

Expand Down Expand Up @@ -367,7 +372,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);
}

Expand Down