diff --git a/src/screen_song.c b/src/screen_song.c
index 2c451c1599c38d2043fafa9ee97d3289c8daf24c..c2b6c3c5f67be21c1a397d996c83f74d70c8271a 100644 (file)
--- a/src/screen_song.c
+++ b/src/screen_song.c
/* ncmpc (Ncurses MPD Client)
* (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"
enum {
LABEL_LENGTH = MPD_TAG_COUNT,
+ LABEL_PATH,
LABEL_BITRATE,
+ LABEL_POSITION,
};
static const char *const tag_labels[] = {
[MPD_TAG_TITLE] = N_("Title"),
[MPD_TAG_ALBUM] = N_("Album"),
[LABEL_LENGTH] = N_("Length"),
+ [LABEL_POSITION] = N_("Position"),
[MPD_TAG_COMPOSER] = N_("Composer"),
[MPD_TAG_NAME] = N_("Name"),
[MPD_TAG_DISC] = N_("Disc"),
[MPD_TAG_DATE] = N_("Date"),
[MPD_TAG_GENRE] = N_("Genre"),
[MPD_TAG_COMMENT] = N_("Comment"),
+ [LABEL_PATH] = N_("Path"),
[LABEL_BITRATE] = N_("Bitrate"),
};
}
static const char *
-screen_song_list_callback(unsigned idx, G_GNUC_UNUSED void *data)
+screen_song_list_callback(unsigned idx, gcc_unused void *data)
{
assert(idx < current.lines->len);
}
static const char *
-screen_song_title(G_GNUC_UNUSED char *str, G_GNUC_UNUSED size_t size)
+screen_song_title(gcc_unused char *str, gcc_unused size_t size)
{
return _("Song viewer");
}
{
assert(song != NULL);
+ char songpos[16];
+ g_snprintf(songpos, sizeof(songpos), "%d", mpd_song_get_pos(song) + 1);
+ screen_song_append(_(tag_labels[LABEL_POSITION]), songpos,
+ max_tag_label_width);
+
screen_song_append_tag(song, MPD_TAG_ARTIST);
screen_song_append_tag(song, MPD_TAG_TITLE);
screen_song_append_tag(song, MPD_TAG_ALBUM);
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);
}
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));