Commit caf4fda9 authored by Geoffrey Métais's avatar Geoffrey Métais

DVD navigation with remote

parent b13ca457
...@@ -621,3 +621,12 @@ jint Java_org_videolan_libvlc_LibVLC_getTitleCount(JNIEnv *env, jobject thiz) ...@@ -621,3 +621,12 @@ jint Java_org_videolan_libvlc_LibVLC_getTitleCount(JNIEnv *env, jobject thiz)
return libvlc_media_player_get_title_count(mp); return libvlc_media_player_get_title_count(mp);
return -1; 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);
}
...@@ -49,6 +49,12 @@ public class LibVLC { ...@@ -49,6 +49,12 @@ public class LibVLC {
public static final int DEV_HW_DECODER_MEDIACODEC = 2; public static final int DEV_HW_DECODER_MEDIACODEC = 2;
public static final int DEV_HW_DECODER_MEDIACODEC_DR = 3; 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 final String DEFAULT_CODEC_LIST = "mediacodec,iomx,all";
private static LibVLC sInstance; private static LibVLC sInstance;
...@@ -848,5 +854,6 @@ public class LibVLC { ...@@ -848,5 +854,6 @@ public class LibVLC {
public native void setTitle(int title); public native void setTitle(int title);
public native int getChapterCountForTitle(int title); public native int getChapterCountForTitle(int title);
public native int getTitleCount(); public native int getTitleCount();
public native void playerNavigate(int navigate);
} }
...@@ -788,11 +788,44 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer { ...@@ -788,11 +788,44 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
case KeyEvent.KEYCODE_MEDIA_STOP: case KeyEvent.KEYCODE_MEDIA_STOP:
finish(); finish();
return true; 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: default:
return super.onKeyDown(keyCode, event); 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 @Override
public void onConfigurationChanged(Configuration newConfig) { public void onConfigurationChanged(Configuration newConfig) {
setSurfaceSize(mVideoWidth, mVideoHeight, mVideoVisibleWidth, mVideoVisibleHeight, mSarNum, mSarDen); setSurfaceSize(mVideoWidth, mVideoHeight, mVideoVisibleWidth, mVideoVisibleHeight, mSarNum, mSarDen);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment