Skip to content
Snippets Groups Projects
Commit 4005c13c authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Fix the audio player total progress being empty

And improve readability by using the non textual length
Fixes #2045
parent c5394688
No related branches found
No related tags found
1 merge request!994Various UI fixes
......@@ -362,15 +362,12 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
lifecycleScope.launchWhenStarted {
val text = withContext(Dispatchers.Default) {
val medias = playlistModel.medias ?: return@withContext ""
if (medias.size < 2) {
withContext(Dispatchers.Main) { if (!shouldHidePlayProgress()) binding.audioPlayProgress.setVisible() }
return@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@withContext ""
val elapsedTracksTime = playlistModel.previousTotalTime ?: return@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)
......
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment