如何使用 itents 在 android 中传递视频数据?
好的活动 1 在 gridVideoView 中显示 SD 卡中的视频缩略图。我希望能够单击并将数据传递到活动 2 并播放这些视频。我买的书只告诉我如何用字符串来做到这一点。我该如何做到这一点,以便当我单击活动 1 中的视频时,它会被传递并可以在活动 2 中播放?如果您想要代码,我将发布它。
Intent Intent = new Intent(getBaseContext(), Editor.class); intent.putExtra("mnt/sdcard-ext", _ID); startActivity(intent);
private VideoView video;
private MediaController ctlr;
File clip=new File(Environment.getExternalStorageDirectory(),
"mnt/sdcard-ext");
if (clip.exists()) {
video=(VideoView)findViewById(R.id.video);
video.setVideoPath(clip.getAbsolutePath());
ctlr=new MediaController(this);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
video.requestFocus();
video.start();
}
}
}
我如何在 VideoView 中引用意图?
Ok activity 1 displays thumbnails of videos from the SD card in a gridVideoView. I want to be able to click and pass the data onto activity 2 and play those videos. My book that i bought only shows me how to do this with strings. How can i do this so when i click a video in activity 1 it is passed and can be played in activity 2? If you would like the code I'll post it.
Intent intent = new Intent(getBaseContext(), Editor.class);
intent.putExtra("mnt/sdcard-ext", _ID);
startActivity(intent);
private VideoView video;
private MediaController ctlr;
File clip=new File(Environment.getExternalStorageDirectory(),
"mnt/sdcard-ext");
if (clip.exists()) {
video=(VideoView)findViewById(R.id.video);
video.setVideoPath(clip.getAbsolutePath());
ctlr=new MediaController(this);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
video.requestFocus();
video.start();
}
}
}
How do i do reference the intent in the VideoView?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种选择是简单地将视频路径作为字符串传递给第二个活动。
One option would be to simply pass the path of the video as a string to the second activity.
试试这个:
Try this: