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) {
// 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,23 +855,12 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
playNextVideo()
}
when (playbackState) {
Player.STATE_READY -> {
if (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)
}
}
// save the watch position when paused
if (playbackState == PlaybackState.STATE_PAUSED) {