如何在特定时间播放 android 中的视频文件

How can Play Video file in android for specific time

我有四个 MP4 视频。我想一一播放。每个视频都应该播放 对于特定时间,例如 30 秒。我有这样的代码:

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(); 

如何将这段代码改为运行4个视频一个一个播放,每个视频都播放 持续 30 秒?

您可以像这样检查它在处理程序中的当前位置

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);