# |
- Title |
+ Track |
Duration |
|
@@ -191,10 +191,10 @@
@@ -242,7 +242,7 @@
-
diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js
index 5c8a8d1..99fc70f 100644
--- a/htdocs/js/mpd.js
+++ b/htdocs/js/mpd.js
@@ -227,7 +227,7 @@ function webSocketConnect() {
var obj = JSON.parse(msg.data);
switch (obj.type) {
- case "queue":
+ case 'queue':
if(current_app !== 'queue')
break;
@@ -238,8 +238,9 @@ function webSocketConnect() {
$('#salamisandwich > tbody').append(
"" + (obj.data[song].pos + 1) + " | " +
- ""+ obj.data[song].title +" | " +
- ""+ minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
+ " | " + obj.data[song].artist + " " + obj.data[song].album + " | " +
+ "" + obj.data[song].title + " | " +
+ "" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
" | |
");
}
@@ -299,14 +300,14 @@ function webSocketConnect() {
};
//Make queue table sortable
- $("#salamisandwich > tbody").sortable({
+ $('#salamisandwich > tbody').sortable({
helper: fixHelperModified,
stop: function(event,ui) {renumber_table('#salamisandwich',ui.item)}
}).disableSelection();
break;
- case "search":
+ case 'search':
$('#wait').modal('hide');
- case "browse":
+ case 'browse':
if(current_app !== 'browse' && current_app !== 'search')
break;
@@ -319,7 +320,7 @@ function webSocketConnect() {
}
for (var item in obj.data) {
switch(obj.data[item].type) {
- case "directory":
+ case 'directory':
var clazz = 'dir';
if (filter !== undefined) {
var first = obj.data[item].dir[0];
@@ -334,11 +335,11 @@ function webSocketConnect() {
$('#salamisandwich > tbody').append(
"" +
" | " +
- "" + basename(obj.data[item].dir) + " | " +
+ "" + basename(obj.data[item].dir) + " | " +
" | |
"
);
break;
- case "playlist":
+ case 'playlist':
var clazz = 'plist';
if (filter !== "||") {
clazz += ' hide';
@@ -346,29 +347,34 @@ function webSocketConnect() {
$('#salamisandwich > tbody').append(
"" +
" | " +
- "" + basename(obj.data[item].plist) + " | " +
+ "" + basename(obj.data[item].plist) + " | " +
" | |
"
);
break;
- case "song":
+ case 'song':
var minutes = Math.floor(obj.data[item].duration / 60);
var seconds = obj.data[item].duration - minutes * 60;
- $('#salamisandwich > tbody').append(
+ if (typeof obj.data[item].artist === 'undefined') {
+ var details = "" + obj.data[item].title + " | ";
+ } else {
+ var details = "" + obj.data[item].artist + " " + obj.data[item].album + " | " + obj.data[item].title + " | ";
+ }
+
+ $('#salamisandwich > tbody').append(
"" +
- " | " +
- "" + obj.data[item].title +" | " +
- ""+ minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
+ " | | " + details +
+ "" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
" | |
"
);
break;
- case "wrap":
+ case 'wrap':
if(current_app == 'browse') {
$('#next').removeClass('hide');
} else {
$('#salamisandwich > tbody').append(
- " | " +
- "Too many results, please refine your search! | " +
+ "
| " +
+ "Too many results, please refine your search! | " +
" | |
"
);
}
@@ -389,7 +395,7 @@ function webSocketConnect() {
socket.send(onClickAction + "," + decodeURI($(this).parents("tr").attr("uri")));
$('.top-right').notify({
message:{
- text: $('td:nth-child(2)', $(this).parents("tr")).text() + " added"
+ text: "\"" + $('td:nth-last-child(3)', $(this).parents("tr")).text() + "\" added"
} }).show();
}).fadeTo('fast',1);
}
@@ -423,7 +429,7 @@ function webSocketConnect() {
socket.send("MPD_API_ADD_TRACK," + decodeURI($(this).attr("uri")));
$('.top-right').notify({
message:{
- text: $('td:nth-child(2)', this).text() + " added"
+ text: "\"" + $('td:nth-last-child(3)', this).text() + "\" added"
}
}).show();
break;
@@ -431,7 +437,7 @@ function webSocketConnect() {
socket.send("MPD_API_ADD_PLAYLIST," + decodeURI($(this).attr("uri")));
$('.top-right').notify({
message:{
- text: "Playlist " + $('td:nth-child(2)', this).text() + " added"
+ text: "\"" + $('td:nth-last-child(3)', this).text() + "\" added"
}
}).show();
break;
diff --git a/src/mpd_client.c b/src/mpd_client.c
index 2911e46..1054ede 100644
--- a/src/mpd_client.c
+++ b/src/mpd_client.c
@@ -475,6 +475,30 @@ char* mpd_get_title(struct mpd_song const *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) {
+ return "";
+ } else {
+ 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) {
+ return "";
+ } else {
+ return str;
+ }
+}
+
int mpd_put_state(char *buffer, int *current_song_id, unsigned *queue_version)
{
struct mpd_status *status;
@@ -559,18 +583,10 @@ int mpd_put_current_song(char *buffer)
cur += json_emit_int(cur, end - cur, mpd_song_get_pos(song));
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_title(song));
-
- if(mpd_song_get_tag(song, MPD_TAG_ARTIST, 0) != NULL)
- {
- cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
- cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_tag(song, MPD_TAG_ARTIST, 0));
- }
-
- if(mpd_song_get_tag(song, MPD_TAG_ALBUM, 0) != NULL)
- {
- cur += json_emit_raw_str(cur, end - cur, ",\"album\":");
- cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_tag(song, MPD_TAG_ALBUM, 0));
- }
+ 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, "}}");
mpd_song_free(song);
@@ -604,6 +620,10 @@ int mpd_put_queue(char *buffer, unsigned int offset)
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(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, ",\"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, "},");
}
mpd_entity_free(entity);
@@ -718,6 +738,10 @@ int mpd_search(char *buffer, char *searchstr)
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(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, ",\"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, "},");
mpd_song_free(song);