I am working on playing a video task,for this purpose I am using two Activity classes
,In my First Activity
I am playing a video by VideoView
using certain Height and width.Here I am having one full screen icon too.If I tap the icon It will forward to Second Activity
which will show the video in Full screen mode.In Second Activity
it is playing a video from beginning.what I actually need is if I tap the icon in My First Activity
after playing the half of video,I will need to play remaining part of video in Full Screen
mode. Not the entire video from beginning which is playing now.
public void previewVideo(Uri mediaUri) {
pDialog.setMessage("Buffering Please Wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
videoPreview.setVideoURI(mediaUri);//setting the uri into VideoView
MediaController mediaController = new MediaController(SecondActivity.this);
mediaController.setAnchorView(videoPreview);
videoPreview.setMediaController(mediaController);
videoPreview.requestFocus();
videoPreview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
pDialog.dismiss();
videoPreview.start();
}
});
}
As per Nitin Misra
's Comment I have achieved it by below code.
inside My First Activity previewVideo(Uri mediaUri)
method
public void onPrepared(MediaPlayer mp) {
pDialog.dismiss();
int timeInterval = mp.getCurrentPosition();
videoPreview.start();
}
sending that timeInterval
value into Second Activity by Intent.putExtra("timeDuration",timeInterval);
And in Second Activity I am getting the value of timeDuration
using getIntent().getStringExtra("timeDuration");
and set that value into previewVideo(Uri mediaUri)
method
public void onPrepared(MediaPlayer mp) {
pDialog.dismiss();
mp.seekTo(Integer.parseInt(getIntent().getStringExtra("timeDuration")));
videoPreview.start();
}