From 88c72a45f785891ad632daed874563708821c9d0 Mon Sep 17 00:00:00 2001 From: GilesMunn Date: Sat, 12 Nov 2022 16:31:44 +0000 Subject: [PATCH] Added restart icon and change miniplayer to it when video is finished. --- .../libretube/ui/fragments/PlayerFragment.kt | 21 ++++++++++++------- app/src/main/res/drawable/ic_restart.xml | 10 +++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/drawable/ic_restart.xml 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 df0195ffe..c157a0913 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 @@ -816,13 +816,20 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { if (binding.player.autoplayEnabled) playNextVideo() } - if (playbackState == Player.STATE_READY) { - // media actually playing - transitioning = false - binding.playImageView.setImageResource(R.drawable.ic_pause) - } else { - // player paused in any state - binding.playImageView.setImageResource(R.drawable.ic_play) + when (playbackState) { + Player.STATE_READY -> { + // media actually playing + transitioning = false + binding.playImageView.setImageResource(R.drawable.ic_pause) + } + 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 diff --git a/app/src/main/res/drawable/ic_restart.xml b/app/src/main/res/drawable/ic_restart.xml new file mode 100644 index 000000000..4acff846b --- /dev/null +++ b/app/src/main/res/drawable/ic_restart.xml @@ -0,0 +1,10 @@ + + +