[Android] [PATCH 1/2] fix regression due to MediaWrapperListPlayer

Thomas Guillem thomas at gllm.fr
Wed Jan 21 19:19:16 CET 2015


AudioService and VideoPlayerActivity shared the same MediaList, so do the same
with MediaWrapperListPlayer.

It's ugly and temporary waiting for PlaybackService.
---
 vlc-android/src/org/videolan/vlc/MediaWrapperListPlayer.java      | 8 ++++++++
 vlc-android/src/org/videolan/vlc/audio/AudioService.java          | 2 +-
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java       | 2 +-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/MediaWrapperListPlayer.java b/vlc-android/src/org/videolan/vlc/MediaWrapperListPlayer.java
index f2fd81d..0cde4f2 100644
--- a/vlc-android/src/org/videolan/vlc/MediaWrapperListPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/MediaWrapperListPlayer.java
@@ -31,6 +31,14 @@ public class MediaWrapperListPlayer {
     final private LibVLC mLibVLC;
     final private MediaWrapperList mMediaList;
 
+    private static MediaWrapperListPlayer sMediaWrapperListPlayer = null;
+
+    public static synchronized MediaWrapperListPlayer getInstance(LibVLC libVLC) {
+        if (sMediaWrapperListPlayer == null)
+            sMediaWrapperListPlayer = new MediaWrapperListPlayer(libVLC);
+        return sMediaWrapperListPlayer;
+    }
+
     public MediaWrapperListPlayer(LibVLC libVLC) {
         mLibVLC = libVLC;
         mMediaList = new MediaWrapperList(libVLC);
diff --git a/vlc-android/src/org/videolan/vlc/audio/AudioService.java b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
index 227a853..c088e40 100644
--- a/vlc-android/src/org/videolan/vlc/audio/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
@@ -160,7 +160,7 @@ public class AudioService extends Service {
         } catch (LibVlcException e) {
             e.printStackTrace();
         }
-        mMediaListPlayer = new MediaWrapperListPlayer(mLibVLC);
+        mMediaListPlayer = MediaWrapperListPlayer.getInstance(mLibVLC);
 
         mCallback = new HashMap<IAudioServiceCallback, Integer>();
         mCurrentIndex = -1;
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index ac406a9..f3b705a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -382,7 +382,7 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
             Log.d(TAG, "LibVLC initialisation failed");
             return;
         }
-        mMediaListPlayer = new MediaWrapperListPlayer(mLibVLC);
+        mMediaListPlayer = MediaWrapperListPlayer.getInstance(mLibVLC);
 
         mSurfaceView = (SurfaceView) findViewById(R.id.player_surface);
         mSurfaceHolder = mSurfaceView.getHolder();
-- 
2.1.3



More information about the Android mailing list