我想要的与图像相同。当用户单击一个按钮(在我的情况下是 VideoView 本身)时,我想让他们打开 Gallery 并将视频加载到 VideoView 中。
vv_video = (VideoView) findViewById(R.id.vv_video);
vv_video.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Intent intent = new Intent();
intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Complete action using"), LOAD_VIDEO);
return false;
}
});
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != RESULT_OK) return;
switch (requestCode) {
case LOAD_VIDEO:
Toast.makeText(NewBucketActivity.this, "test", Toast.LENGTH_SHORT).show(); //this appears!
Bundle video = data.getExtras();
mVideoCaptureUri = video.getParcelable("data");
vv_video.setVideoURI(mVideoCaptureUri);
break;
}
}
但是当我在图库中选择视频时没有任何反应。Toast msg 出现了,所以我将 sg 与 Bundle 或 Uri 搞砸了。它应该显示在 VideoView 中,对吧?