Code

conf.c: use g_mkdir for WIN32 compatibility
[ncmpc.git] / src / screen_song.c
index 4ec8aa4952eae103633dab60bfa51c408ff73954..22f52f4b4441233f33da4929006e2d762074a16d 100644 (file)
@@ -1,21 +1,21 @@
 /* ncmpc (Ncurses MPD Client)
- * (c) 2004-2009 The Music Player Daemon Project
+ * (c) 2004-2010 The Music Player Daemon Project
  * Project homepage: http://musicpd.org
-
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
-
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
-
+ *
  * You should have received a copy of the GNU General Public License along
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
+ */
 
 #include "screen_song.h"
 #include "screen_interface.h"
@@ -36,6 +36,7 @@
 
 enum {
        LABEL_LENGTH = MPD_TAG_COUNT,
+       LABEL_PATH,
        LABEL_BITRATE,
 };
 
@@ -51,6 +52,7 @@ static const char *const tag_labels[] = {
        [MPD_TAG_DATE] = N_("Date"),
        [MPD_TAG_GENRE] = N_("Genre"),
        [MPD_TAG_COMMENT] = N_("Comment"),
+       [LABEL_PATH] = N_("Path"),
        [LABEL_BITRATE] = N_("Bitrate"),
 };
 
@@ -269,7 +271,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);
        }
 
@@ -281,10 +310,11 @@ screen_song_add_song(const struct mpd_song *song, const struct mpdclient *c)
        screen_song_append_tag(song, MPD_TAG_GENRE);
        screen_song_append_tag(song, MPD_TAG_COMMENT);
 
-       screen_song_append(_("Path"), mpd_song_get_uri(song),
+       screen_song_append(_(tag_labels[LABEL_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));