Use Intent.ACTION_GET_CONTENT to choose video up to some duration - android

I have want to limit user to choose only videos with duration less then 60 seconds.
My code:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("video/mp4");
intent.addCategory(Intent.CATEGORY_OPENABLE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
}
I already able to do that during capture video by camera with next code:
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 60);

I have want to limit user to choose only videos with duration less then 60 seconds.
Then you will need to implement your own UI for this, using MediaStore to try to find videos that meet your requirements, then display them for selection in a list or grid or something. ACTION_GET_CONTENT does not support arbitrary filters ("duration less than 60 seconds", "length less than 500MB", "starring Amanda Seyfried", etc.).
I already able to do that during capture video by camera with next code
No, you are able to request this. Camera apps that honor ACTION_VIDEO_CAPTURE should honor EXTRA_DURATION_LIMIT. They do not have to honor EXTRA_DURATION_LIMIT. The video that is recorded may be longer than your requested limit.

Related

How to record a video in low resolution. In Android OS?

In according to the site android.developers the constant "EXTRA_VIDEO_QUALITY" is used for control the quality of a recorded video, but when i use this constant, the quality of a record video don't change.
// Currently value 0 means low quality, suitable for MMS messages, and value 1 means high quality.
Intent intent = new Intent(MediaStore.intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 5);
fileUri = getOutputMediaFileUri(MEDIA_TYPE_VIDEO); // create a file to save the image
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
// start the image capture Intent
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
the quality of a record video don't change
By including that extra, you are asking a third-party app to record a lower-quality video. Whether the third-party app honors that request is up to the third-party app, not you. Some will honor it, some will not.
If you want greater control over video recording, you have to do it yourself (e.g., via MediaRecorder).

Prevent pause while recording a video with intent on some Android devices

Is it possible to prevent such feature in selected devices (like the HTC One)?
I am starting an intent using that code:
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
Uri fileUri = Uri.fromFile(/* path to some file */);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // set the video image quality to high
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 45); // limit the camera to 45 seconds
startActivityForResult(intent, CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);
I cannot find any flag to use for preventing "pause while recording"..
The stock Android camera (on api lvl21+ at least) there isn't any option to pause the video recording but on some devices you can.

Extend Video recording time in Google Glass

Is there a way we can extend the default video recording time on glass. The current recording time is only 10 seconds and we have to extend it manually by pressing the camera key for one second or by tapping and choosing Extend Video option. So i was wondering whether there is a flag that we can set when requesting the camera to start recording which will cause the camera to record an extended video.
I was also wondering how can we set the maximum time limit of video recording and what is the default time limit of video recording in glass ?
I am using the code below for starting the glass camera for video recording
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(intent, CAPTURE_VIDEO_REQUEST_CODE);
Also if there isn't a possible way can anyone guide me on the alternatives. Is there any open source camera available which works for glass or should i have to write my own camera [any links that would help me get started] ?
Hope you get him idea from it:
Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra("android.intent.extra.durationLimit", 60);
startActivityForResult(intent, CAPTURE_VIDEO_REQUEST_CODE);
This above code video duration is one minute,if u want to extend the video time then do it like that,and now the video duration is 2 minutes:
Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra("android.intent.extra.durationLimit", 120);
startActivityForResult(intent, CAPTURE_VIDEO_REQUEST_CODE);
You can access the camera directly and record the video yourself. See the official Android documentation for more information: http://developer.android.com/guide/topics/media/camera.html#capture-video

How to capture video using Intent and set path of recorded and limit recording time

I use an example of recording video using intent based on
Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(intent, REQUEST_VIDEO_CAPTURED);
For time limit I have used: intent.putExtra("android.intent.extra.durationLimit", 5);
This records 5 seconds and then stop automatically.
I have used example from URL:
http://android-er.blogspot.cz/2011/04/start-video-recording-using.html
This example is for me interesting because works on all my devices and is easy to implement.
Is it possible to set the path to save recorded video ?
Let's say simple I need video to save to a specified file "myrecordedvideo.mp4" to a specified folder and need video to have exactly 5 seconds. Is it possible to make it easy way with this Intent ?
To set the time limit and set the path to save the video
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
takeVideoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 30);
takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, Environment.getExternalStorageDirectory().getPath()+"videocapture_example.mp4");
startActivityForResult(takeVideoIntent, ACTION_TAKE_VIDEO);

Whether this property android.provider.MediaStore.EXTRA_SIZE_LIMIT is valid or not?

I use the MediaStore in my application for capturing the video, but it will capture only 8 or 14 seconds ,based on encoder.
Is there any other way to increase the duration and size of video.
Thanks.
You can set duration limit by time in you Intent like that:
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 4); // i.e. 4 secs maximum

Categories

Resources