Permalink
Browse files

status: add nextsong/nextsongid support

  • Loading branch information...
1 parent 8223156 commit e325c0a01c49390caefe9bfddfc3ed86cf581358 @neuschaefer neuschaefer committed Jan 4, 2012
Showing with 43 additions and 0 deletions.
  1. +1 −0 NEWS
  2. +16 −0 include/mpd/status.h
  3. +2 −0 libmpdclient.ld
  4. +24 −0 src/status.c
View
1 NEWS
@@ -1,4 +1,5 @@
libmpdclient 2.7 (2011/??/??)
+* status: add nextsong/nextsongid support
libmpdclient 2.6 (2011/10/23)
View
@@ -225,6 +225,22 @@ int
mpd_status_get_song_id(const struct mpd_status *status);
/**
+ * The same as mpd_status_get_next_song_pos, but for the next song to be
+ * played.
+ */
+mpd_pure
+int
+mpd_status_get_next_song_pos(const struct mpd_status *status);
+
+/**
+ * Returns the id of the next song to be played. If it is not known, -1 is
+ * returned.
+ */
+mpd_pure
+int
+mpd_status_get_next_song_id(const struct mpd_status *status);
+
+/**
* Returns time in seconds that have elapsed in the currently playing/paused
* song
*/
View
@@ -319,6 +319,8 @@ global:
mpd_status_get_mixrampdelay;
mpd_status_get_song_pos;
mpd_status_get_song_id;
+ mpd_status_get_next_song_pos;
+ mpd_status_get_next_song_id;
mpd_status_get_elapsed_time;
mpd_status_get_elapsed_ms;
mpd_status_get_total_time;
View
@@ -87,6 +87,12 @@ struct mpd_status {
/** Song ID of the currently selected song */
int song_id;
+ /** The same as song_pos, but for the next song to be played */
+ int next_song_pos;
+
+ /** Song ID of the next song to be played */
+ int next_song_id;
+
/**
* Time in seconds that have elapsed in the currently
* playing/paused song.
@@ -132,6 +138,8 @@ mpd_status_begin(void)
status->state = MPD_STATE_UNKNOWN;
status->song_pos = -1;
status->song_id = -1;
+ status->next_song_pos = -1;
+ status->next_song_id = -1;
status->elapsed_time = 0;
status->elapsed_ms = 0;
status->total_time = 0;
@@ -226,6 +234,10 @@ mpd_status_feed(struct mpd_status *status, const struct mpd_pair *pair)
status->song_pos = atoi(pair->value);
else if (strcmp(pair->name, "songid") == 0)
status->song_id = atoi(pair->value);
+ else if (strcmp(pair->name, "nextsong") == 0)
+ status->next_song_pos = atoi(pair->value);
+ else if (strcmp(pair->name, "nextsongid") == 0)
+ status->next_song_id = atoi(pair->value);
else if (strcmp(pair->name, "time") == 0) {
char *endptr;
@@ -343,6 +355,18 @@ mpd_status_get_song_id(const struct mpd_status *status)
return status->song_id;
}
+int
+mpd_status_get_next_song_pos(const struct mpd_status *status)
+{
+ return status->next_song_pos;
+}
+
+int
+mpd_status_get_next_song_id(const struct mpd_status *status)
+{
+ return status->next_song_id;
+}
+
unsigned
mpd_status_get_elapsed_time(const struct mpd_status *status)
{

0 comments on commit e325c0a

Please sign in to comment.