1

我的应用程序拍摄了一段视频,然后返回到允许我选择另一个视频或画廊显示视频的屏幕。问题是画廊没有显示我录制的所有视频,只有一个。我确定我会录制视频,因为它们出现在“我的文件”中。

用于显示图库的代码如下:

final static int REQUEST_VIDEO_CAPTURED = 1;
    private Uri uriVideo;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.video_list);

        Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
        intent.setType("video/*");
        startActivityForResult(intent, 1);

            //I also try this
        // Intent intent = new Intent(Intent.ACTION_PICK,
        // android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        // intent.setType("video/*");
        // startActivityForResult(intent, 1);

            // and this
        // Intent intent = new Intent();
        // intent.setType("video/*");
        // intent.setAction(Intent.ACTION_GET_CONTENT);
        // startActivityForResult(Intent.createChooser(intent, "Select Video"),
        // 1);

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == RESULT_OK) {
            if (requestCode == REQUEST_VIDEO_CAPTURED) {
                uriVideo = data.getData();
                Toast.makeText(VideoList.this, uriVideo.getPath(), Toast.LENGTH_LONG).show();

                ContentResolver res = getApplicationContext().getContentResolver();
                Cursor cursor = MediaStore.Video.query(res, data.getData(), new String[] { MediaStore.Video.VideoColumns.DURATION });
                if (cursor.moveToFirst()) {
                    duration = cursor.getString(0);
                }

                if (uriVideo != null) {

                }
            }
        } else if (resultCode == RESULT_CANCELED) {
            uriVideo = null;
            finish();
        }
    }

我希望你明白,这是我的第一个问题。

非常感谢你!对不起,我的英语不好

4

1 回答 1

0

您必须请求系统更新媒体库

于 2012-07-24T17:04:25.000 回答