[Android] No long/double press on playpause button on TV

Geoffrey Métais git at videolan.org
Fri Aug 7 14:12:33 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Aug  7 13:02:27 2015 +0200| [aa94abbddd0aebefb13803d6baa67bde7ec4e767] | committer: Geoffrey Métais

No long/double press on playpause button on TV

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

 .../videolan/vlc/RemoteControlClientReceiver.java  |   32 +++++++++-----------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/RemoteControlClientReceiver.java b/vlc-android/src/org/videolan/vlc/RemoteControlClientReceiver.java
index a97cc6c..5fb8e93 100644
--- a/vlc-android/src/org/videolan/vlc/RemoteControlClientReceiver.java
+++ b/vlc-android/src/org/videolan/vlc/RemoteControlClientReceiver.java
@@ -19,9 +19,6 @@
  *****************************************************************************/
 package org.videolan.vlc;
 
-import org.videolan.libvlc.MediaPlayer;
-import org.videolan.vlc.util.VLCInstance;
-
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
@@ -50,8 +47,8 @@ public class RemoteControlClientReceiver extends BroadcastReceiver {
                 return;
 
             if (event.getKeyCode() != KeyEvent.KEYCODE_HEADSETHOOK &&
-                event.getKeyCode() != KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE &&
-                event.getAction() != KeyEvent.ACTION_DOWN)
+                    event.getKeyCode() != KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE &&
+                    event.getAction() != KeyEvent.ACTION_DOWN)
                 return;
 
             Intent i = null;
@@ -67,23 +64,22 @@ public class RemoteControlClientReceiver extends BroadcastReceiver {
                     long time = SystemClock.uptimeMillis();
                     switch (event.getAction()) {
                         case KeyEvent.ACTION_DOWN:
-                            if (event.getRepeatCount() > 0)
-                                break;
-                            mHeadsetDownTime = time;
+                            if (event.getRepeatCount() <= 0)
+                                mHeadsetDownTime = time;
                             break;
                         case KeyEvent.ACTION_UP:
-                            // long click
-                            if (time - mHeadsetDownTime >= 1000) {
-                                i = new Intent(PlaybackService.ACTION_REMOTE_BACKWARD);
-                                time = 0;
-                                // double click
-                            } else if (time - mHeadsetUpTime <= 500) {
-                                i = new Intent(PlaybackService.ACTION_REMOTE_FORWARD);
+                            if (!BuildConfig.tv) { //no backward/forward on TV
+                                if (time - mHeadsetDownTime >= 1000) { // long click
+                                    i = new Intent(PlaybackService.ACTION_REMOTE_BACKWARD);
+                                    time = 0;
+                                    break;
+                                } else if (time - mHeadsetUpTime <= 500) { // double click
+                                    i = new Intent(PlaybackService.ACTION_REMOTE_FORWARD);
+                                    break;
+                                }
                             }
                             // one click
-                            else {
-                                i = new Intent(PlaybackService.ACTION_REMOTE_PLAYPAUSE);
-                            }
+                            i = new Intent(PlaybackService.ACTION_REMOTE_PLAYPAUSE);
                             mHeadsetUpTime = time;
                             break;
                     }



More information about the Android mailing list