本文介绍了如何删除使用带有ACTION_VIDEO_CAPTURE一个Intent录制视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除已使用意向pviously记录$ P $视频:

I would like to remove a video that has been previously recorded using an Intent:

Intent captureVideoIntent = new Intent(
                  android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(captureVideoIntent, VIDEO_CAPTURED);

该方法的onActivityResult()获得记录的视频作为意向数据。我尝试获取记录的文件并将其删除。

The method onActivityResult() get the recorded video as Intent data. I try to obtain the recorded file and delete it.

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Code for modify and copy the video
    try {
            Uri androidUri = data.getData();
            File file = new File(new java.net.URI(androidUri.toString()));
            file.delete();
    } catch (Exception e) {
            e.printStackTrace();
    }
}

但我得到的错误:

But I get the error:

java.lang.IllegalArgumentException异常:预计,URI文件架构:内容://媒体/外部/视频/媒体/ 177

java.lang.IllegalArgumentException: Expected file scheme in URI: content://media/external/video/media/177.

是否有人知道我如何能得到录制的视频的路径和移动或删除呢?

Does somebody know how can I get the path of the recorded video and move or delete it?

推荐答案

This回答有如何从内容URI路径。你应该能够将其结果传递给文件构造。

This answer has how to get the path from a content URI. You should be able to pass its result to the File constructor.

这篇关于如何删除使用带有ACTION_VIDEO_CAPTURE一个Intent录制视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 17:01