1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-11-26 14:57:17 +00:00

add artist and title columns (by laclaro)

This commit is contained in:
SuperBFG7 2015-10-16 18:51:25 +02:00
commit ff92b2718f
3 changed files with 63 additions and 8 deletions

View File

@ -119,6 +119,8 @@
<tr> <tr>
<th>#</th> <th>#</th>
<th>Title</th> <th>Title</th>
<th>Album</th>
<th>Artist</th>
<th>Duration</th> <th>Duration</th>
<th></th> <th></th>
</tr> </tr>

View File

@ -206,6 +206,7 @@ function webSocketConnect() {
var obj = JSON.parse(msg.data); var obj = JSON.parse(msg.data);
switch (obj.type) { switch (obj.type) {
case "queue": case "queue":
if(current_app !== 'queue') if(current_app !== 'queue')
@ -219,6 +220,8 @@ function webSocketConnect() {
$('#salamisandwich > tbody').append( $('#salamisandwich > tbody').append(
"<tr trackid=\"" + obj.data[song].id + "\"><td>" + (obj.data[song].pos + 1) + "</td>" + "<tr trackid=\"" + obj.data[song].id + "\"><td>" + (obj.data[song].pos + 1) + "</td>" +
"<td>"+ obj.data[song].title +"</td>" + "<td>"+ obj.data[song].title +"</td>" +
"<td>"+ obj.data[song].album +"</td>" +
"<td>"+ obj.data[song].artist +"</td>" +
"<td>"+ minutes + ":" + (seconds < 10 ? '0' : '') + seconds + "<td>"+ minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
"</td><td></td></tr>"); "</td><td></td></tr>");
} }
@ -283,14 +286,14 @@ function webSocketConnect() {
"<tr uri=\"" + encodeURI(obj.data[item].dir) + "\" class=\"dir\">" + "<tr uri=\"" + encodeURI(obj.data[item].dir) + "\" class=\"dir\">" +
"<td><span class=\"glyphicon glyphicon-folder-open\"></span></td>" + "<td><span class=\"glyphicon glyphicon-folder-open\"></span></td>" +
"<td><a>" + basename(obj.data[item].dir) + "</a></td>" + "<td><a>" + basename(obj.data[item].dir) + "</a></td>" +
"<td></td><td></td>" +
"<td></td><td></td></tr>" "<td></td><td></td></tr>"
); );
break; break;
case "playlist": case "playlist":
$('#salamisandwich > tbody').append( $('#salamisandwich > tbody').append(
"<tr uri=\"" + encodeURI(obj.data[item].plist) + "\" class=\"plist\">" + "<tr uri=\"" + encodeURI(obj.data[item].plist) + "\" class=\"plist\">" +
"<td><span class=\"glyphicon glyphicon-list\"></span></td>" + "<td></td><td></td>" +
"<td><a>" + basename(obj.data[item].plist) + "</a></td>" +
"<td></td><td></td></tr>" "<td></td><td></td></tr>"
); );
break; break;
@ -302,6 +305,8 @@ function webSocketConnect() {
"<tr uri=\"" + encodeURI(obj.data[item].uri) + "\" class=\"song\">" + "<tr uri=\"" + encodeURI(obj.data[item].uri) + "\" class=\"song\">" +
"<td><span class=\"glyphicon glyphicon-music\"></span></td>" + "<td><span class=\"glyphicon glyphicon-music\"></span></td>" +
"<td>" + obj.data[item].title + "</td>" + "<td>" + obj.data[item].title + "</td>" +
"<td>" + obj.data[item].album + "</td>" +
"<td>" + obj.data[item].artist + "</td>" +
"<td>" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds + "<td>" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
"</td><td></td></tr>" "</td><td></td></tr>"
); );

View File

@ -424,6 +424,42 @@ char* mpd_get_title(struct mpd_song const *song)
return str; 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) int mpd_put_state(char *buffer, int *current_song_id, unsigned *queue_version)
{ {
struct mpd_status *status; 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_int(cur, end - cur, mpd_song_get_pos(song));
cur += json_emit_raw_str(cur, end - cur, ",\"duration\":"); cur += json_emit_raw_str(cur, end - cur, ",\"duration\":");
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song)); 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_raw_str(cur, end - cur, ",\"title\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_title(song)); cur += json_emit_quoted_str(cur, end - cur, mpd_get_title(song));
cur += json_emit_raw_str(cur, end - cur, "},"); 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); song = mpd_entity_get_song(entity);
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"song\",\"uri\":"); 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_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_raw_str(cur, end - cur, ",\"duration\":");
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song)); cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song));
cur += json_emit_raw_str(cur, end - cur, ",\"title\":"); 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) { while((song = mpd_recv_song(mpd.conn)) != NULL) {
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"song\",\"uri\":"); 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_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_raw_str(cur, end - cur, ",\"duration\":");
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song)); cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song));
cur += json_emit_raw_str(cur, end - cur, ",\"title\":"); cur += json_emit_raw_str(cur, end - cur, ",\"title\":");