[Android] Fix the audio player total progress being empty

Nicolas Pomepuy git at videolan.org
Tue Jun 1 12:17:27 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Jun  1 06:20:48 2021 +0200| [4005c13c449cc4c7303a05acbe9001059b72e5d2] | committer: Nicolas Pomepuy

Fix the audio player total progress being empty

And improve readability by using the non textual length
Fixes #2045

> https://code.videolan.org/videolan/vlc-android/commit/4005c13c449cc4c7303a05acbe9001059b72e5d2
---

 .../vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt    | 9 +++------
 .../vlc-android/src/org/videolan/vlc/viewmodels/PlaylistModel.kt | 2 +-
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
index 1969e53d3..12e1fa86f 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
@@ -362,15 +362,12 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
         lifecycleScope.launchWhenStarted {
             val text = withContext(Dispatchers.Default) {
                 val medias = playlistModel.medias ?: return at withContext ""
-                if (medias.size < 2) {
-                    withContext(Dispatchers.Main) { if (!shouldHidePlayProgress()) binding.audioPlayProgress.setVisible() }
-                    return at withContext ""
-                } else withContext(Dispatchers.Main) { if (!shouldHidePlayProgress()) binding.audioPlayProgress.setVisible()  }
+                withContext(Dispatchers.Main) { if (!shouldHidePlayProgress()) binding.audioPlayProgress.setVisible() else  binding.audioPlayProgress.setGone() }
                 if (playlistModel.currentMediaPosition == -1) return at withContext ""
                 val elapsedTracksTime = playlistModel.previousTotalTime ?: return at withContext ""
                 val totalTime = elapsedTracksTime + progress.time
-                val totalTimeText = Tools.millisToString(totalTime, true, true, false)
-                val currentProgressText = if (totalTimeText.isNullOrEmpty()) "0s" else totalTimeText
+                val totalTimeText = Tools.millisToString(totalTime, false, true, false)
+                val currentProgressText = if (totalTimeText.isNullOrEmpty()) "0:00" else totalTimeText
 
                 val textTrack = getString(R.string.track_index, "${playlistModel.currentMediaPosition + 1} / ${medias.size}")
                 val textProgress = if (audioPlayProgressMode)
diff --git a/application/vlc-android/src/org/videolan/vlc/viewmodels/PlaylistModel.kt b/application/vlc-android/src/org/videolan/vlc/viewmodels/PlaylistModel.kt
index fc8d021cc..35127c6ef 100644
--- a/application/vlc-android/src/org/videolan/vlc/viewmodels/PlaylistModel.kt
+++ b/application/vlc-android/src/org/videolan/vlc/viewmodels/PlaylistModel.kt
@@ -245,7 +245,7 @@ class PlaylistModel : ViewModel(), PlaybackService.Callback by EmptyPBSCallback
                     .map { it.length }
                     .sum()
         }
-        totalTime = Tools.millisToString(totalLength, true, false, false)
+        totalTime = Tools.millisToString(totalLength, false, false, false)
     }
 
     fun getTotalTime():Long {



More information about the Android mailing list