[Android] Respect paused state on popup expanding to player

Geoffrey Métais git at videolan.org
Wed Jul 12 12:17:26 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jul 12 10:15:35 2017 +0200| [5fd5b0b35a64e54baca3915b0f85025d8f44de83] | committer: Geoffrey Métais

Respect paused state on popup expanding to player

> https://code.videolan.org/videolan/vlc-android/commit/5fd5b0b35a64e54baca3915b0f85025d8f44de83
---

 .../org/videolan/vlc/gui/video/PopupManager.java   | 23 +++++++++++-----------
 .../vlc/gui/video/VideoPlayerActivity.java         |  2 ++
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java b/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
index fc180318c..878af0d14 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
@@ -45,6 +45,7 @@ import android.widget.ImageView;
 import org.videolan.libvlc.IVLCVout;
 import org.videolan.libvlc.Media;
 import org.videolan.libvlc.MediaPlayer;
+import org.videolan.medialibrary.media.MediaWrapper;
 import org.videolan.vlc.PlaybackService;
 import org.videolan.vlc.R;
 import org.videolan.vlc.VLCApplication;
@@ -79,7 +80,6 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
         hideNotification();
         if (mRootView == null)
             return;
-        mService.setVideoTrackEnabled(false);
         mService.removeCallback(this);
         final IVLCVout vlcVout = mService.getVLCVout();
         vlcVout.detachViews();
@@ -122,8 +122,7 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
 
     @Override
     public boolean onDoubleTap(MotionEvent e) {
-        mService.removePopup();
-        mService.switchToVideo();
+        expandToVideoPlayer();
         return true;
     }
 
@@ -215,7 +214,7 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
     public void onMediaPlayerEvent(MediaPlayer.Event event) {
         switch (event.type) {
             case MediaPlayer.Event.Stopped:
-                mService.removePopup();
+                removePopup();
                 break;
             case MediaPlayer.Event.Playing:
                 if (!mAlwaysOn)
@@ -257,12 +256,18 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
                 stopPlayback();
                 break;
             case R.id.popup_expand:
-                mService.removePopup();
-                mService.switchToVideo();
+                expandToVideoPlayer();
                 break;
         }
     }
 
+    private void expandToVideoPlayer() {
+        removePopup();
+        if (mService.hasMedia() && !mService.isPlaying())
+            mService.getCurrentMediaWrapper().setFlags(MediaWrapper.MEDIA_PAUSED);
+        mService.switchToVideo();
+    }
+
     private void stopPlayback() {
         long time = mService.getTime();
         if (time != -1) {
@@ -317,16 +322,12 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
         mService.setVideoTrackEnabled(true);
         if (mService.hasMedia()) {
             mService.flush();
-            updatePlayIcon();
+            mPlayPauseButton.setImageResource(mService.isPlaying() ? R.drawable.ic_popup_pause : R.drawable.ic_popup_play);
         } else
             mService.playIndex(mService.getCurrentMediaPosition());
         showNotification();
     }
 
-    private void updatePlayIcon() {
-        mPlayPauseButton.setImageResource(mService.isPlaying() ? R.drawable.ic_popup_pause : R.drawable.ic_popup_play);
-    }
-
     @Override
     public void onSurfacesDestroyed(IVLCVout vlcVout) {
         vlcVout.removeCallback(this);
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 78e695582..cd1db79a3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -612,6 +612,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             if (Permissions.canDrawOverlays(this)) {
                 mSwitchingView = true;
                 mSwitchToPopup = true;
+                if (!mService.isPlaying())
+                    mService.getCurrentMediaWrapper().addFlags(MediaWrapper.MEDIA_PAUSED);
                 cleanUI();
                 exitOK();
             } else



More information about the Android mailing list