[Android] Fix some video player shortcuts

Geoffrey Métais git at videolan.org
Mon Dec 9 15:34:24 CET 2019


vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey at videolan.org> | Mon Dec  9 13:20:11 2019 +0100| [39c596681157424728d1b4ef2345e871eb0db8cf] | committer: Nicolas Pomepuy

Fix some video player shortcuts

(cherry picked from commit bed8c8f59349cc7ec1524bbff5f774c1683dca32)

> https://code.videolan.org/videolan/vlc-android/commit/39c596681157424728d1b4ef2345e871eb0db8cf
---

 .../videolan/vlc/gui/video/VideoPlayerActivity.kt  | 23 ++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index adf873ab3..cba2114c8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -254,6 +254,7 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
                     HIDE_INFO -> hideOverlay(true)
                     SHOW_INFO -> showOverlay()
                     HIDE_SEEK -> touchDelegate?.hideSeekOverlay()
+                    HIDE_SETTINGS -> endPlaybackSetting()
                     else -> {
                     }
                 }
@@ -952,7 +953,9 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
     override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
         if (service == null || keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_BUTTON_B)
             return super.onKeyDown(keyCode, event)
-        if (isPlaybackSettingActive || isOptionsListShowing) return false
+        if (isOptionsListShowing) return false
+        if (isPlaybackSettingActive && keyCode != KeyEvent.KEYCODE_J && keyCode != KeyEvent.KEYCODE_K
+                && keyCode != KeyEvent.KEYCODE_G && keyCode != KeyEvent.KEYCODE_H) return false
         if (isLoading) {
             when (keyCode) {
                 KeyEvent.KEYCODE_S, KeyEvent.KEYCODE_MEDIA_STOP -> {
@@ -1098,14 +1101,20 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
                 super.onKeyDown(keyCode, event)
             KeyEvent.KEYCODE_J -> {
                 delayAudio(-50000L)
+                handler.removeMessages(HIDE_SETTINGS)
+                handler.sendEmptyMessageDelayed(HIDE_SETTINGS, 4000L)
                 return true
             }
             KeyEvent.KEYCODE_K -> {
                 delayAudio(50000L)
+                handler.removeMessages(HIDE_SETTINGS)
+                handler.sendEmptyMessageDelayed(HIDE_SETTINGS, 4000L)
                 return true
             }
             KeyEvent.KEYCODE_G -> {
                 delaySubs(-50000L)
+                handler.removeMessages(HIDE_SETTINGS)
+                handler.sendEmptyMessageDelayed(HIDE_SETTINGS, 4000L)
                 return true
             }
             KeyEvent.KEYCODE_T -> {
@@ -1114,7 +1123,11 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
             KeyEvent.KEYCODE_H -> {
                 if (event.isCtrlPressed) {
                     showOverlay()
-                } else delaySubs(50000L)
+                } else {
+                    delaySubs(50000L)
+                    handler.removeMessages(HIDE_SETTINGS)
+                    handler.sendEmptyMessageDelayed(HIDE_SETTINGS, 4000L)
+                }
                 return true
             }
             KeyEvent.KEYCODE_Z -> {
@@ -1149,7 +1162,7 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
                 if (event.isShiftPressed) {
                     service?.run { setRate(rate * 1.2f, true) }
                     return true
-                }
+                } else service?.run { setRate(1f, true) }
                 return false
             }
             KeyEvent.KEYCODE_MINUS -> {
@@ -1227,7 +1240,7 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
 
     @SuppressLint("ClickableViewAccessibility")
     fun showDelayControls() {
-        if (touchDelegate != null) touchDelegate!!.clearTouchAction()
+        touchDelegate?.clearTouchAction()
         if (!displayManager.isPrimary) showOverlayTimeout(OVERLAY_INFINITE)
         val vsc = findViewById<ViewStubCompat>(R.id.player_overlay_settings_stub)
         if (vsc != null) {
@@ -1267,6 +1280,7 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
     }
 
     override fun endPlaybackSetting() {
+        if (playbackSetting == IPlaybackSettingsController.DelayState.OFF) return
         service?.let { service ->
             service.saveMediaMeta()
             if (playbackSetting == IPlaybackSettingsController.DelayState.AUDIO && (audiomanager.isBluetoothA2dpOn || audiomanager.isBluetoothScoOn)) {
@@ -2726,6 +2740,7 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
         internal const val SHOW_INFO = 8
         internal const val HIDE_INFO = 9
         internal const val HIDE_SEEK = 10
+        internal const val HIDE_SETTINGS = 11
         private const val KEY_REMAINING_TIME_DISPLAY = "remaining_time_display"
         private const val KEY_BLUETOOTH_DELAY = "key_bluetooth_delay"
 



More information about the Android mailing list