[Android] Restore audioplayer lazy-loading

Geoffrey Métais git at videolan.org
Fri Mar 31 18:44:57 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Mar 31 16:24:44 2017 +0200| [20b5e71e98bf925b9ce6b5b2c3168c317783e899] | committer: Geoffrey Métais

Restore audioplayer lazy-loading

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

 vlc-android/src/org/videolan/vlc/PlaybackService.java      | 10 ++++++++--
 .../org/videolan/vlc/gui/AudioPlayerContainerActivity.java | 14 +++-----------
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 2ec0e10..9540b69 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -578,10 +578,12 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
                     changeAudioFocus(true);
                     if (!mWakeLock.isHeld())
                         mWakeLock.acquire();
-                    if (!keyguardManager.inKeyguardRestrictedInputMode() && !mVideoBackground && switchToVideo())
+                    if (!keyguardManager.inKeyguardRestrictedInputMode() && !mVideoBackground && switchToVideo()) {
                         hideNotification();
-                    else
+                    } else {
+                        showPlayer();
                         showNotification();
+                    }
                     mVideoBackground = false;
                     if (getCurrentMediaWrapper().getType() == MediaWrapper.TYPE_STREAM)
                         mMedialibrary.addToHistory(getCurrentMediaLocation(), getCurrentMediaWrapper().getTitle());
@@ -657,6 +659,10 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
         }
     };
 
+    private void showPlayer() {
+        sendBroadcast(new Intent(AudioPlayerContainerActivity.ACTION_SHOW_PLAYER));
+    }
+
     public void saveMediaMeta() {
         MediaWrapper media = mMedialibrary.findMedia(getCurrentMediaWrapper());
         if (media == null || media.getId() == 0)
diff --git a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
index cf2d080..1e4c457 100644
--- a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
@@ -46,8 +46,6 @@ import android.view.ViewGroup;
 import android.widget.FrameLayout;
 import android.widget.TextView;
 
-import org.videolan.libvlc.Media;
-import org.videolan.libvlc.MediaPlayer;
 import org.videolan.vlc.BuildConfig;
 import org.videolan.vlc.MediaParsingService;
 import org.videolan.vlc.PlaybackService;
@@ -231,13 +229,8 @@ public class AudioPlayerContainerActivity extends BaseActivity implements Playba
      */
     public void removeTipViewIfDisplayed() {
         View tips = findViewById(R.id.audio_tips);
-        if (tips == null)
-            return;
-        ViewGroup root = (ViewGroup) tips.getParent();
-        for (int i = 0; i < root.getChildCount(); ++i){
-            if (root.getChildAt(i).getId() == R.id.audio_tips)
-                root.removeViewAt(i);
-        }
+        if (tips != null)
+            ((ViewGroup) tips.getParent()).removeView(tips);
     }
     /**
      * Show the audio player.
@@ -387,8 +380,7 @@ public class AudioPlayerContainerActivity extends BaseActivity implements Playba
     @Override
     public void onConnected(PlaybackService service) {
         mService = service;
-
-        if (!isAudioPlayerReady())
+        if (service.hasMedia() && !mService.isVideoPlaying())
             showAudioPlayer();
     }
 



More information about the Android mailing list