After searching for many hours , i am asking this, any related answers are welcomed . .
I'm having a video in my R.raw folder and i am playing it in two videoview of same duration simultaneously , here is my code ,
sb = (SeekBar)findViewById(R.id.control_seekbar);
mVideoView1 = (VideoView) findViewById(R.id.surface_view1);
mVideoView1.setVideoPath("android.resource://" + getPackageName() +"/"+R.raw.play1);
mVideoView1.start();
mVideoView2 = (VideoView) findViewById(R.id.surface_view2);
mVideoView2.setVideoPath("android.resource://" + getPackageName() +"/"+R.raw.play2);
mVideoView2.start();
v1 = mVideoView1.getDuration();
v2 = mVideoView2.getDuration();
mVideoView1.setOnPreparedListener(new OnPreparedListener()
{
@Override
public void onPrepared(MediaPlayer arg0)
{
sb.setMax(mVideoView1.getDuration()+3);
sb.postDelayed(onEverySecond, 60);
}
});
sb.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
{
@Override
public void onStopTrackingTouch(SeekBar seekBar)
{
mVideoView1.seekTo(sb.getProgress());
mVideoView2.seekTo(sb.getProgress());
}
@Override
public void onStartTrackingTouch(SeekBar seekBar)
{
mVideoView1.seekTo(sb.getProgress());
mVideoView2.seekTo(sb.getProgress());
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser)
{
mVideoView1.seekTo(progress);
mVideoView2.seekTo(progress);
}
});
}
private Runnable onEverySecond=new Runnable()
{
@Override
public void run()
{
if(sb != null)
{
sb.setProgress(mVideoView1.getCurrentPosition());
}
if(mVideoView1.isPlaying())
{
sb.postDelayed(onEverySecond, 1000);
if(mVideoView1.getDuration() <= sb.getProgress())
{
mVideoView1.seekTo(0);
mVideoView2.seekTo(0);
}
}
}
};
and i could drag the seekbar to the new position and it is playing from the new position correctly .
But i dont want to play the video initially . It should be in pause() and as i drag the seekbar, the videoview should update to the respective position .
When i change the mVideoView.start() to pause() , i could see only a blank black screen and no update for the seekbar position change in the videoview .
in what way i could achieve it .