I'm trying to play a video with VideoView in WindowManager. I'm using the StandOutLibrary for this. I've been pretty successful so far except a couple of things.
MediaController obviously does not work in this case since it needs an activity. So I wrote my custom view to control the videoview. Here is the result-
Everything works except the seekbar after pausing. After I pause the video and start it again, the seekbar refuses to update. Here's my code to play/pause and update seekbar-
play.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
if (playing) {
vv.pause();
play.setImageResource(R.drawable.ic_media_play);
playing = !playing;
} else {
vv.start();
play.setImageResource(R.drawable.ic_media_pause);
playing = !playing;
}
}
});
vv = (VideoView) mView.findViewById(R.id.videoView);
vv.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
sb.setMax(vv.getDuration());
sb.postDelayed(onEverySecond, 60);
}
});
vv.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
close(id);
}
});
sb = (SeekBar) mView.findViewById(R.id.sbar);
sb.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
vv.seekTo(sb.getProgress());
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
vv.seekTo(sb.getProgress());
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
if (fromUser) {
vv.seekTo(progress);
// vv.start();
}
}
});
Where is my mistake?
Also the second problem comes after resizing the window. Normally, all the views take the new layout size after resizing the window. I've tried this with a SurfaceView too and it works. But the VideoView does not take the new size. Here is the result after changing the window size-
Can anyone help me out regarding these two? Thanks in advance!