我的应用程序拍摄了一段视频,然后又返回到一个屏幕,允许我选择另一个视频或图库显示视频。 问题是图库不显示我录制的所有视频,只显示一个。我确定我会录制视频,因为它们出现在我的文件中。
用于显示图库的代码如下:
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();
}
}
我希望你理解,这是我的第一个问题。
非常感谢! 抱歉我的英文不好
答案 0 :(得分:0)
您必须请求系统更新媒体库