[Android] Fix the audio repeat state on Android TV

Nicolas Pomepuy git at videolan.org
Tue May 18 04:15:24 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon May 17 09:45:49 2021 +0200| [9a920cfc06e21d683716ed78cad99eca4104fcb3] | committer: Nicolas Pomepuy

Fix the audio repeat state on Android TV

Fixes #1848

> https://code.videolan.org/videolan/vlc-android/commit/9a920cfc06e21d683716ed78cad99eca4104fcb3
---

 .../television/ui/audioplayer/AudioPlayerActivity.kt   | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/application/television/src/main/java/org/videolan/television/ui/audioplayer/AudioPlayerActivity.kt b/application/television/src/main/java/org/videolan/television/ui/audioplayer/AudioPlayerActivity.kt
index aac12c8e0..b876f8827 100644
--- a/application/television/src/main/java/org/videolan/television/ui/audioplayer/AudioPlayerActivity.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/audioplayer/AudioPlayerActivity.kt
@@ -91,6 +91,7 @@ class AudioPlayerActivity : BaseTvActivity() {
                 adapter.setSelection(-1)
                 adapter.update(mediaWrappers)
             }
+            updateRepeatMode()
         })
         model.speed.observe(this, { showChips() })
         PlayerOptionsDelegate.playerSleepTime.observe(this, {
@@ -277,7 +278,7 @@ class AudioPlayerActivity : BaseTvActivity() {
             R.id.button_play -> togglePlayPause()
             R.id.button_next -> goNext()
             R.id.button_previous -> goPrevious()
-            R.id.button_repeat -> updateRepeatMode()
+            R.id.button_repeat -> switchRepeatMode()
             R.id.button_shuffle -> setShuffleMode(!shuffling)
             R.id.button_more -> showAdvancedOptions(v)
         }
@@ -302,6 +303,21 @@ class AudioPlayerActivity : BaseTvActivity() {
     }
 
     private fun updateRepeatMode() {
+        when (model.repeatType) {
+            PlaybackStateCompat.REPEAT_MODE_ALL -> {
+                binding.buttonRepeat.setImageResource(R.drawable.ic_repeat_all)
+            }
+            PlaybackStateCompat.REPEAT_MODE_ONE -> {
+                binding.buttonRepeat.setImageResource(R.drawable.ic_repeat_one)
+            }
+            PlaybackStateCompat.REPEAT_MODE_NONE -> {
+                model.repeatType = PlaybackStateCompat.REPEAT_MODE_NONE
+                binding.buttonRepeat.setImageResource(R.drawable.ic_repeat)
+            }
+        }
+    }
+
+    private fun switchRepeatMode() {
         when (model.repeatType) {
             PlaybackStateCompat.REPEAT_MODE_NONE -> {
                 model.repeatType = PlaybackStateCompat.REPEAT_MODE_ALL



More information about the Android mailing list