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,23 +855,12 @@ 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
binding.playImageView.setImageResource(R.drawable.ic_pause)
// update the PiP params to use the correct aspect ratio // update the PiP params to use the correct aspect ratio
if (usePiP()) activity?.setPictureInPictureParams(getPipParams()) 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
if (playbackState == PlaybackState.STATE_PAUSED) { if (playbackState == PlaybackState.STATE_PAUSED) {