diff --git a/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt index f5d1b6b7c..18b2c124f 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt @@ -80,6 +80,10 @@ class AudioPlayerFragment : BaseFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + // select the title TV in order for it to automatically scroll + binding.title.isSelected = true + binding.uploader.isSelected = true + binding.prev.setOnClickListener { val currentIndex = PlayingQueue.currentIndex() if (!PlayingQueue.hasPrev()) return@setOnClickListener @@ -175,25 +179,24 @@ class AudioPlayerFragment : BaseFragment() { * Update the position, duration and text views belonging to the seek bar */ private fun updateSeekBar() { - val duration = playerService?.getDuration()?.toFloat() ?: return - - // when the video is not loaded yet, retry in 100 ms - if (duration <= 0) { + val duration = playerService?.getDuration()?.takeIf { it > 0 } ?: let { + // if there's no duration available, clear everything + binding.timeBar.value = 0f + binding.duration.text = "" + binding.currentPosition.text = "" handler.postDelayed(this::updateSeekBar, 100) return } - - // get the current position from the player service val currentPosition = playerService?.getCurrentPosition()?.toFloat() ?: 0f // set the text for the indicators - binding.duration.text = DateUtils.formatElapsedTime((duration / 1000).toLong()) + binding.duration.text = DateUtils.formatElapsedTime(duration / 1000) binding.currentPosition.text = DateUtils.formatElapsedTime( (currentPosition / 1000).toLong() ) // update the time bar current value and maximum value - binding.timeBar.valueTo = duration / 1000 + binding.timeBar.valueTo = (duration / 1000).toFloat() binding.timeBar.value = minOf( currentPosition / 1000, binding.timeBar.valueTo diff --git a/app/src/main/res/layout/fragment_audio_player.xml b/app/src/main/res/layout/fragment_audio_player.xml index 26728e965..40c1b5a1a 100644 --- a/app/src/main/res/layout/fragment_audio_player.xml +++ b/app/src/main/res/layout/fragment_audio_player.xml @@ -39,21 +39,17 @@ diff --git a/app/src/main/res/values/style.xml b/app/src/main/res/values/style.xml index 488986625..043068972 100644 --- a/app/src/main/res/values/style.xml +++ b/app/src/main/res/values/style.xml @@ -239,11 +239,23 @@ + + \ No newline at end of file