[Android] Thread mediaplayer stop & restart
Geoffrey Métais
git at videolan.org
Mon Aug 21 11:34:12 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Aug 21 11:27:55 2017 +0200| [12b5dd1aecdd4c997b942e7c169e78be8538281f] | committer: Geoffrey Métais
Thread mediaplayer stop & restart
> https://code.videolan.org/videolan/vlc-android/commit/12b5dd1aecdd4c997b942e7c169e78be8538281f
---
vlc-android/src/org/videolan/vlc/PlaybackService.java | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index d45fc7eaa..ba8b13e1f 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -1022,8 +1022,14 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
saveMediaMeta();
media.setEventListener(null);
mMediaPlayer.setEventListener(null);
- mMediaPlayer.stop();
- mMediaPlayer.setMedia(null);
+ final MediaPlayer mp = mMediaPlayer;
+ VLCApplication.runBackground(new Runnable() {
+ @Override
+ public void run() {
+ mp.stop();
+ mp.setMedia(null);
+ }
+ });
media.release();
publishState();
}
@@ -2527,7 +2533,13 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
public void restartMediaPlayer() {
stop();
- mMediaPlayer.release();
+ final MediaPlayer mp = mMediaPlayer;
+ VLCApplication.runBackground(new Runnable() {
+ @Override
+ public void run() {
+ mp.release();
+ }
+ });
mMediaPlayer = newMediaPlayer();
/* TODO RESUME */
}
More information about the Android
mailing list