[Android] Audio player global progress improvements
Nicolas Pomepuy
git at videolan.org
Tue Jun 8 12:43:26 UTC 2021
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Jun 4 06:25:45 2021 +0200| [adcd7619304010b32e5a14335dda32be41254af6] | committer: Nicolas Pomepuy
Audio player global progress improvements
New mode: remaining time when the user use the remaining time mode for tracks
The "Ends at" mode now displays seconds
Fixes #2050
> https://code.videolan.org/videolan/vlc-android/commit/adcd7619304010b32e5a14335dda32be41254af6
---
application/resources/src/main/res/values/strings.xml | 1 +
.../src/org/videolan/vlc/gui/audio/AudioPlayer.kt | 14 ++++++++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 70808b3f1..3a5a26472 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -727,6 +727,7 @@
<string name="subtitle_delay_end">Text seen</string>
<string name="track_index">Track: %s</string>
<string name="audio_queue_progress">Progress: %s</string>
+ <string name="audio_queue_progress_remaining">Remaining: %s</string>
<string name="audio_queue_progress_finished">Ends at: %s</string>
<string name="sortby_track">Track</string>
<string name="this_folder">Add this folder</string>
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 12e1fa86f..c0a4c80e9 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
@@ -30,6 +30,8 @@ import android.support.v4.media.session.PlaybackStateCompat
import android.text.Editable
import android.text.TextWatcher
import android.text.format.DateFormat
+import android.text.format.DateUtils
+import android.util.Log
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
@@ -366,15 +368,19 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
if (playlistModel.currentMediaPosition == -1) return at withContext ""
val elapsedTracksTime = playlistModel.previousTotalTime ?: return at withContext ""
val totalTime = elapsedTracksTime + progress.time
- val totalTimeText = Tools.millisToString(totalTime, false, true, false)
+ val totalTimeText = Tools.millisToString(if (showRemainingTime && playlistModel.getTotalTime()>0) playlistModel.getTotalTime() - totalTime else 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)
- getString(R.string.audio_queue_progress_finished,DateFormat.getTimeFormat(requireContext()).format(Date(System.currentTimeMillis() + playlistModel.getTotalTime() - totalTime)))
+ getString(R.string.audio_queue_progress_finished,DateFormat.format("hh:mm:ss a", Date(System.currentTimeMillis() + playlistModel.getTotalTime() - totalTime)))
+ else
+ if (showRemainingTime && playlistModel.getTotalTime() > 0) getString(R.string.audio_queue_progress_remaining, "$currentProgressText")
else
- getString(R.string.audio_queue_progress,
- if (playlistModel.totalTime.isNullOrEmpty()) "$currentProgressText" else "$currentProgressText / ${playlistModel.totalTime}")
+ getString(
+ R.string.audio_queue_progress,
+ if (playlistModel.totalTime.isNullOrEmpty()) "$currentProgressText" else "$currentProgressText / ${playlistModel.totalTime}"
+ )
"$textTrack • $textProgress"
}
binding.audioPlayProgress.text = text
More information about the Android
mailing list