[Android] Release mediaplayer instead of stop it

Geoffrey Métais git at videolan.org
Tue Sep 5 18:46:03 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Sep  5 18:22:21 2017 +0200| [d8f8bf9097675671b231557b85d542d3166baf07] | committer: Geoffrey Métais

Release mediaplayer instead of stop it

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

 .../src/org/videolan/vlc/PlaybackService.java        | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 6b6915cea..ff0854154 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -235,7 +235,6 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
         if (aout != null)
             mp.setAudioOutput(aout);
         mp.getVLCVout().addCallback(this);
-
         return mp;
     }
 
@@ -356,7 +355,12 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
             unregisterReceiver(mRemoteControlClientReceiver);
             mRemoteControlClientReceiver = null;
         }
-        mMediaPlayer.release();
+        VLCApplication.runBackground(new Runnable() {
+            @Override
+            public void run() {
+                mMediaPlayer.release();
+            }
+        });
     }
 
     @Override
@@ -989,17 +993,9 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
         if (media != null) {
             saveMediaMeta();
             media.setEventListener(null);
-            mMediaPlayer.setEventListener(null);
-            final MediaPlayer mp = mMediaPlayer;
-            VLCApplication.runBackground(new Runnable() {
-                @Override
-                public void run() {
-                    mp.stop();
-                    mp.setMedia(null);
-                }
-            });
             media.release();
         }
+        restartMediaPlayer();
         mMediaList.removeEventListener(mListEventListener);
         mPrevious.clear();
         mHandler.removeMessages(SHOW_PROGRESS);
@@ -2497,7 +2493,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
     }
 
     public void restartMediaPlayer() {
-        stop();
+        mMediaPlayer.setEventListener(null);
         final MediaPlayer mp = mMediaPlayer;
         VLCApplication.runBackground(new Runnable() {
             @Override



More information about the Android mailing list