From d3d75d8bc8b56142f779d099f31a49c82a049ce5 Mon Sep 17 00:00:00 2001 From: Krunal Patel Date: Thu, 1 Dec 2022 22:02:22 +0530 Subject: [PATCH] Fix synchronization of minimized player button --- .../libretube/ui/fragments/PlayerFragment.kt | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index d7b87a6ad..30c5da369 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -819,6 +819,14 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { if (isPlaying) { // Stop [BackgroundMode] service if it is running. BackgroundHelper.stopBackgroundPlay(requireContext()) + // video is playing + binding.playImageView.setImageResource(R.drawable.ic_pause) + } else if (exoPlayer.playbackState == Player.STATE_ENDED) { + // video has finished + binding.playImageView.setImageResource(R.drawable.ic_restart) + } else { + // player in any other state + binding.playImageView.setImageResource(R.drawable.ic_play) } if (isPlaying && PlayerHelper.sponsorBlockEnabled) { @@ -847,22 +855,11 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { playNextVideo() } - when (playbackState) { - Player.STATE_READY -> { - // media actually playing - transitioning = false - binding.playImageView.setImageResource(R.drawable.ic_pause) - // update the PiP params to use the correct aspect ratio - if (usePiP()) activity?.setPictureInPictureParams(getPipParams()) - } - Player.STATE_ENDED -> { - // video has finished - binding.playImageView.setImageResource(R.drawable.ic_restart) - } - else -> { - // player in any other state - binding.playImageView.setImageResource(R.drawable.ic_play) - } + if (playbackState == Player.STATE_READY) { + // media actually playing + transitioning = false + // update the PiP params to use the correct aspect ratio + if (usePiP()) activity?.setPictureInPictureParams(getPipParams()) } // save the watch position when paused