I like this site very much because I can find many useful solutions help me very much especially I'm beginner in android programming and this is my first question so I hope find helping from this great community.
The Problem: I play video in my app and make it playing in full screen in landscape when user orient screen so I want to make video restart playing from the same point by using seekTo() and getCurrentPosition() - but the problem that video play many seconds after the position I mean that video seek to same point in time but when start play it add many seconds.
My Code:
//initialise everything
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
v = (VideoView) findViewById(R.id.videoView1);
v.setVideoPath(dir + videoName + ".3gp");
v.setMediaController(new MediaController(this));
if (savedInstanceState == null){
v.start();
}
else {
playingTime = savedInstanceState.getInt("restartTime", 0);
v.seekTo(playingTime);
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
// TODO Auto-generated method stub
super.onSaveInstanceState(outState);
if (file.exists()){
playingTime = v.getCurrentPosition();
v.stopPlayback();
outState.putInt("restartTime", playingTime);
}
}
I try many solution such as this How to keep playing video while changing to landscape mode android
I'm using Galaxy Nexus to test my app .. I would be grateful for any hint. Sorry for my bad English and thanks very much.