Commit d0efdf84 authored by ylwu's avatar ylwu Committed by Gerrit Review System

changed the location clips are stored in camcorder component. Instead

of creating a /Video folder and store it inside, we store the video in
the place where video clips are usually stored using camcorder.

Change-Id: Id2d78897535e579b9ecb69ce85e9aefc79f113bc
parent 5be74dbb
......@@ -42,9 +42,7 @@ public class Camcorder extends AndroidNonvisibleComponent
implements ActivityResultListener, Component {
private static final String CAMCORDER_INTENT = "android.media.action.VIDEO_CAPTURE";
private static final String CAMCORDER_OUTPUT = "output";
private final ComponentContainer container;
private Uri clipFile;
/* Used to identify the call to startActivityForResult. Will be passed back
into the resultReturned() callback method. */
......@@ -65,29 +63,16 @@ public class Camcorder extends AndroidNonvisibleComponent
*/
@SimpleFunction
public void RecordVideo() {
Date date = new Date();
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
Log.i("CamcorderComponent", "External storage is available and writable");
clipFile = Uri.fromFile(new File(Environment.getExternalStorageDirectory(),
"/Video/app_inventor_" + date.getTime()
+ ".3gp"));
ContentValues values = new ContentValues();
values.put(MediaStore.Video.Media.DATA, clipFile.getPath());
values.put(MediaStore.Video.Media.MIME_TYPE, "clip/3gp");
values.put(MediaStore.Video.Media.TITLE, clipFile.getLastPathSegment());
if (requestCode == 0) {
requestCode = form.registerForActivityResult(this);
}
Uri clipUri = container.$context().getContentResolver().insert(
MediaStore.Video.Media.INTERNAL_CONTENT_URI, values);
Intent intent = new Intent(CAMCORDER_INTENT);
intent.putExtra(CAMCORDER_OUTPUT, clipUri);
container.$context().startActivityForResult(intent, requestCode);
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
form.dispatchErrorOccurredEvent(this, "RecordVideo",
......@@ -103,12 +88,6 @@ public class Camcorder extends AndroidNonvisibleComponent
Log.i("CamcorderComponent",
"Returning result. Request code = " + requestCode + ", result code = " + resultCode);
if (requestCode == this.requestCode && resultCode == Activity.RESULT_OK) {
File clip = new File(clipFile.getPath());
if (clip.length() != 0) {
AfterRecording(clipFile.toString());
} else {
deleteFile(clipFile); // delete empty file
// see if something useful got returned in the data
if (data != null && data.getData() != null) {
Uri tryClipUri = data.getData();
Log.i("CamcorderComponent", "Calling Camcorder.AfterPicture with clip path "
......@@ -119,10 +98,10 @@ public class Camcorder extends AndroidNonvisibleComponent
form.dispatchErrorOccurredEvent(this, "TakeVideo",
ErrorMessages.ERROR_CAMCORDER_NO_CLIP_RETURNED);
}
}
} else {
// delete empty file
deleteFile(clipFile);
Log.i("CamcorderComponent", "No clip filed rerturn; request failed");
form.dispatchErrorOccurredEvent(this, "TakeVideo",
ErrorMessages.ERROR_CAMCORDER_NO_CLIP_RETURNED);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment