Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Android MediaStore.EXTRA_DURATION_LIMIT not working in 6.0 and uper version device

I'm using LG Nexus(6.0). When I have use the camera to capture video using below code.

   Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
   fileUri = getOutputMediaFileUri(MEDIA_TYPE_VIDEO);
    // set video quality
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
    intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 30);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); 

I have given its duration limit using below code.

    intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 30);

The camera seems to ignore the duration limit. On any 6.0 device, it does not work. Is there an another way to limit the capture video duration on 6.0 + devices?

like image 728
Sanjay Bhalani Avatar asked Jun 28 '17 12:06

Sanjay Bhalani


People also ask

What is MediaStore API in Android?

android.provider.MediaStore. The contract between the media provider and applications. Contains definitions for the supported URIs and columns. The media provider provides an indexed collection of common media types, such as Audio , Video , and Images , from any attached storage devices.

What is MediaStore Extra_output?

If you specified MediaStore. EXTRA_OUTPUT, the image taken will be written to that path, and no data will given to onActivityResult. You can read the image from what you specified.

What is MediaStore?

The media store also includes a collection called MediaStore. Files . Its contents depend on whether your app uses scoped storage, available on apps that target Android 10 or higher: If scoped storage is enabled, the collection shows only the photos, videos, and audio files that your app has created.


1 Answers

The camera seems to ignore the duration limit. On any 6.0 device it does not work.

There are ~2 billion Android devices, spread across thousands of device models from hundreds of manufacturers. Those devices will have hundreds of different pre-installed camera apps, plus possibly camera apps installed by users. Any of them can be what responds to an ACTION_VIDEO_CAPTURE request, and any of them can have bugs. This issue is not tied to an Android OS version.

Is there a other way to limit the capture video duration on 6.0 + devices?

Not with ACTION_VIDEO_CAPTURE. You are delegating the work to a third-party app, and that app can do whatever it wants.

If you want full control, use MediaRecorder, either directly in your own code or via some third-party library.

like image 109
CommonsWare Avatar answered Sep 23 '22 16:09

CommonsWare