diff --git a/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java b/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java index ab165eb45..f57b2364f 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java +++ b/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java @@ -218,11 +218,6 @@ public class VideoFragment extends ViewPagerFragment } } - @Override - public void surfaceCreated(SurfaceHolder holder) { - initMediaPlayer(); - } - private void initMediaPlayer() { if (mMediaPlayer != null) return; @@ -284,6 +279,11 @@ public class VideoFragment extends ViewPagerFragment mTimerHandler.removeCallbacksAndMessages(null); } + @Override + public void surfaceCreated(SurfaceHolder holder) { + initMediaPlayer(); + } + @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { @@ -291,7 +291,10 @@ public class VideoFragment extends ViewPagerFragment @Override public void surfaceDestroyed(SurfaceHolder holder) { - + if (mMediaPlayer != null) { + mMediaPlayer.release(); + mMediaPlayer = null; + } } @Override