diff --git a/htdocs/index.html b/htdocs/index.html index f06f7ed..9b2d66a 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -119,6 +119,8 @@ # Title + Album + Artist Duration diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js index be1a8fa..befb312 100644 --- a/htdocs/js/mpd.js +++ b/htdocs/js/mpd.js @@ -205,6 +205,7 @@ function webSocketConnect() { return; var obj = JSON.parse(msg.data); + switch (obj.type) { case "queue": @@ -218,7 +219,9 @@ function webSocketConnect() { $('#salamisandwich > tbody').append( "" + (obj.data[song].pos + 1) + "" + - ""+ obj.data[song].title +"" + + ""+ obj.data[song].title +"" + + ""+ obj.data[song].album +"" + + ""+ obj.data[song].artist +"" + ""+ minutes + ":" + (seconds < 10 ? '0' : '') + seconds + ""); } @@ -281,16 +284,16 @@ function webSocketConnect() { case "directory": $('#salamisandwich > tbody').append( "" + - "" + - "" + basename(obj.data[item].dir) + "" + + "" + + "" + basename(obj.data[item].dir) + "" + + "" + "" ); break; case "playlist": $('#salamisandwich > tbody').append( "" + - "" + - "" + basename(obj.data[item].plist) + "" + + "" + "" ); break; @@ -300,9 +303,11 @@ function webSocketConnect() { $('#salamisandwich > tbody').append( "" + - "" + - "" + obj.data[item].title +"" + - ""+ minutes + ":" + (seconds < 10 ? '0' : '') + seconds + + "" + + "" + obj.data[item].title + "" + + "" + obj.data[item].album + "" + + "" + obj.data[item].artist + "" + + "" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds + "" ); break; diff --git a/src/mpd_client.c b/src/mpd_client.c index c90436d..f9fd6b6 100644 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@ -424,6 +424,42 @@ char* mpd_get_title(struct mpd_song const *song) return str; } +char* mpd_get_album(struct mpd_song const *song) +{ + char *str; + + str = (char *)mpd_song_get_tag(song, MPD_TAG_ALBUM, 0); + if(str == NULL){ + str = "-"; + } + + return str; +} + +char* mpd_get_artist(struct mpd_song const *song) +{ + char *str; + + str = (char *)mpd_song_get_tag(song, MPD_TAG_ARTIST, 0); + if(str == NULL){ + str = "-"; + } + + return str; +} + +char* mpd_get_year(struct mpd_song const *song) +{ + char *str; + + str = (char *)mpd_song_get_tag(song, MPD_TAG_DATE, 0); + if(str == NULL){ + str = "-"; + } + + return str; +} + int mpd_put_state(char *buffer, int *current_song_id, unsigned *queue_version) { struct mpd_status *status; @@ -551,6 +587,10 @@ int mpd_put_queue(char *buffer, unsigned int offset) cur += json_emit_int(cur, end - cur, mpd_song_get_pos(song)); cur += json_emit_raw_str(cur, end - cur, ",\"duration\":"); cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song)); + cur += json_emit_raw_str(cur, end - cur, ",\"artist\":"); + cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song)); + cur += json_emit_raw_str(cur, end - cur, ",\"album\":"); + cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song)); cur += json_emit_raw_str(cur, end - cur, ",\"title\":"); cur += json_emit_quoted_str(cur, end - cur, mpd_get_title(song)); cur += json_emit_raw_str(cur, end - cur, "},"); @@ -605,6 +645,10 @@ int mpd_put_browse(char *buffer, char *path, unsigned int offset) song = mpd_entity_get_song(entity); cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"song\",\"uri\":"); cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_uri(song)); + cur += json_emit_raw_str(cur, end - cur, ",\"album\":"); + cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song)); + cur += json_emit_raw_str(cur, end - cur, ",\"artist\":"); + cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song)); cur += json_emit_raw_str(cur, end - cur, ",\"duration\":"); cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song)); cur += json_emit_raw_str(cur, end - cur, ",\"title\":"); @@ -663,6 +707,10 @@ int mpd_search(char *buffer, char *searchstr) while((song = mpd_recv_song(mpd.conn)) != NULL) { cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"song\",\"uri\":"); cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_uri(song)); + cur += json_emit_raw_str(cur, end - cur, ",\"album\":"); + cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song)); + cur += json_emit_raw_str(cur, end - cur, ",\"artist\":"); + cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song)); cur += json_emit_raw_str(cur, end - cur, ",\"duration\":"); cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song)); cur += json_emit_raw_str(cur, end - cur, ",\"title\":");