[Android] DVD navigation with remote

Geoffrey Métais git at videolan.org
Mon Nov 3 16:55:04 CET 2014


vlc-ports/android | branch: 1.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Oct 31 16:18:24 2014 +0100| [1f2ea0a3980ea69e52f1e347678421fe5cdb092c] | committer: Jean-Baptiste Kempf

DVD navigation with remote

(cherry picked from commit caf4fda937ba7fe5bbfdb46be4b7c1c763036341)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

Conflicts:
	vlc-android/src/org/videolan/libvlc/LibVLC.java

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

 vlc-android/jni/libvlcjni.c                        |    9 ++++++
 vlc-android/src/org/videolan/libvlc/LibVLC.java    |    7 +++++
 .../vlc/gui/video/VideoPlayerActivity.java         |   33 ++++++++++++++++++++
 3 files changed, 49 insertions(+)

diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
index df49f6e..e89105a 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -602,3 +602,12 @@ jint Java_org_videolan_libvlc_LibVLC_getTitleCount(JNIEnv *env, jobject thiz)
         return libvlc_media_player_get_title_count(mp);
     return -1;
 }
+
+void Java_org_videolan_libvlc_LibVLC_playerNavigate(JNIEnv *env, jobject thiz, jint navigate)
+{
+    unsigned nav = navigate;
+    libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
+    if (mp)
+        libvlc_media_player_navigate(mp, (unsigned) nav);
+}
+
diff --git a/vlc-android/src/org/videolan/libvlc/LibVLC.java b/vlc-android/src/org/videolan/libvlc/LibVLC.java
index 8023e53..ab3184f 100644
--- a/vlc-android/src/org/videolan/libvlc/LibVLC.java
+++ b/vlc-android/src/org/videolan/libvlc/LibVLC.java
@@ -43,6 +43,12 @@ public class LibVLC {
     public static final int HW_ACCELERATION_DECODING = 1;
     public static final int HW_ACCELERATION_FULL = 2;
 
+    public static final int INPUT_NAV_ACTIVATE = 0;
+    public static final int INPUT_NAV_UP = 1;
+    public static final int INPUT_NAV_DOWN = 2;
+    public static final int INPUT_NAV_LEFT = 3;
+    public static final int INPUT_NAV_RIGHT = 4;
+
     private static LibVLC sInstance;
 
     /** libVLC instance C pointer */
@@ -742,5 +748,6 @@ public class LibVLC {
     public native void setTitle(int title);
     public native int getChapterCountForTitle(int title);
     public native int getTitleCount();
+    public native void playerNavigate(int navigate);
 
 }
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 4c9e158..56efc96 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -799,11 +799,44 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         case KeyEvent.KEYCODE_MEDIA_STOP:
             finish();
             return true;
+        case KeyEvent.KEYCODE_DPAD_UP:
+        case KeyEvent.KEYCODE_DPAD_DOWN:
+        case KeyEvent.KEYCODE_DPAD_LEFT:
+        case KeyEvent.KEYCODE_DPAD_RIGHT:
+        case KeyEvent.KEYCODE_DPAD_CENTER:
+        case KeyEvent.KEYCODE_ENTER:
+            if (mIsNavMenu)
+                return navigateDvdMenu(keyCode);
+            else
+                return super.onKeyDown(keyCode, event);
         default:
             return super.onKeyDown(keyCode, event);
         }
     }
 
+    private boolean navigateDvdMenu(int keyCode) {
+        switch (keyCode) {
+            case KeyEvent.KEYCODE_DPAD_UP:
+                mLibVLC.playerNavigate(LibVLC.INPUT_NAV_UP);
+                return true;
+            case KeyEvent.KEYCODE_DPAD_DOWN:
+                mLibVLC.playerNavigate(LibVLC.INPUT_NAV_DOWN);
+                return true;
+            case KeyEvent.KEYCODE_DPAD_LEFT:
+                mLibVLC.playerNavigate(LibVLC.INPUT_NAV_LEFT);
+                return true;
+            case KeyEvent.KEYCODE_DPAD_RIGHT:
+                mLibVLC.playerNavigate(LibVLC.INPUT_NAV_RIGHT);
+                return true;
+            case KeyEvent.KEYCODE_DPAD_CENTER:
+            case KeyEvent.KEYCODE_ENTER:
+                mLibVLC.playerNavigate(LibVLC.INPUT_NAV_ACTIVATE);
+                return true;
+            default:
+                return false;
+        }
+    }
+
     @Override
     public void onConfigurationChanged(Configuration newConfig) {
         setSurfaceSize(mVideoWidth, mVideoHeight, mVideoVisibleWidth, mVideoVisibleHeight, mSarNum, mSarDen);



More information about the Android mailing list