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

Fix audio global progress flickering and Locale format

Fixes #2050
parent 331c979f
No related branches found
No related tags found
1 merge request!1006Various UI fixes
Pipeline #106811 passed with stage
in 2 minutes and 42 seconds
......@@ -77,7 +77,10 @@ import org.videolan.vlc.util.share
import org.videolan.vlc.viewmodels.BookmarkModel
import org.videolan.vlc.viewmodels.PlaybackProgress
import org.videolan.vlc.viewmodels.PlaylistModel
import java.text.DateFormat.SHORT
import java.text.DateFormat.getTimeInstance
import java.util.*
import kotlin.math.absoluteValue
private const val TAG = "VLC/AudioPlayer"
private const val SEARCH_TIMEOUT_MILLIS = 10000L
......@@ -106,6 +109,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
private lateinit var abRepeatAddMarker: Button
private var audioPlayProgressMode:Boolean = false
private var lastEndsAt = -1L
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
......@@ -377,21 +381,22 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
val currentProgressText = if (progressTimeText.isNullOrEmpty()) "0:00" else progressTimeText
val textTrack = getString(R.string.track_index, "${playlistModel.currentMediaPosition + 1} / ${medias.size}")
val textProgress = if (audioPlayProgressMode)
val textProgress = if (audioPlayProgressMode) {
val endsAt = System.currentTimeMillis() + totalTime - progressTime
if ((lastEndsAt - endsAt).absoluteValue > 1) lastEndsAt = endsAt
getString(
R.string.audio_queue_progress_finished,
DateFormat.format("hh:mm:ss a", Date(System.currentTimeMillis() + totalTime - progressTime))
getTimeInstance(java.text.DateFormat.MEDIUM).format(lastEndsAt)
)
else
if (showRemainingTime && totalTime > 0) getString(
R.string.audio_queue_progress_remaining,
"$currentProgressText"
} else if (showRemainingTime && totalTime > 0) getString(
R.string.audio_queue_progress_remaining,
"$currentProgressText"
)
else getString(
R.string.audio_queue_progress,
if (totalTimeText.isNullOrEmpty()) "$currentProgressText" else "$currentProgressText / $totalTimeText"
)
else
getString(
R.string.audio_queue_progress,
if (totalTimeText.isNullOrEmpty()) "$currentProgressText" else "$currentProgressText / $totalTimeText"
)
"$textTrack • $textProgress"
}
binding.audioPlayProgress.text = text
......
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