Reputation: 1503
i am using video player in my application. its working fine. But i need while android "HOME" button clicking video player in pause state and again i click application it continue from last played state.
here my code:
videoView = (VideoView)findViewById(R.id.videoView);
MediaController mediaController= new MediaController(this);
mediaController.setAnchorView(videoView);
String path1="http://commonsware.com/misc/test2.3gp";
Uri uri=Uri.parse(path1);
videoView.setMediaController(mediaController);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();
@Override
protected void onPause() {
videoView.pause();
super.onPause();
}
@Override
protected void onResume(){
videoView.start();
super.onResume();
}
any one can help me?
Upvotes: 1
Views: 1557
Reputation: 1503
solved this issue. here my answer
@Override
protected void onResume() {
super.onResume();
try{
if (videoView != null) {
videoView.seekTo(position);
videoView.start();
}
}catch (Exception e) {
}
}
@Override
protected void onPause() {
super.onPause();
try{
if (videoView != null) {
position = videoView.getCurrentPosition();
videoView.pause();
}
}catch (Exception e) {
}
}
Upvotes: 5
Reputation: 386
Please refer android API reference for VideoView
You can use the following methods to achieve this.
int getCurrentPosition ()
and
void seekTo (int msec)
Upvotes: 0