здесь код для перехода к следующему / предыдущему видео в одном действии.как плейлист.
public class Test11Activity extends Activity {
private int currentVideo=0;
ArrayList<String> httpLinkArrayList = new ArrayList<String>();
VideoView videoView;
Button n_button;
Button p_button;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
httpLinkArrayList.add("http://abb.mp4");
httpLinkArrayList.add("http://abb1.mp4");
httpLinkArrayList.add("http://abb2.mp4");
httpLinkArrayList.add("http://abb3.mp4");
httpLinkArrayList.add("http://abb4.mp4");
LinearLayout mainlayout = new LinearLayout(this);
mainlayout.setOrientation (LinearLayout.VERTICAL);LinearLayout n_p_layout = new LinearLayout (this);
n_button = new Button(this);
n_button.setText("Next");
n_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if(currentVideo<httpLinkArrayList.size()){
currentVideo++;
videoView.setVideoURI(Uri.parse(httpLinkArrayList.get(currentVideo)));
videoView.start();
}
}
});
p_button = new Button(this);
p_button.setText("Previous");
p_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(currentVideo>0){
currentVideo--;
videoView.setVideoURI(Uri.parse(httpLinkArrayList.get(currentVideo)));
videoView.start();
}
}
});
n_p_layout.addView(n_button);
n_p_layout.addView(p_button);
videoView = new VideoView(this);
videoView.setVideoURI(Uri.parse(httpLinkArrayList.get(currentVideo)));
videoView.start();
videoView.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer arg0) {
// TODO Auto-generated method stub
if(currentVideo<httpLinkArrayList.size()){
currentVideo++;
videoView.setVideoURI(Uri.parse(httpLinkArrayList.get(currentVideo)));
videoView.start();
}
}
});
mainlayout.addView(n_p_layout);
mainlayout.addView(videoView);
setContentView(mainlayout);
}
}
надеюсь, полезно для вас .:)