[Android] Thread mediaplayer restarting

Geoffrey Métais git at videolan.org
Fri Aug 4 10:57:03 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Aug  4 10:06:15 2017 +0200| [67078588da0260e657ac7a0f3fd9fdb772b450b4] | committer: Geoffrey Métais

Thread mediaplayer restarting

This extends the workaround for hanging Mediaplayer.stop()

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

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

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index e63ff1e74..4f0734e3c 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -2509,8 +2509,14 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
 
     public void restartMediaPlayer() {
         stop();
-        mMediaPlayer.release();
-        mMediaPlayer = newMediaPlayer();
+        // Thread restart while MediaPlayer.stop() is threaded.
+        VLCApplication.runBackground(new Runnable() {
+            @Override
+            public void run() {
+                mMediaPlayer.release();
+                mMediaPlayer = newMediaPlayer();
+            }
+        });
         /* TODO RESUME */
     }
 



More information about the Android mailing list