fixed play animation

This commit is contained in:
LagradOst 2022-01-08 16:45:53 +01:00
parent b5a38b39be
commit d81cbee7f4

View file

@ -18,6 +18,7 @@ import androidx.annotation.LayoutRes
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
import com.google.android.exoplayer2.ExoPlayer import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.PlaybackException import com.google.android.exoplayer2.PlaybackException
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout import com.google.android.exoplayer2.ui.AspectRatioFrameLayout
@ -96,13 +97,27 @@ abstract class AbstractPlayerFragment(
player_pause_play?.setImageResource(if (isPlayingRightNow) R.drawable.play_to_pause else R.drawable.pause_to_play) player_pause_play?.setImageResource(if (isPlayingRightNow) R.drawable.play_to_pause else R.drawable.pause_to_play)
val drawable = player_pause_play?.drawable val drawable = player_pause_play?.drawable
var startedAnimation = false
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
if (drawable is AnimatedImageDrawable) { if (drawable is AnimatedImageDrawable) {
drawable.start() drawable.start()
startedAnimation = true
} }
} }
if (drawable is AnimatedVectorDrawable) { if (drawable is AnimatedVectorDrawable) {
drawable.start() drawable.start()
startedAnimation = true
}
if (drawable is AnimatedVectorDrawableCompat) {
drawable.start()
startedAnimation = true
}
// somehow the phone is wacked
if(!startedAnimation) {
player_pause_play?.setImageResource(if (isPlayingRightNow) R.drawable.netflix_pause else R.drawable.netflix_play)
} }
} else { } else {
player_pause_play?.setImageResource(if (isPlayingRightNow) R.drawable.netflix_pause else R.drawable.netflix_play) player_pause_play?.setImageResource(if (isPlayingRightNow) R.drawable.netflix_pause else R.drawable.netflix_play)
@ -110,7 +125,7 @@ abstract class AbstractPlayerFragment(
} }
canEnterPipMode = isPlayingRightNow canEnterPipMode = isPlayingRightNow
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && isInPIPMode) {
activity?.let { act -> activity?.let { act ->
PlayerPipHelper.updatePIPModeActions(act, isPlayingRightNow) PlayerPipHelper.updatePIPModeActions(act, isPlayingRightNow)
} }