Reputation: 27
I have four MP4 videos. And I want to play all of them one by one. Each video should play for a specific time for example 30 second. I have code like this:
VideoView videoView = (VideoView)findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setVideoPath(PATH_TO_FILE);
videoView.setMediaController(mediaController);
videoView.start();
How can I change this code to run 4 videos one by one, and each video is played for 30 seconds?
Upvotes: 0
Views: 1579
Reputation: 15668
You could be checking for it's current position in a handler like this
private android.os.Handler mHandler;
private Runnable mRunnable;
mHandler = new Handler();
mRunnable = new Runnable() {
public void run() {
int currentPostion = mVideoView.getCurrentPosition());
if(currentPostion >= 30 * 1000 || currentPostion == mVideoView.getDuration()) {
// Play next video
}
mHandler1.postDelayed(this, 250);
}
};
mHandler.post(mRunnable);
Upvotes: 1