Fix synchronization of minimized player button

This commit is contained in:
Krunal Patel 2022-12-01 22:02:22 +05:30
parent e925d72d0b
commit d3d75d8bc8

View File

@ -819,6 +819,14 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
if (isPlaying) { if (isPlaying) {
// Stop [BackgroundMode] service if it is running. // Stop [BackgroundMode] service if it is running.
BackgroundHelper.stopBackgroundPlay(requireContext()) 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) { if (isPlaying && PlayerHelper.sponsorBlockEnabled) {
@ -847,22 +855,11 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
playNextVideo() playNextVideo()
} }
when (playbackState) { if (playbackState == Player.STATE_READY) {
Player.STATE_READY -> { // media actually playing
// media actually playing transitioning = false
transitioning = false // update the PiP params to use the correct aspect ratio
binding.playImageView.setImageResource(R.drawable.ic_pause) if (usePiP()) activity?.setPictureInPictureParams(getPipParams())
// 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)
}
} }
// save the watch position when paused // save the watch position when paused