gpt4 book ai didi

java - 如何播放所有在线视频

转载 作者:搜寻专家 更新时间:2023-11-01 08:03:14 27 4
gpt4 key购买 nike

我将视频网址存储在一个数组中。我只想播放该数组中的所有视频。

我的java代码是:

public void video_play(){

VideoView vview= (VideoView)findViewById(R.id.vview);
vview.setVideoURI(Uri.parse(prepare.txtLectureFileName[index_value]));
vview.setMediaController(new MediaController(this));
vview.requestFocus();
vview.start();

if(index_val>=no_of_videos){
Toast.makeText(getApplicationContext(), "Videos are finished", Toast.LENGTH_SHORT).show();
}
else{
video_play();
}
}

我还尝试过实现 onCompleteListener 并创建了一个方法 onCompletion()。但是没有任何效果,请帮帮我......

最佳答案

嘿,试试这个对我有用:

public void video_play(){

VideoView vview= (VideoView)findViewById(R.id.vview);
vview.setVideoURI(Uri.parse(prepare.txtLectureFileName[index_value]));
vview.setMediaController(new MediaController(this));
vview.requestFocus();
vview.start();
if(index_val>=no_of_videos){
Toast.makeText(getApplicationContext(), "Videos are finished", Toast.LENGTH_SHORT).show();
}
else{
video_play();
}
vview.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion (MediaPlayer mp) {
index_value++;
video_play();
}
});
}

关于java - 如何播放所有在线视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18079285/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com