Reputation: 2295
I am using VideoView to play *.mp4 file. And I want to play and pause it at a specific time.
Here is my code:
VideoView videoView=(VideoView)findViewById(R.id.video_view);
videoView.setVideoURI(Uri.parse("/sdcard/video/myvideo.mp4"));
videoView.seekTo(15000);
videoView.play();
In this case, video start from 00:00:15. And I want to pause it at 00:00:30.
How to do that?
Upvotes: 1
Views: 3188
Reputation: 1616
If you want the video to pause at exactly 00:00:30 and not just 30 sec after video play, the most reliable way is to have a handler that run every second to check on the current position of the video. Pause the video if the current position is equal or larger than 30 sec.
Upvotes: 3
Reputation: 3992
final VideoView videoView=(VideoView)findViewById(R.id.video_view);
videoView.postDelayed(new Runnable() {
@Override
public void run() {
videoView.pause();
}
}, 15000);
Upvotes: 4