Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix media controller UI not showing during audio playback #3286

Merged
merged 3 commits into from
Feb 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,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()
}
Expand Down Expand Up @@ -124,18 +124,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()
Expand All @@ -161,6 +160,11 @@ class ViewVideoFragment : ViewMediaFragment() {
false
}

// Audio doesn't cause the controller to show automatically
if (isAudio) {
mediaController.show()
}

binding.progressBar.hide()
mp.isLooping = true
}
Expand Down