mirror of
https://github.com/SuperBFG7/ympd
synced 2024-12-25 02:20:27 +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;
|
||||
|
||||
if (obj.totalTime > 0) {
|
||||
var hours = Math.floor(obj.totalTime / 3600);
|
||||
var minutes = Math.floor(obj.totalTime / 60) - hours * 60;
|
||||
var seconds = obj.totalTime - hours * 3600 - minutes * 60;
|
||||
var days = Math.floor(obj.totalTime / 86400);
|
||||
var hours = Math.floor(obj.totalTime / 3600) - days * 24;
|
||||
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 – ' +
|
||||
(days > 0 ? days + '\u2009d ' : '') +
|
||||
(hours > 0 ? hours + '\u2009h ' + (minutes < 10 ? '0' : '') : '') +
|
||||
minutes + '\u2009m ' + (seconds < 10 ? '0' : '') + seconds + '\u2009s');
|
||||
} else {
|
||||
|
@ -630,7 +630,8 @@ int mpd_put_queue(char *buffer, unsigned int offset)
|
||||
unsigned long totalTime = 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");
|
||||
|
||||
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"queue\",\"data\":[ ");
|
||||
@ -642,29 +643,31 @@ int mpd_put_queue(char *buffer, unsigned int offset)
|
||||
if(mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG) {
|
||||
song = mpd_entity_get_song(entity);
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user