[Android] [PATCH] DVD navigation with remote
Geoffrey Métais
geoffrey.metais at gmail.com
Fri Oct 31 16:18:24 CET 2014
---
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 0813d7c..512f0f6 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -621,3 +621,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 8d5ad0e..790855a 100644
--- a/vlc-android/src/org/videolan/libvlc/LibVLC.java
+++ b/vlc-android/src/org/videolan/libvlc/LibVLC.java
@@ -49,6 +49,12 @@ public class LibVLC {
public static final int DEV_HW_DECODER_MEDIACODEC = 2;
public static final int DEV_HW_DECODER_MEDIACODEC_DR = 3;
+ 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 final String DEFAULT_CODEC_LIST = "mediacodec,iomx,all";
private static LibVLC sInstance;
@@ -848,5 +854,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 d80b92d..a27cfe1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -788,11 +788,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);
--
1.9.1
More information about the Android
mailing list