From 9e0ff78fb4ef2162998f0d30ccfe9cb7dea109ef Mon Sep 17 00:00:00 2001 From: Eric Frohnhoefer Date: Thu, 23 Feb 2023 10:41:16 -0800 Subject: [PATCH] Fix media controller UI not showing during audio playback (#3286) * Update ViewVideoFragment.kt Testing - Open audio attachment: https://solarpunk.moe/@vv/109562659215759090 - Ensure media control UI and alt text is shown once playback starts Fixes #3261 * Fix commit issue * Fix spacing --- .../tusky/fragment/ViewVideoFragment.kt | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt index 9576825e..68dc6687 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt @@ -73,8 +73,8 @@ class ViewVideoFragment : ViewMediaFragment() { super.onResume() if (_binding != null) { - if (mediaActivity.isToolbarVisible) { - handler.postDelayed(hideToolbar, TOOLBAR_HIDE_DELAY_MS) + if (mediaActivity.isToolbarVisible && !isAudio) { + hideToolbarAfterDelay(TOOLBAR_HIDE_DELAY_MS) } binding.videoView.start() } @@ -130,18 +130,17 @@ class ViewVideoFragment : ViewMediaFragment() { binding.videoView.setMediaController(mediaController) binding.videoView.requestFocus() binding.videoView.setPlayPauseListener(object : ExposedPlayPauseVideoView.PlayPauseListener { - override fun onPause() { - handler.removeCallbacks(hideToolbar) - } override fun onPlay() { - // Audio doesn't cause the controller to show automatically, - // and we only want to hide the toolbar if it's a video. - if (isAudio) { - mediaController.show() - } else { + if (!isAudio) { hideToolbarAfterDelay(TOOLBAR_HIDE_DELAY_MS) } } + + override fun onPause() { + if (!isAudio) { + handler.removeCallbacks(hideToolbar) + } + } }) binding.videoView.setOnPreparedListener { mp -> val containerWidth = binding.videoContainer.measuredWidth.toFloat() @@ -167,6 +166,11 @@ class ViewVideoFragment : ViewMediaFragment() { false } + // Audio doesn't cause the controller to show automatically + if (isAudio) { + mediaController.show() + } + binding.progressBar.hide() mp.isLooping = true }