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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With