Create an arraylist of movie urls(e.g yourURLList
)
Define an int
constant as static final int VIDEO_PLAYBACK_FINISHED = 32
You can keep a count to keep track of which video is being played like:
static int VIDEO_RUNNING = 0
Create a method like this inside the caller activity:
private void startMovie(int serialOfMovie){
String vdoURL= yourURLList.get(serialOfMovie);//array list of movie urls
if(vdoURL != null)
{
//video url for that index is found,if not then it would not enter here
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(vdoURL), "video/mp4");
startActivityForResult(intent,
VIDEO_PLAYBACK_FINISHED);
}
}
And inside the caller activity(the one from which you are invoking the intents you are creating) don't forget to add this snippet:
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == VIDEO_PLAYBACK_FINISHED) {
if (resultCode == RESULT_OK) {
//one video is finished
VIDEO_RUNNING++; //increase which vdo is running count
startMovie(VIDEO_RUNNING);
}
}
}
Now when you are about to play this series of movies(starting from the beginning),just call startMovie(VIDEO_RUNNING);//VIDEO_RUNNING is 0 initially,so it will point the first url in url list.
Remember if you are using MediaPlayer to play movie in the activity(the one you call using intents with movie url),then when the movie has finished playing you should finish
that activity. Like if you have a MediaPlayer instance called mPlayer
in that activity then you should do this:
mPlayer.setOnCompletionListener(new
OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer arg0) {
finish();
}
});
This way you should have the queue effect with movies being played one after another.