1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-12-25 02:20:27 +00:00

Display total songs in queue header

This commit is contained in:
jcorporation 2018-04-30 15:11:53 +01:00
parent 71868bf89d
commit 801159bfe8
2 changed files with 5 additions and 1 deletions

View File

@ -302,7 +302,7 @@ function webSocketConnect() {
var minutes = Math.floor(obj.totalTime / 60) - hours * 60;
var seconds = obj.totalTime - hours * 3600 - minutes * 60;
$('#panel-heading-info').text('Total: ' +
$('#panel-heading-info').text(obj.totalSongs+' Songs ' +
(hours > 0 ? hours + '\u2009h ' + (minutes < 10 ? '0' : '') : '') +
minutes + '\u2009m ' + (seconds < 10 ? '0' : '') + seconds + '\u2009s');
} else {

View File

@ -628,6 +628,7 @@ int mpd_put_queue(char *buffer, unsigned int offset)
const char *end = buffer + MAX_SIZE;
struct mpd_entity *entity;
unsigned long totalTime = 0;
unsigned long totalSongs = 0;
if (!mpd_send_list_queue_range_meta(mpd.conn, offset, offset+MAX_ELEMENTS_PER_PAGE))
RETURN_ERROR_AND_RECOVER("mpd_send_list_queue_meta");
@ -663,6 +664,7 @@ int mpd_put_queue(char *buffer, unsigned int offset)
cur += json_emit_raw_str(cur, end - cur, "},");
totalTime += drtn;
totalSongs ++;
}
mpd_entity_free(entity);
}
@ -672,6 +674,8 @@ int mpd_put_queue(char *buffer, unsigned int offset)
cur += json_emit_raw_str(cur, end - cur, "],\"totalTime\":");
cur += json_emit_int(cur, end - cur, totalTime);
cur += json_emit_raw_str(cur, end - cur, ",\"totalSongs\":");
cur += json_emit_int(cur, end - cur, totalSongs);
cur += json_emit_raw_str(cur, end - cur, "}");
return cur - buffer;
}