Reputation: 2624
I'm trying to create a custom video playback, which has a video view and media controller:
VideoView mVideoView =(VideoView) findViewById(R.id.videoView);
mVideoView.setVideoURI(uri);
MediaController mMediaController = new MyMediaController(this);
mMediaController.findFocus();
mMediaController.setEnabled(true);
mMediaController.setAnchorView(mVideoView);
mVideoView.setMediaController(mMediaController);
Problem is that: when I programmatically change value of seekbar:
mVideoView.pause();
mVideoView.seekTo(newValue);
MediaController doesn't update these changes immediately. It updates only after I touch it again. Can anybody tell me the right way to update state of media controller? Thanks a a lot!
Upvotes: 1
Views: 1921
Reputation: 4698
for this you have to set an handler that is call after every one second like below code-
static Runnable musicSchedular = new Runnable() {
@Override
public void run() {
resetSeek();
}
};
public static void resetSeek(){
long currentDuration = mediaPlayer.getCurrentPosition();
int cPos = (int)currentDuration/1000;
seekBar.setProgress(cPos);
}
and when you start playing music paste this line of code
myHandler.postDelayed(musicSchedular,100);
hope it will solve your problem.
Upvotes: 1