mirror of
				https://github.com/SuperBFG7/ympd
				synced 2025-10-31 13:53:00 +00:00 
			
		
		
		
	Count complete queue in header and display days
This commit is contained in:
		| @@ -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,7 +630,8 @@ 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\":[ "); | ||||||
| @@ -642,13 +643,16 @@ 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); | ||||||
|  |             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_raw_str(cur, end - cur, "{\"id\":"); | ||||||
|                 cur += json_emit_int(cur, end - cur, mpd_song_get_id(song)); |                 cur += json_emit_int(cur, end - cur, mpd_song_get_id(song)); | ||||||
|                 cur += json_emit_raw_str(cur, end - cur, ",\"pos\":"); |                 cur += json_emit_raw_str(cur, end - cur, ",\"pos\":"); | ||||||
|                 cur += json_emit_int(cur, end - cur, mpd_song_get_pos(song)); |                 cur += json_emit_int(cur, end - cur, mpd_song_get_pos(song)); | ||||||
|                 cur += json_emit_raw_str(cur, end - cur, ",\"duration\":"); |                 cur += json_emit_raw_str(cur, end - cur, ",\"duration\":"); | ||||||
|             cur += json_emit_int(cur, end - cur, drtn); |                 cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song)); | ||||||
|                 cur += json_emit_raw_str(cur, end - cur, ",\"artist\":"); |                 cur += json_emit_raw_str(cur, end - cur, ",\"artist\":"); | ||||||
|                 cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song)); |                 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_raw_str(cur, end - cur, ",\"album_artist\":"); | ||||||
| @@ -662,9 +666,8 @@ int mpd_put_queue(char *buffer, unsigned int offset) | |||||||
|                 cur += json_emit_raw_str(cur, end - cur, ",\"album\":"); |                 cur += json_emit_raw_str(cur, end - cur, ",\"album\":"); | ||||||
|                 cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song)); |                 cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song)); | ||||||
|                 cur += json_emit_raw_str(cur, end - cur, "},"); |                 cur += json_emit_raw_str(cur, end - cur, "},"); | ||||||
|  |             } | ||||||
|  |  | ||||||
|             totalTime += drtn; |  | ||||||
|             totalSongs ++; |  | ||||||
|         } |         } | ||||||
|         mpd_entity_free(entity); |         mpd_entity_free(entity); | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 jcorporation
					jcorporation