视频捕捉OK /重拍屏幕在播放

时间:2018-02-06 08:11:07

标签: android video video-capture

每当我捕捉视频并且我被带到下一个屏幕,即OK / Retake屏幕,我尝试播放视频;它崩溃了。我认为这是因为参数(MediaStore.EXTRA_OUTPUT)我指定了我的自定义路径。然而;如果我没有传递此参数并允许视频存储在默认位置;按下播放按钮时应用程序不会崩溃。

以下是我的代码:

private void dispatchTakeVideoIntent() {
    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    takeVideoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 100);

    StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
    StrictMode.setVmPolicy(builder.build());
    mVideoCaptureUri = mActivity.getExternalCacheDir() +
            "/", ".mp4"
    takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, mVideoCaptureUri);
    takeVideoIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
    if (takeVideoIntent.resolveActivity(mActivity.getPackageManager()) != null) {
        mActivity.startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
    }
}

崩溃日志: android.os.FileUriExposedException:file:///storage/emulated/0/Android/data/com.example.test/cache/1517905670437.mp4通过Intent.getData()

0 个答案:

没有答案