char *cur = buffer;
const char *end = buffer + MAX_SIZE;
struct mpd_entity *entity;
+ unsigned long totalTime = 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");
while((entity = mpd_recv_entity(mpd.conn)) != NULL) {
const struct mpd_song *song;
+ unsigned int drtn;
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, mpd_song_get_duration(song));
+ cur += json_emit_int(cur, end - cur, drtn);
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_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;
}
mpd_entity_free(entity);
}
/* remove last ',' */
cur--;
- cur += json_emit_raw_str(cur, end - cur, "]}");
+ 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, "}");
return cur - buffer;
}