diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js index f38079c..77572ac 100644 --- a/htdocs/js/mpd.js +++ b/htdocs/js/mpd.js @@ -436,7 +436,7 @@ function webSocketConnect() { var row=''; switch(obj.data[item].type) { case 'directory': - row='' + + row ='' + 'folder_open' + '' + basename(obj.data[item].dir) + '' + ''; @@ -444,7 +444,7 @@ function webSocketConnect() { case 'song': var minutes = Math.floor(obj.data[item].duration / 60); var seconds = obj.data[item].duration - minutes * 60; - row='' + + row ='' + 'music_note' + '' + obj.data[item].title + '' + '' + obj.data[item].artist + '' + @@ -452,6 +452,12 @@ function webSocketConnect() { '' + minutes + ':' + (seconds < 10 ? '0' : '') + seconds + ''; break; + case 'playlist': + row ='' + + 'list' + + '' + basename(obj.data[item].plist) + '' + + ''; + break; } if (nrItems <= tr.length) { $(tr[nrItems-1]).replaceWith(row); } else { $('#'+current_app+'List > tbody').append(row); } @@ -510,6 +516,10 @@ function webSocketConnect() { socket.send("MPD_API_ADD_TRACK," + decodeURI($(this).attr("uri"))); showNotification('"' + $('td:nth-last-child(3)', this).text() + '" added','','','success'); break; + case 'plist': + socket.send("MPD_API_ADD_PLAYLIST," + decodeURI($(this).attr("uri"))); + showNotification('"' + $('td:nth-last-child(3)', this).text() + '" added','','','success'); + break; } } }); diff --git a/src/mpd_client.c b/src/mpd_client.c index 0a9548c..bc2a730 100644 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@ -798,6 +798,7 @@ int mpd_put_browse(char *buffer, char *path, unsigned int offset) char *cur = buffer; const char *end = buffer + MAX_SIZE; struct mpd_entity *entity; + const struct mpd_playlist *pl; unsigned int entity_count = 0; unsigned int entities_returned = 0; @@ -838,8 +839,12 @@ int mpd_put_browse(char *buffer, char *path, unsigned int offset) cur += json_emit_quoted_str(cur, end - cur, mpd_directory_get_path(dir)); cur += json_emit_raw_str(cur, end - cur, "},"); break; - + case MPD_ENTITY_TYPE_PLAYLIST: + pl = mpd_entity_get_playlist(entity); + cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"playlist\",\"plist\":"); + cur += json_emit_quoted_str(cur, end - cur, mpd_playlist_get_path(pl)); + cur += json_emit_raw_str(cur, end - cur, "},"); break; } }