In Android, MediaStore.EXTRA_DURATION_LIMIT does not work in 6.0 and later
I am using LG Nexus (6.0). When I use the camera to capture video using the code below.
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 my limit on duration using below code.
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 30);
The camera seems to ignore the duration limit. It doesn't work on any 6.0 device. Is there any other way to limit the video capture duration on 6.0+ devices?
source to share
The camera seems to ignore the duration limit. It doesn't work on any 6.0 device.
There are ~ 2 billion Android devices spread across thousands of device models from hundreds of manufacturers. These devices will have hundreds of different camera apps pre-installed, as well as possibly user-installed camera apps. Any of them can be the one that meets the request ACTION_VIDEO_CAPTURE
, and any of them can have errors. This issue is not related to the Android OS version.
Is there any other way to limit the video capture duration on 6.0+ devices?
Not with ACTION_VIDEO_CAPTURE
. You delegate work to a third-party application, and that application can do whatever it wants.
If you want complete control, use MediaRecorder
either directly in your own code or through some third party library.
source to share