mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30:31 +05:30
Improve video duration formatting.
This commit is contained in:
parent
231fe0d503
commit
52f9ac5a9c
@ -1100,21 +1100,21 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
/**
|
/**
|
||||||
* Update the displayed duration of the video
|
* Update the displayed duration of the video
|
||||||
*/
|
*/
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
private fun updateDisplayedDuration() {
|
private fun updateDisplayedDuration() {
|
||||||
if (exoPlayer.duration < 0 || streams.livestream || _binding == null) return
|
val duration = exoPlayer.duration / 1000
|
||||||
|
if (duration < 0 || streams.livestream || _binding == null) return
|
||||||
|
|
||||||
playerBinding.duration.text =
|
val durationWithoutSegments = duration - segments.sumOf {
|
||||||
DateUtils.formatElapsedTime(exoPlayer.duration / 1000)
|
val (start, end) = it.segmentStartAndEnd
|
||||||
if (segments.isEmpty()) return
|
end - start
|
||||||
|
}.toLong()
|
||||||
|
val durationString = DateUtils.formatElapsedTime(duration)
|
||||||
|
|
||||||
val durationWithSb = DateUtils.formatElapsedTime(
|
playerBinding.duration.text = if (durationWithoutSegments < duration) {
|
||||||
(exoPlayer.duration / 1000) - segments.sumOf {
|
"$durationString (${DateUtils.formatElapsedTime(durationWithoutSegments)})"
|
||||||
val (start, end) = it.segmentStartAndEnd
|
} else {
|
||||||
end - start
|
durationString
|
||||||
}.toInt()
|
}
|
||||||
)
|
|
||||||
playerBinding.duration.text = playerBinding.duration.text.toString() + " ($durationWithSb)"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun syncQueueButtons() {
|
private fun syncQueueButtons() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user