[Android] Implement Video player HUD delay
Nicolas Pomepuy
git at videolan.org
Fri Nov 13 07:31:03 CET 2020
vlc-android | branch: 3.3.x | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Nov 5 14:40:15 2020 +0100| [ad6664d90b943564563a6cabaf59b4d84b2dc1e9] | committer: Nicolas Pomepuy
Implement Video player HUD delay
Fixes #1528
(cherry picked from commit 6b55256a33b623d924262e55d74fea008dc4872c)
> https://code.videolan.org/videolan/vlc-android/commit/ad6664d90b943564563a6cabaf59b4d84b2dc1e9
---
.../resources/src/main/res/values/arrays.xml | 14 ++++++++++++
.../resources/src/main/res/values/strings.xml | 6 ++++++
.../src/main/java/org/videolan/tools/Settings.kt | 3 +++
.../vlc-android/res/xml/preferences_video.xml | 10 +++++++++
.../vlc/gui/preferences/PreferencesVideo.kt | 25 +++++++++++++++++++---
.../vlc/gui/video/VideoPlayerOverlayDelegate.kt | 8 ++++++-
6 files changed, 62 insertions(+), 4 deletions(-)
diff --git a/application/resources/src/main/res/values/arrays.xml b/application/resources/src/main/res/values/arrays.xml
index 2b6170575..06275b561 100644
--- a/application/resources/src/main/res/values/arrays.xml
+++ b/application/resources/src/main/res/values/arrays.xml
@@ -423,4 +423,18 @@
<item>2</item>
</string-array>
+ <string-array name="video_hud_timeout_entries">
+ <item>@string/timeout_infinite</item>
+ <item>@string/timeout_short</item>
+ <item>@string/timeout_normal</item>
+ <item>@string/timeout_long</item>
+ </string-array>
+
+ <string-array name="video_hud_timeout_values">
+ <item>-1</item>
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ </string-array>
+
</resources>
\ No newline at end of file
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 3f7083500..0b8cb692c 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -767,4 +767,10 @@
<string name="air_action_previous">Previous item in playback</string>
<string name="allow_otg">Allow OTG access</string>
<string name="allow_otg_description">Please select your OTG drive to allow access to VLC.</string>
+ <string name="timeout_infinite">Infinite</string>
+ <string name="timeout_short">Short</string>
+ <string name="timeout_normal">Normal</string>
+ <string name="timeout_long">Long</string>
+ <string name="video_hud_timeout">Video player controls hiding delay</string>
+
</resources>
diff --git a/application/tools/src/main/java/org/videolan/tools/Settings.kt b/application/tools/src/main/java/org/videolan/tools/Settings.kt
index cada8c50c..ff6cb640a 100644
--- a/application/tools/src/main/java/org/videolan/tools/Settings.kt
+++ b/application/tools/src/main/java/org/videolan/tools/Settings.kt
@@ -21,6 +21,7 @@ object Settings : SingletonHolder<SharedPreferences, Context>({ init(it.applicat
var tvUI = false
var listTitleEllipsize = 0
var overrideTvUI = false
+ var videoHudDelay = 2
lateinit var device : DeviceInfo
private set
@@ -29,6 +30,7 @@ object Settings : SingletonHolder<SharedPreferences, Context>({ init(it.applicat
showVideoThumbs = prefs.getBoolean(SHOW_VIDEO_THUMBNAILS, true)
tvUI = prefs.getBoolean(PREF_TV_UI, false)
listTitleEllipsize = prefs.getString(LIST_TITLE_ELLIPSIZE, "0")?.toInt() ?: 0
+ videoHudDelay = prefs.getString(VIDEO_HUD_TIMEOUT, "2")?.toInt() ?: 2
device = DeviceInfo(context)
return prefs
}
@@ -81,6 +83,7 @@ const val KEY_PLAYBACK_RATE = "playback_rate"
const val KEY_PLAYBACK_SPEED_PERSIST = "playback_speed"
const val KEY_VIDEO_APP_SWITCH = "video_action_switch"
const val VIDEO_TRANSITION_SHOW = "video_transition_show"
+const val VIDEO_HUD_TIMEOUT = "video_hud_timeout"
const val RESULT_RESCAN = Activity.RESULT_FIRST_USER + 1
const val RESULT_RESTART = Activity.RESULT_FIRST_USER + 2
const val RESULT_RESTART_APP = Activity.RESULT_FIRST_USER + 3
diff --git a/application/vlc-android/res/xml/preferences_video.xml b/application/vlc-android/res/xml/preferences_video.xml
index dfbe5bc4f..3e8a0eda2 100644
--- a/application/vlc-android/res/xml/preferences_video.xml
+++ b/application/vlc-android/res/xml/preferences_video.xml
@@ -87,6 +87,16 @@
android:key="popup_keepscreen"
android:summary="@string/popup_keepscreen_summary"
android:title="@string/popup_keepscreen_title"/>
+
+ <ListPreference
+ app:singleLineTitle="false"
+ android:defaultValue="2"
+ android:key="video_hud_timeout"
+ android:entries="@array/video_hud_timeout_entries"
+ android:entryValues="@array/video_hud_timeout_values"
+ android:summary="%s"
+ android:title="@string/video_hud_timeout"/>
+
</PreferenceCategory>
<PreferenceCategory
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.kt
index 47344267e..50154847c 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.kt
@@ -22,18 +22,18 @@
package org.videolan.vlc.gui.preferences
+import android.content.SharedPreferences
import android.os.Bundle
import androidx.preference.Preference
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import org.videolan.libvlc.util.AndroidUtil
+import org.videolan.tools.*
import org.videolan.vlc.R
-import org.videolan.tools.POPUP_FORCE_LEGACY
-import org.videolan.tools.POPUP_KEEPSCREEN
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
-class PreferencesVideo : BasePreferenceFragment() {
+class PreferencesVideo : BasePreferenceFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
override fun getXml() = R.xml.preferences_video
@@ -44,4 +44,23 @@ class PreferencesVideo : BasePreferenceFragment() {
findPreference<Preference>(POPUP_KEEPSCREEN)?.isVisible = !AndroidUtil.isOOrLater
findPreference<Preference>(POPUP_FORCE_LEGACY)?.isVisible = AndroidUtil.isOOrLater
}
+
+ override fun onStart() {
+ super.onStart()
+ preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
+ }
+
+ override fun onStop() {
+ super.onStop()
+ preferenceScreen.sharedPreferences
+ .unregisterOnSharedPreferenceChangeListener(this)
+ }
+
+ override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
+ when (key) {
+ VIDEO_HUD_TIMEOUT -> {
+ Settings.videoHudDelay = sharedPreferences.getString(VIDEO_HUD_TIMEOUT, "2")?.toInt() ?: 2
+ }
+ }
+ }
}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
index 2c7938b3a..e99738cfc 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
@@ -279,8 +279,14 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
initOverlay()
if (!::hudBinding.isInitialized) return
overlayTimeout = when {
+ Settings.videoHudDelay == -2 -> VideoPlayerActivity.OVERLAY_INFINITE
timeout != 0 -> timeout
- service.isPlaying -> VideoPlayerActivity.OVERLAY_TIMEOUT
+ service.isPlaying -> when (Settings.videoHudDelay) {
+ -1 -> VideoPlayerActivity.OVERLAY_INFINITE
+ 1 -> VideoPlayerActivity.OVERLAY_TIMEOUT / 2
+ 3 -> VideoPlayerActivity.OVERLAY_TIMEOUT * 2
+ else -> VideoPlayerActivity.OVERLAY_TIMEOUT
+ }
else -> VideoPlayerActivity.OVERLAY_INFINITE
}
if (player.isNavMenu) {
More information about the Android
mailing list