我已经实现了一个代码,用于将捕获的视频保存到自定义位置。
// Constants
final static int REQUEST_VIDEO_CAPTURED = 1;
String CAPTURE_TITLE="MyVideo.3gp";
// Specified the desired location here
File file = new File(Environment.getExternalStorageDirectory() + "/DCIM", CAPTURE_TITLE);
Uri outputFileUri = Uri.fromFile( file );
Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, REQUEST_VIDEO_CAPTURED);
现在在活动结果我只获取默认路径而不是我想要保存视频的所需路径。
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (resultCode == RESULT_OK)
{
Uri capturedImageUri = data.getData();
Toast.makeText(this, capturedImageUri .getPath(), TOAST.LENGTH_LONG).show();
}
}
现在我不知道为什么它没有将它保存到所需的位置类似于我尝试使用图像捕获并且它有效。
此外,我已添加了所需的权限。
任何想法!!
答案 0 :(得分:2)
File file = new File(Environment.getExternalStorageDirectory() + "/DCIM", CAPTURE_TITLE);
更改为:
File file = new File(Environment.getExternalStorageDirectory() + "/DCIM/", CAPTURE_TITLE);
答案 1 :(得分:2)
试试这个......
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)), CAPTURE_TITLE);