我使用Intent从MediaStore获取视频。
String videoFileName = String.valueOf(java.util.UUID.randomUUID());
String fileExtension = "." + "mp4";
String root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath();
String videoFilePath = root + File.separator + videoFileName + fileExtension;
File videoFile = new File(videoFilePath);
String myCurrentVideoPath = videoFile.getAbsolutePath();
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (takeVideoIntent.resolveActivity(getActivity().getPackageManager()) != null) {
if (videoFile != null) {
takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(videoFile));
startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
}
}
...
这是通过onClick
方法完成的。 是否可以为MediaStore采用defaut视频文件扩展名,并将其分配给我的String fileExtension = "." + "mp4";
。我想这样做,因为有些cheep设备只记录.3gp
。欢呼所有stackoverflowers。