[Android] Update the playback speed video chip on media change
Nicolas Pomepuy
git at videolan.org
Mon Feb 17 13:32:36 UTC 2025
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Feb 17 11:14:52 2025 +0100| [a7ed22d89297188a5ff7c91f3711688392cd1854] | committer: Nicolas Pomepuy
Update the playback speed video chip on media change
Fixes #3149
> https://code.videolan.org/videolan/vlc-android/commit/a7ed22d89297188a5ff7c91f3711688392cd1854
---
.../videolan/vlc/gui/video/VideoPlayerActivity.kt | 1 +
.../vlc/gui/video/VideoPlayerOverlayDelegate.kt | 24 ++++++++++++++--------
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index 9068232df8..8d3bd585fc 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -1741,6 +1741,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
val surfaceView = rootView?.findViewById<View>(R.id.surface_video) as SurfaceView
FrameRateManager(this, service!!).matchFrameRate(surfaceView, window)
}
+ overlayDelegate.updatePlaybackSpeedChip()
}
private fun encounteredError() {
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 975230a61c..2d310e645d 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
@@ -941,19 +941,14 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
hudRightBinding.playerScreenshot.visibility = if (Settings.getInstance(player).getString(SCREENSHOT_MODE, "0") in arrayOf("1", "3")) View.VISIBLE else View.GONE
hudRightBinding.playerOverlayNavmenu.visibility = if (player.menuIdx >= 0) View.VISIBLE else View.GONE
hudRightBinding.sleepQuickAction.visibility = if (show && PlaybackService.playerSleepTime.value != null) View.VISIBLE else View.GONE
- hudRightBinding.playbackSpeedQuickAction.visibility = if (show && player.service?.rate != 1.0F) View.VISIBLE else View.GONE
- if (Settings.getInstance(player).getBoolean(KEY_PLAYBACK_SPEED_VIDEO_GLOBAL, false)) {
- hudRightBinding.playbackSpeedQuickAction.chipIcon = ContextCompat.getDrawable(player, R.drawable.ic_speed_all)
- } else {
- hudRightBinding.playbackSpeedQuickAction.chipIcon = ContextCompat.getDrawable(player, R.drawable.ic_speed)
- }
+
hudRightBinding.spuDelayQuickAction.visibility = if (show && player.service?.spuDelay != 0L) View.VISIBLE else View.GONE
hudRightBinding.audioDelayQuickAction.visibility = if (show && player.service?.audioDelay != 0L) View.VISIBLE else View.GONE
hudRightBinding.clock.visibility = if (Settings.showTvUi) View.VISIBLE else View.GONE
- hudRightBinding.playbackSpeedQuickAction.text = player.service?.rate?.formatRateString()
- hudRightBinding.playbackSpeedQuickAction.contentDescription = player.getString(R.string.playback_speed)+ ". " + player.service?.rate?.formatRateString()
+ hudRightBinding.playbackSpeedQuickAction.visibility = if (show && player.service?.rate != 1.0F) View.VISIBLE else View.GONE
+ updatePlaybackSpeedChip()
val format = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.getDefault())
PlaybackService.playerSleepTime.value?.let {
hudRightBinding.sleepQuickAction.text = format.format(it.time)
@@ -966,6 +961,19 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
}
+ fun updatePlaybackSpeedChip() {
+ if (::hudRightBinding.isInitialized) {
+ hudRightBinding.playbackSpeedQuickAction.text = player.service?.rate?.formatRateString()
+ hudRightBinding.playbackSpeedQuickAction.contentDescription = player.getString(R.string.playback_speed) + ". " + player.service?.rate?.formatRateString()
+ if (player.service?.rate == 1.0F) hudRightBinding.playbackSpeedQuickAction.setGone()
+ if (Settings.getInstance(player).getBoolean(KEY_PLAYBACK_SPEED_VIDEO_GLOBAL, false)) {
+ hudRightBinding.playbackSpeedQuickAction.chipIcon = ContextCompat.getDrawable(player, R.drawable.ic_speed_all)
+ } else {
+ hudRightBinding.playbackSpeedQuickAction.chipIcon = ContextCompat.getDrawable(player, R.drawable.ic_speed)
+ }
+ }
+ }
+
/**
* hider overlay
*/
More information about the Android
mailing list