[Android] Additionnal keybindings for video player

Geoffrey Métais git at videolan.org
Wed Dec 20 16:41:40 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Dec 20 16:41:12 2017 +0100| [08eddc7f570df5a22b6675772850a2b6183c43b8] | committer: Geoffrey Métais

Additionnal keybindings for video player

> https://code.videolan.org/videolan/vlc-android/commit/08eddc7f570df5a22b6675772850a2b6183c43b8
---

 .../vlc/gui/video/VideoPlayerActivity.java         | 71 +++++++++++++++-------
 1 file changed, 50 insertions(+), 21 deletions(-)

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 c6171edf4..62c31d4d9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1249,7 +1249,10 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                     return true;
                 }
             case KeyEvent.KEYCODE_DPAD_UP:
-                if (!mShowing) {
+                if (event.isCtrlPressed()) {
+                    volumeUp();
+                    return true;
+                } else if (!mShowing) {
                     if (mFov == 0f)
                         showAdvancedOptions();
                     else
@@ -1257,7 +1260,10 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                     return true;
                 }
             case KeyEvent.KEYCODE_DPAD_DOWN:
-                if (!mShowing && mFov != 0f) {
+                if (event.isCtrlPressed()) {
+                    volumeDown();
+                    return true;
+                } else if (!mShowing && mFov != 0f) {
                     mService.updateViewpoint(0f, 5f, 0f, 0f, false);
                     return true;
                 }
@@ -1284,35 +1290,58 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                 delaySubs(50000L);
                 return true;
             case KeyEvent.KEYCODE_VOLUME_DOWN:
-                int vol;
-                if (mService.getVolume() > 100)
-                    vol = Math.round(((float)mService.getVolume())*mAudioMax/100 - 1);
-                else
-                    vol = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) - 1;
-                vol = Math.min(Math.max(vol, 0), mAudioMax * (audioBoostEnabled ? 2 : 1));
-                mOriginalVol = vol;
-                setAudioVolume(vol);
+                volumeDown();
                 return true;
             case KeyEvent.KEYCODE_VOLUME_UP:
-                if (mMute) {
-                    updateMute();
-                } else {
-                    int volume;
-                    if (mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) < mAudioMax)
-                        volume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) + 1;
-                    else
-                        volume = Math.round(((float)mService.getVolume())*mAudioMax/100 + 1);
-                    volume = Math.min(Math.max(volume, 0), mAudioMax * (audioBoostEnabled ? 2 : 1));
-                    setAudioVolume(volume);
-                }
+                volumeUp();
                 return true;
             case KeyEvent.KEYCODE_CAPTIONS:
                 selectSubtitles();
                 return true;
+            case KeyEvent.KEYCODE_PLUS:
+                mService.setRate(mService.getRate()*1.2f, true);
+                return true;
+            case KeyEvent.KEYCODE_EQUALS:
+                if (event.isShiftPressed()) {
+                    mService.setRate(mService.getRate() * 1.2f, true);
+                    return true;
+                }
+                return false;
+            case KeyEvent.KEYCODE_MINUS:
+                mService.setRate(mService.getRate()/1.2f, true);
+                return true;
+            case KeyEvent.KEYCODE_C:
+                resizeVideo();
+                return true;
         }
         return super.onKeyDown(keyCode, event);
     }
 
+    private void volumeUp() {
+        if (mMute) {
+            updateMute();
+        } else {
+            int volume;
+            if (mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) < mAudioMax)
+                volume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) + 1;
+            else
+                volume = Math.round(((float)mService.getVolume())*mAudioMax/100 + 1);
+            volume = Math.min(Math.max(volume, 0), mAudioMax * (audioBoostEnabled ? 2 : 1));
+            setAudioVolume(volume);
+        }
+    }
+
+    private void volumeDown() {
+        int vol;
+        if (mService.getVolume() > 100)
+            vol = Math.round(((float)mService.getVolume())*mAudioMax/100 - 1);
+        else
+            vol = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) - 1;
+        vol = Math.min(Math.max(vol, 0), mAudioMax * (audioBoostEnabled ? 2 : 1));
+        mOriginalVol = vol;
+        setAudioVolume(vol);
+    }
+
     private boolean navigateDvdMenu(int keyCode) {
         switch (keyCode) {
             case KeyEvent.KEYCODE_DPAD_UP:



More information about the Android mailing list