[Android] fix regression due to MediaWrapperListPlayer

Thomas Guillem git at videolan.org
Thu Jan 22 11:04:04 CET 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Jan 21 18:53:02 2015 +0100| [490bfee75a6b3ecb17d5351155c9db9c3c05a382] | committer: Thomas Guillem

fix regression due to MediaWrapperListPlayer

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

It's ugly and temporary waiting for PlaybackService.

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=490bfee75a6b3ecb17d5351155c9db9c3c05a382
---

 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();



More information about the Android mailing list