[Android] Fix play/pause from notification

Geoffrey Métais git at videolan.org
Mon Mar 14 12:29:06 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Mar 14 10:34:28 2016 +0100| [d743d3d3267bff689ea5c6f2f7d5cbc36cb17a64] | committer: Geoffrey Métais

Fix play/pause from notification

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

 .../src/org/videolan/vlc/PlaybackService.java       | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 9acf1ba..be65af6 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -467,9 +467,11 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
              * Remote / headset control events
              */
             if (action.equalsIgnoreCase(ACTION_REMOTE_PLAYPAUSE)) {
-                if (hasCurrentMedia())
+                if (!hasCurrentMedia())
+                    return;
+                if (mMediaPlayer.isPlaying())
                     pause();
-                else if (!mMediaPlayer.isPlaying() && hasCurrentMedia())
+                else
                     play();
             } else if (action.equalsIgnoreCase(ACTION_REMOTE_PLAY)) {
                 if (!mMediaPlayer.isPlaying() && hasCurrentMedia())
@@ -479,7 +481,8 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
                     pause();
             } else if (action.equalsIgnoreCase(ACTION_REMOTE_BACKWARD)) {
                 previous();
-            } else if (action.equalsIgnoreCase(ACTION_REMOTE_STOP)) {
+            } else if (action.equalsIgnoreCase(ACTION_REMOTE_STOP) ||
+                    action.equalsIgnoreCase(VLCApplication.SLEEP_INTENT)) {
                 stop();
             } else if (action.equalsIgnoreCase(ACTION_REMOTE_FORWARD)) {
                 next();
@@ -499,25 +502,17 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
             /*
              * headset plug events
              */
-            if (mDetectHeadset && !mHasHdmiAudio) {
+            else if (mDetectHeadset && !mHasHdmiAudio) {
                 if (action.equalsIgnoreCase(AudioManager.ACTION_AUDIO_BECOMING_NOISY)) {
                     Log.i(TAG, "Headset Removed.");
                     if (hasCurrentMedia())
                         pause();
-                }
-                else if (action.equalsIgnoreCase(Intent.ACTION_HEADSET_PLUG) && state != 0) {
+                } else if (action.equalsIgnoreCase(Intent.ACTION_HEADSET_PLUG) && state != 0) {
                     Log.i(TAG, "Headset Inserted.");
                     if (hasCurrentMedia())
                         play();
                 }
             }
-
-            /*
-             * Sleep
-             */
-            if (action.equalsIgnoreCase(VLCApplication.SLEEP_INTENT)) {
-                stop();
-            }
         }
     };
 



More information about the Android mailing list