From 838237d854fa614d60cf7ee227ecfdcd0e299614 Mon Sep 17 00:00:00 2001 From: LaClaro Date: Tue, 11 Nov 2014 18:41:39 +0100 Subject: [PATCH] Patched files to include more columns in browsing and queue mode --- htdocs/js/mpd.js | 15 +++++++++++---- src/mpd_client.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js index b6db9af..08e08a9 100644 --- a/htdocs/js/mpd.js +++ b/htdocs/js/mpd.js @@ -137,6 +137,7 @@ function webSocketConnect() { return; var obj = JSON.parse(msg.data); + switch (obj.type) { case "queue": @@ -150,7 +151,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 + ""); } @@ -192,6 +195,7 @@ function webSocketConnect() { "" + "" + "" + basename(obj.data[item].dir) + "" + + "" + "" ); break; @@ -199,7 +203,8 @@ function webSocketConnect() { $('#salamisandwich > tbody').append( "" + "" + - "" + basename(obj.data[item].plist) + "" + + "" + basename(obj.data[item].plist) + "" + + "" + "" ); break; @@ -210,8 +215,10 @@ 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 ea10178..76b079d 100644 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@ -320,6 +320,30 @@ 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 = basename((char *)mpd_song_get_uri(song)); + } + + 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 = basename((char *)mpd_song_get_uri(song)); + } + + return str; +} + int mpd_put_state(char *buffer, int *current_song_id, unsigned *queue_version) { struct mpd_status *status; @@ -413,6 +437,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, "},"); @@ -469,6 +497,10 @@ int mpd_put_browse(char *buffer, char *path, unsigned int offset) cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_uri(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, "},"); -- 2.20.1