From fee282f49c6a998cf37ee4050971c20239f98056 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 21 Jan 2021 13:47:13 +0100 Subject: [PATCH] SongPrint: use LightSong::GetDuration() This properly prints the "Time"/"duration" values for songs in virtual CUE folders. This is loosely related to https://github.com/MusicPlayerDaemon/MPD/issues/1048 --- NEWS | 1 + src/SongPrint.cxx | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index f6172c454..16353791c 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ ver 0.22.4 (not yet released) * protocol - fix "readpicture" on 32 bit machines + - show duration of songs in virtual playlist (CUE) folders * storage - curl: fix several WebDAV protocol bugs * decoder diff --git a/src/SongPrint.cxx b/src/SongPrint.cxx index 7e8729ad0..5ad300081 100644 --- a/src/SongPrint.cxx +++ b/src/SongPrint.cxx @@ -91,7 +91,14 @@ song_print_info(Response &r, const LightSong &song, bool base) noexcept if (song.audio_format.IsDefined()) r.Format("Format: %s\n", ToString(song.audio_format).c_str()); - tag_print(r, song.tag); + tag_print_values(r, song.tag); + + const auto duration = song.GetDuration(); + if (!duration.IsNegative()) + r.Format("Time: %i\n" + "duration: %1.3f\n", + duration.RoundS(), + duration.ToDoubleS()); } void