From 301f14acdb27e493cba4de408e76bb5f339a76da Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 9 Oct 2016 11:08:58 +0200 Subject: [PATCH] clean up the mediaplayer at surface destroy, so its recreated --- .../gallery/fragments/VideoFragment.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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