[Android] Release media on end reached

Geoffrey Métais git at videolan.org
Thu Nov 9 16:04:35 CET 2017


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

Release media on end reached

> https://code.videolan.org/videolan/vlc-android/commit/6d1e3409a6940d58f805243e486388abb84fb10d
---

 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 0a9c4a028..7e1952db1 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