[Android] TV: d-pad navigation for video playlist

Geoffrey Métais git at videolan.org
Thu Jan 14 17:31:36 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan 14 16:12:44 2016 +0100| [882f827ff1d69982deb71dfbd0dab1fa2cf06e0a] | committer: Geoffrey Métais

TV: d-pad navigation for video playlist

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

 .../src/org/videolan/vlc/gui/audio/PlaylistAdapter.java   |  6 +++++-
 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java   | 15 +++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.java
index 3f01297..cf3c02a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.java
@@ -140,8 +140,12 @@ public class PlaylistAdapter extends RecyclerView.Adapter<PlaylistAdapter.ViewHo
         mOriginalDataSet.clear();
     }
 
+    public int getCurrentIndex() {
+        return mCurrentIndex;
+    }
+
     public void setCurrentIndex(int position) {
-        if (position == mCurrentIndex)
+        if (position == mCurrentIndex || position < 0 || position >= mDataSet.size())
             return;
         int former = mCurrentIndex;
         mCurrentIndex = position;
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 08ed300..3598e32 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1066,6 +1066,21 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             }
             return false;
         }
+        //Handle playlist d-pad navigation
+        if (mPlaylist.hasFocus()) {
+            switch (keyCode) {
+                case KeyEvent.KEYCODE_DPAD_UP:
+                    mPlaylistAdapter.setCurrentIndex(mPlaylistAdapter.getCurrentIndex() - 1);
+                    break;
+                case KeyEvent.KEYCODE_DPAD_DOWN:
+                    mPlaylistAdapter.setCurrentIndex(mPlaylistAdapter.getCurrentIndex() + 1);
+                    break;
+                case KeyEvent.KEYCODE_ENTER:
+                    mService.playIndex(mPlaylistAdapter.getCurrentIndex());
+                    break;
+            }
+            return true;
+        }
         showOverlayTimeout(OVERLAY_TIMEOUT);
         switch (keyCode) {
         case KeyEvent.KEYCODE_F:



More information about the Android mailing list