clean up the mediaplayer at surface destroy, so its recreated

This commit is contained in:
tibbi 2016-10-09 11:08:58 +02:00
parent b1fcd36a0b
commit 301f14acdb

View file

@ -218,11 +218,6 @@ public class VideoFragment extends ViewPagerFragment
} }
} }
@Override
public void surfaceCreated(SurfaceHolder holder) {
initMediaPlayer();
}
private void initMediaPlayer() { private void initMediaPlayer() {
if (mMediaPlayer != null) if (mMediaPlayer != null)
return; return;
@ -284,6 +279,11 @@ public class VideoFragment extends ViewPagerFragment
mTimerHandler.removeCallbacksAndMessages(null); mTimerHandler.removeCallbacksAndMessages(null);
} }
@Override
public void surfaceCreated(SurfaceHolder holder) {
initMediaPlayer();
}
@Override @Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
@ -291,7 +291,10 @@ public class VideoFragment extends ViewPagerFragment
@Override @Override
public void surfaceDestroyed(SurfaceHolder holder) { public void surfaceDestroyed(SurfaceHolder holder) {
if (mMediaPlayer != null) {
mMediaPlayer.release();
mMediaPlayer = null;
}
} }
@Override @Override