我有一个带有 videoview 的 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/back"
android:orientation="vertical"
android:screenOrientation="landscape">
<VideoView
android:id="@+id/videoview_concept"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
我的java部分是:
public class playvideos extends Activity implements OnCompletionListener{
public Integer index_val=0;
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
index_val++;
VideoView videoview= (VideoView)findViewById(R.id.videoview_concept);
checkdbconn();
videoview.setVideoURI(Uri.parse(prepare.txtLectureFileName[index_val]));
videoview.setMediaController(new MediaController(this));
videoview.requestFocus();
videoview.start();
}
public void playvideo(View view){
setContentView(R.layout.playvid);
VideoView videoview= (VideoView)findViewById(R.id.videoview_concept);
Log.i("Video URL",videourl_array[index_val]);
checkdbconn();
videoview.setVideoURI(Uri.parse(videourl_array[index_val]));
videoview.setMediaController(new MediaController(this));
videoview.requestFocus();
checkdbconn();
videoview.start();
}
上面的代码是一个按钮点击事件。它真的很好用。如果第一个视频完成,它应该自动播放第二个视频。因此,我想连续播放该数组中的所有视频。如何做到这一点?请帮帮我:)