I am having an Activity in which there is
VideoView -- Streams a video from a webserver.
Button -- Takes the user to the next activit
The problem with videoView.resume() in onResume() can be seen here: VideoView.resume().
VideoView.resume() calls openVideo() which first releases any previous MediaPlayer instances and then starts a new one. I cannot see an easy way out of this.
I see two possibilities:
Have fun! :)
As the buffer is lost when the video view goes to the background(change in visibility), you should try blocking this behavior by overriding the onWindowVisibilityChanged method of VideoView. Call super only if the video view is becoming visible. May have side-effects.
public class VideoTest extends VideoView {
public VideoTest(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onWindowVisibilityChanged(int visibility) {
if (visibility == View.VISIBLE) {
super.onWindowVisibilityChanged(visibility);
}
}
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
videoView.pause();
super.onPause();
}
@Override
protected void onRestart() {
// TODO Auto-generated method stub
videoView.resume();
super.onPause();
}
try by adding above twomethods in your activity.
In onPause() function, instead of
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
videoView.suspend();
}
try
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
videoView.pause();
}