Skip to content

Commit 5d0de7c

Browse files
committed
Display album, year and genre if found in music player
1 parent a2686d6 commit 5d0de7c

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

source/menus/menu_music.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ static void Music_HandleNext(bool forward, int state) {
124124
free(length_time);
125125
free(position_time);
126126

127-
if ((metadata.has_meta) && (metadata.cover_image))
128-
SDL_DestroyTexture(metadata.cover_image);
129-
130127
Audio_Term();
131128
Music_Play(playlist[selection]);
132129
}
@@ -165,14 +162,25 @@ void Menu_PlayMusic(char *path) {
165162

166163
SDL_DrawRect(0, 141, 560, 560, MUSIC_GENRE_COLOUR); // Draw album art background
167164

165+
SDL_DrawRect(570, 141, 710, 559, FC_MakeColor(45, 48, 50, 255)); // Draw info box (outer)
166+
SDL_DrawRect(575, 146, 700, 549, FC_MakeColor(46, 49, 51, 255)); // Draw info box (inner)
167+
168+
if (metadata.has_meta) {
169+
if (metadata.album[0] != '\0')
170+
SDL_DrawTextf(590, 156, 30, WHITE, "Album: %.50s", metadata.album);
171+
172+
if (metadata.year[0] != '\0')
173+
SDL_DrawTextf(590, 196, 30, WHITE, "Year: %.50s", metadata.year);
174+
175+
if (metadata.genre[0] != '\0')
176+
SDL_DrawTextf(590, 236, 30, WHITE, "Genre: %.50s", metadata.genre);
177+
}
178+
168179
if ((metadata.has_meta) && (metadata.cover_image))
169180
SDL_DrawImageScale(metadata.cover_image, 0, 141, 560, 560); // Cover art
170181
else
171182
SDL_DrawImage(default_artwork, 0, 141); // Default album art
172183

173-
SDL_DrawRect(570, 141, 710, 559, FC_MakeColor(45, 48, 50, 255)); // Draw info box (outer)
174-
SDL_DrawRect(575, 146, 700, 549, FC_MakeColor(46, 49, 51, 255)); // Draw info box (inner)
175-
176184
Menu_ConvertSecondsToString(position_time, Audio_GetPositionSeconds());
177185
SDL_DrawText(605, 615, 30, WHITE, position_time);
178186
SDL_DrawText(1245 - length_time_width, 615, 30, WHITE, length_time);
@@ -294,9 +302,6 @@ void Menu_PlayMusic(char *path) {
294302
free(length_time);
295303
free(position_time);
296304

297-
if ((metadata.has_meta) && (metadata.cover_image))
298-
SDL_DestroyTexture(metadata.cover_image);
299-
300305
Audio_Term();
301306
memset(playlist, 0, sizeof(playlist[0][0]) * 512 * 512);
302307
count = 0;

0 commit comments

Comments
 (0)