Code

command.c: put curly braces around a single large statement
[ncmpc.git] / src / screen_song.c
index 2c451c1599c38d2043fafa9ee97d3289c8daf24c..9154f9ab1379ffe9b4a48b7dc6319e1a0511c655 100644 (file)
@@ -269,7 +269,34 @@ screen_song_add_song(const struct mpd_song *song, const struct mpdclient *c)
                char length[16];
                format_duration_short(length, sizeof(length),
                                      mpd_song_get_duration(song));
-               screen_song_append(_(tag_labels[LABEL_LENGTH]), length,
+
+               const char *value = length;
+
+#if LIBMPDCLIENT_CHECK_VERSION(2,3,0)
+               char buffer[64];
+
+               if (mpd_song_get_end(song) > 0) {
+                       char start[16], end[16];
+                       format_duration_short(start, sizeof(start),
+                                             mpd_song_get_start(song));
+                       format_duration_short(end, sizeof(end),
+                                             mpd_song_get_end(song));
+
+                       snprintf(buffer, sizeof(buffer), "%s [%s-%s]\n",
+                                length, start, end);
+                       value = buffer;
+               } else if (mpd_song_get_start(song) > 0) {
+                       char start[16];
+                       format_duration_short(start, sizeof(start),
+                                             mpd_song_get_start(song));
+
+                       snprintf(buffer, sizeof(buffer), "%s [%s-]\n",
+                                length, start);
+                       value = buffer;
+               }
+#endif
+
+               screen_song_append(_(tag_labels[LABEL_LENGTH]), value,
                                   max_tag_label_width);
        }
 
@@ -284,7 +311,8 @@ screen_song_add_song(const struct mpd_song *song, const struct mpdclient *c)
        screen_song_append(_("Path"), mpd_song_get_uri(song),
                           max_tag_label_width);
        if (mpdclient_is_playing(c) && c->song != NULL &&
-           strcmp(mpd_song_get_uri(c->song), mpd_song_get_uri(song)) == 0) {
+           strcmp(mpd_song_get_uri(c->song), mpd_song_get_uri(song)) == 0 &&
+           mpd_status_get_kbit_rate(c->status)) {
                char buf[16];
                g_snprintf(buf, sizeof(buf), _("%d kbps"),
                           mpd_status_get_kbit_rate(c->status));