[Android] Release media on end reached

Geoffrey Métais git at videolan.org
Thu Nov 9 18:19:37 CET 2017


vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Nov  9 16:03:33 2017 +0100| [23b695080184f7df783dddbe5303f84b6f004557] | committer: Geoffrey Métais

Release media on end reached

(cherry picked from commit 6d1e3409a6940d58f805243e486388abb84fb10d)

> https://code.videolan.org/videolan/vlc-android/commit/23b695080184f7df783dddbe5303f84b6f004557
---

 vlc-android/src/org/videolan/vlc/PlaybackService.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index fe43df0bc..bb9de1f3e 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -665,7 +665,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
                 case MediaPlayer.Event.EndReached:
                     saveMediaMeta();
                     executeUpdateProgress();
-                    previousMediaStats = mMediaPlayer.getMedia().getStats();
+                    setPreviousStats();
                     determinePrevAndNextIndices(true);
                     if (mNextIndex == -1)
                         savePosition(true);
@@ -728,6 +728,13 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
                 }
             }
         }
+
+        private void setPreviousStats() {
+            final Media media = mMediaPlayer.getMedia();
+            if (media == null) return;
+            previousMediaStats = media.getStats();
+            media.release();
+        }
     };
 
     private void onPlaybackStopped() {



More information about the Android mailing list