mirror of
https://github.com/SuperBFG7/ympd
synced 2024-09-28 22:20:42 +00:00
Count complete queue in header and display days
This commit is contained in:
parent
c08b353f24
commit
d97646fa86
@ -298,11 +298,13 @@ function webSocketConnect() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (obj.totalTime > 0) {
|
if (obj.totalTime > 0) {
|
||||||
var hours = Math.floor(obj.totalTime / 3600);
|
var days = Math.floor(obj.totalTime / 86400);
|
||||||
var minutes = Math.floor(obj.totalTime / 60) - hours * 60;
|
var hours = Math.floor(obj.totalTime / 3600) - days * 24;
|
||||||
var seconds = obj.totalTime - hours * 3600 - minutes * 60;
|
var minutes = Math.floor(obj.totalTime / 60) - hours * 60 - days * 1440;
|
||||||
|
var seconds = obj.totalTime - days * 86400 - hours * 3600 - minutes * 60;
|
||||||
|
|
||||||
$('#panel-heading-info').text(obj.totalSongs+' Songs – ' +
|
$('#panel-heading-info').text(obj.totalSongs+' Songs – ' +
|
||||||
|
(days > 0 ? days + '\u2009d ' : '') +
|
||||||
(hours > 0 ? hours + '\u2009h ' + (minutes < 10 ? '0' : '') : '') +
|
(hours > 0 ? hours + '\u2009h ' + (minutes < 10 ? '0' : '') : '') +
|
||||||
minutes + '\u2009m ' + (seconds < 10 ? '0' : '') + seconds + '\u2009s');
|
minutes + '\u2009m ' + (seconds < 10 ? '0' : '') + seconds + '\u2009s');
|
||||||
} else {
|
} else {
|
||||||
|
@ -630,9 +630,10 @@ int mpd_put_queue(char *buffer, unsigned int offset)
|
|||||||
unsigned long totalTime = 0;
|
unsigned long totalTime = 0;
|
||||||
unsigned long totalSongs = 0;
|
unsigned long totalSongs = 0;
|
||||||
|
|
||||||
if (!mpd_send_list_queue_range_meta(mpd.conn, offset, offset+MAX_ELEMENTS_PER_PAGE))
|
/*get complete queue for total songs*/
|
||||||
|
if (!mpd_send_list_queue_range_meta(mpd.conn, 0, -1))
|
||||||
RETURN_ERROR_AND_RECOVER("mpd_send_list_queue_meta");
|
RETURN_ERROR_AND_RECOVER("mpd_send_list_queue_meta");
|
||||||
|
|
||||||
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"queue\",\"data\":[ ");
|
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"queue\",\"data\":[ ");
|
||||||
|
|
||||||
while((entity = mpd_recv_entity(mpd.conn)) != NULL) {
|
while((entity = mpd_recv_entity(mpd.conn)) != NULL) {
|
||||||
@ -642,29 +643,31 @@ int mpd_put_queue(char *buffer, unsigned int offset)
|
|||||||
if(mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG) {
|
if(mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG) {
|
||||||
song = mpd_entity_get_song(entity);
|
song = mpd_entity_get_song(entity);
|
||||||
drtn = mpd_song_get_duration(song);
|
drtn = mpd_song_get_duration(song);
|
||||||
|
|
||||||
cur += json_emit_raw_str(cur, end - cur, "{\"id\":");
|
|
||||||
cur += json_emit_int(cur, end - cur, mpd_song_get_id(song));
|
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"pos\":");
|
|
||||||
cur += json_emit_int(cur, end - cur, mpd_song_get_pos(song));
|
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"duration\":");
|
|
||||||
cur += json_emit_int(cur, end - cur, drtn);
|
|
||||||
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_artist\":");
|
|
||||||
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album_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_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, "},");
|
|
||||||
|
|
||||||
totalTime += drtn;
|
totalTime += drtn;
|
||||||
totalSongs ++;
|
totalSongs ++;
|
||||||
|
if(totalSongs > offset && totalSongs <= offset+MAX_ELEMENTS_PER_PAGE) {
|
||||||
|
/*Pagination*/
|
||||||
|
cur += json_emit_raw_str(cur, end - cur, "{\"id\":");
|
||||||
|
cur += json_emit_int(cur, end - cur, mpd_song_get_id(song));
|
||||||
|
cur += json_emit_raw_str(cur, end - cur, ",\"pos\":");
|
||||||
|
cur += json_emit_int(cur, end - cur, mpd_song_get_pos(song));
|
||||||
|
cur += json_emit_raw_str(cur, end - cur, ",\"duration\":");
|
||||||
|
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_artist\":");
|
||||||
|
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album_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_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);
|
mpd_entity_free(entity);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user