早上好,我创建了一个带有视频视图的活动,该活动自动启动并以循环模式从uri加载视频。 如何在循环模式下加载2或3个视频? 例如从Uri(xxx1,xxx2,xxx3)加载? 提前做出来的
答案 0 :(得分:1)
我认为您可以创建RecyclerView或ListView或ScrollView以及各自的Adapter或Child视频视图。
在Uri []或ArrayList
中有一个视频Uris列表在各自的getView或(Uri uri:mUris)循环中调用它们
以下是播放视频的单个实例
private void playVideo(Uri uri) {
//set the media controller buttons
if (mediaControls == null) {
mediaControls = new MediaController(AndroidVideoViewExample.this);
}
//initialize the VideoView
myVideoView = (VideoView) findViewById(R.id.video_view);
try {
//set the media controller in the VideoView
myVideoView.setMediaController(mediaControls);
//set the uri of the video to be played
myVideoView.setVideoURI(uri);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
//we also set an setOnPreparedListener in order to know when the video file is ready for playback
myVideoView.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mediaPlayer) {
// close the progress bar and play the video
progressDialog.dismiss();
//if we have a position on savedInstanceState, the video playback should start from here
myVideoView.seekTo(position);
if (position == 0) {
myVideoView.start();
} else {
//if we come from a resumed activity, video playback will be paused
myVideoView.pause();
}
}
});
}