mirror of
				https://github.com/SuperBFG7/ympd
				synced 2025-10-31 13:53:00 +00:00 
			
		
		
		
	Display total songs in queue header
This commit is contained in:
		| @@ -302,7 +302,7 @@ function webSocketConnect() { | |||||||
|                         var minutes = Math.floor(obj.totalTime / 60) - hours * 60; |                         var minutes = Math.floor(obj.totalTime / 60) - hours * 60; | ||||||
|                         var seconds = obj.totalTime - hours * 3600 - minutes * 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' : '') : '') + |                             (hours > 0 ? hours + '\u2009h ' + (minutes < 10 ? '0' : '') : '') + | ||||||
|                             minutes + '\u2009m ' + (seconds < 10 ? '0' : '') + seconds + '\u2009s'); |                             minutes + '\u2009m ' + (seconds < 10 ? '0' : '') + seconds + '\u2009s'); | ||||||
|                     } else { |                     } else { | ||||||
|   | |||||||
| @@ -628,6 +628,7 @@ int mpd_put_queue(char *buffer, unsigned int offset) | |||||||
|     const char *end = buffer + MAX_SIZE; |     const char *end = buffer + MAX_SIZE; | ||||||
|     struct mpd_entity *entity; |     struct mpd_entity *entity; | ||||||
|     unsigned long totalTime = 0; |     unsigned long totalTime = 0; | ||||||
|  |     unsigned long totalSongs = 0; | ||||||
|  |  | ||||||
|     if (!mpd_send_list_queue_range_meta(mpd.conn, offset, offset+MAX_ELEMENTS_PER_PAGE)) |     if (!mpd_send_list_queue_range_meta(mpd.conn, offset, offset+MAX_ELEMENTS_PER_PAGE)) | ||||||
|         RETURN_ERROR_AND_RECOVER("mpd_send_list_queue_meta"); |         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, "},"); |             cur += json_emit_raw_str(cur, end - cur, "},"); | ||||||
|  |  | ||||||
|             totalTime += drtn; |             totalTime += drtn; | ||||||
|  |             totalSongs ++; | ||||||
|         } |         } | ||||||
|         mpd_entity_free(entity); |         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_raw_str(cur, end - cur, "],\"totalTime\":"); | ||||||
|     cur += json_emit_int(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, "}"); |     cur += json_emit_raw_str(cur, end - cur, "}"); | ||||||
|     return cur - buffer; |     return cur - buffer; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 jcorporation
					jcorporation