How to limit the duration of MediaStore in Android 7

What's New with MediaStore Duration Limit in Android 7? There is nothing about this in the documentation, but since sdk 24, the device records video without any restrictions.

final Activity activity = (Activity) context;
String controlId = videoInput.getControlId();
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (videoInput.getMaxDuration() > 0) {
    intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, videoInput.getMaxDuration());
}
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, videoInput.getRecordQuality().ordinal());
int requestCode = ActivityResultBus.getInstance().generateRequestCode(new SBundle(controlId));
activity.startActivityForResult(intent, requestCode);

I tested it on a real Motorola Nexus 6 with Android 7.0 and on virtual devices with 7.0 and 7.1.1. In previous versions, everything works the way I want.

Is there something wrong with my package extras? enter image description here

+4
source share
1 answer

"EXTRA_DURATION_LIMIT is not required for any camera application. This is a request, not a command."

Any other way to limit the length of the video?

. API- . , , - , , , 10 .

: MediaStore.EXTRA_DURATION_LIMIT Nexus Devices?

0

Source: https://habr.com/ru/post/1659146/


All Articles