[Android] [PATCH 1/3] Video: implementation of the keyboard basic controls
Alexandre Perraud
4leyx4ndre at gmail.com
Thu Sep 25 17:19:26 CEST 2014
---
.../vlc/gui/video/VideoPlayerActivity.java | 45 ++++++++++++++++++++++
1 file changed, 45 insertions(+)
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 ecd28ce..79fc2db 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -90,6 +90,7 @@ import android.text.format.DateFormat;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
+import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.SurfaceHolder;
@@ -663,6 +664,50 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
}
@Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ showOverlay(OVERLAY_TIMEOUT);
+ switch (keyCode) {
+ case KeyEvent.KEYCODE_F:
+ case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
+ mForward.performClick();
+ return true;
+ case KeyEvent.KEYCODE_R:
+ case KeyEvent.KEYCODE_MEDIA_REWIND:
+ mBackward.performClick();
+ return true;
+ case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
+ case KeyEvent.KEYCODE_MEDIA_PLAY:
+ case KeyEvent.KEYCODE_MEDIA_PAUSE:
+ case KeyEvent.KEYCODE_SPACE:
+ mPlayPause.performClick();
+ return true;
+ case KeyEvent.KEYCODE_V:
+ mSubtitle.performClick();
+ return true;
+ case KeyEvent.KEYCODE_B:
+ case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK:
+ mAudioTrack.performClick();
+ return true;
+ case KeyEvent.KEYCODE_M:
+ case KeyEvent.KEYCODE_MENU:
+ mNavMenu.performClick();
+ return true;
+ case KeyEvent.KEYCODE_O:
+ mMenu.performClick();
+ return true;
+ case KeyEvent.KEYCODE_A:
+ mSize.performClick();
+ return true;
+ case KeyEvent.KEYCODE_S:
+ case KeyEvent.KEYCODE_MEDIA_STOP:
+ finish();
+ return true;
+ default:
+ return super.onKeyDown(keyCode, event);
+ }
+ }
+
+ @Override
public void onConfigurationChanged(Configuration newConfig) {
setSurfaceSize(mVideoWidth, mVideoHeight, mVideoVisibleWidth, mVideoVisibleHeight, mSarNum, mSarDen);
super.onConfigurationChanged(newConfig);
--
1.9.1
More information about the Android
mailing list