1
0
mirror of https://github.com/SuperBFG7/ympd synced 2025-01-14 11:15:49 +00:00

List playlists in browse filesystem view

This commit is contained in:
jcorporation 2018-06-03 06:17:30 +01:00
parent 182924815a
commit 234772155a
2 changed files with 18 additions and 3 deletions

View File

@ -436,7 +436,7 @@ function webSocketConnect() {
var row='';
switch(obj.data[item].type) {
case 'directory':
row='<tr uri="' + encodeURI(obj.data[item].dir) + '" class="dir">' +
row ='<tr uri="' + encodeURI(obj.data[item].dir) + '" class="dir">' +
'<td><span class="material-icons">folder_open</span></td>' +
'<td colspan="3"><a>' + basename(obj.data[item].dir) + '</a></td>' +
'<td></td><td></td></tr>';
@ -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='<tr uri="' + encodeURI(obj.data[item].uri) + '" class="song">' +
row ='<tr uri="' + encodeURI(obj.data[item].uri) + '" class="song">' +
'<td><span class="material-icons">music_note</span></td>' +
'<td>' + obj.data[item].title + '</td>' +
'<td>' + obj.data[item].artist + '</td>' +
@ -452,6 +452,12 @@ function webSocketConnect() {
'<td>' + minutes + ':' + (seconds < 10 ? '0' : '') + seconds +
'</td><td></td></tr>';
break;
case 'playlist':
row ='<tr uri="' + encodeURI(obj.data[item].plist) + '" class="plist">' +
'<td><span class="material-icons">list</span></td>' +
'<td colspan="3"><a>' + basename(obj.data[item].plist) + '</a></td>' +
'<td></td><td></td></tr>';
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;
}
}
});

View File

@ -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;
@ -840,6 +841,10 @@ int mpd_put_browse(char *buffer, char *path, unsigned int offset)
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;
}
}