[Android] Suppress bitrate information if zero

Robert Stone git at videolan.org
Thu Sep 2 06:47:18 UTC 2021


vlc-android | branch: master | Robert Stone <rhstone at gmail.com> | Wed Sep  1 23:22:02 2021 -0700| [a7c5100ee8f91786d70e7e8c5475969fe44da02d] | committer: Robert Stone

Suppress bitrate information if zero

> https://code.videolan.org/videolan/vlc-android/commit/a7c5100ee8f91786d70e7e8c5475969fe44da02d
---

 .../vlc-android/src/org/videolan/vlc/PlaybackService.kt    | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 1be183dc8..ea5ce646d 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -369,11 +369,15 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
         return if (tracks.size == 1) tracks.first().formatTrackInfoString(this) else null
     }
 
-    fun IMedia.AudioTrack.formatTrackInfoString(context: Context) = (context.getString(R.string.track_bitrate_info, bitrate.toLong().readableSize()) +
-            " · " +
-            context.getString(R.string.track_codec_info, codec) +
-            " · " +
-            context.getString(R.string.track_samplerate_info, rate)).replace("\n", "")
+    fun IMedia.AudioTrack.formatTrackInfoString(context: Context) = buildString {
+        if (bitrate > 0) {
+            append(context.getString(R.string.track_bitrate_info, bitrate.toLong().readableSize()))
+            append(" ⋅ ")
+        }
+        append(context.getString(R.string.track_codec_info, codec))
+        append(" ⋅ ")
+        append(context.getString(R.string.track_samplerate_info, rate))
+    }.replace("\n", "")
 
     fun IMedia.getAudioTracks(): List<IMedia.AudioTrack> {
         val tracks = ArrayList<IMedia.AudioTrack>()



More information about the Android mailing list