--- ../rockbox-devel-orig/apps/onplay.c 2005-08-31 11:05:04.000000000 -0400 +++ apps/onplay.c 2005-10-06 15:19:45.636239900 -0400 @@ -35,6 +35,7 @@ #include "keyboard.h" #include "mp3data.h" #include "id3.h" +#include "metadata.h" #include "screens.h" #include "tree.h" #include "buffer.h" @@ -503,6 +504,11 @@ return true; } +bool show_id3_info(void) +{ + return browse_id3_file(selected_file); +} + static bool exit_to_main; /* catch MENU_EXIT_MENU within context menu to call the main menu afterwards */ @@ -593,6 +599,14 @@ } } + if (!(attr & ATTR_DIRECTORY) && context == CONTEXT_TREE && + probe_file_format(selected_file) != AFMT_UNKNOWN) + { + items[i].desc = ID2P(LANG_MENU_SHOW_ID3_INFO); + items[i].function = show_id3_info; + i++; + } + if (!(attr & ATTR_DIRECTORY) && attr) { items[i].desc = ID2P(LANG_ONPLAY_OPEN_WITH); --- ../rockbox-devel-orig/apps/screens.c 2005-10-03 14:34:52.000000000 -0400 +++ apps/screens.c 2005-10-06 15:34:53.475580200 -0400 @@ -41,6 +41,7 @@ #include "talk.h" #include "misc.h" #include "id3.h" +#include "metadata.h" #include "screens.h" #include "debug.h" #include "led.h" @@ -1288,6 +1289,12 @@ } #endif +#if defined(HAVE_LCD_BITMAP) +#define LINES_PER_ID3_ITEM 3 +#else +#define LINES_PER_ID3_ITEM 2 +#endif + int draw_id3_item(int line, int top, int header, const char* body) { if (line >= top) @@ -1311,7 +1318,7 @@ } } - return line + 2; + return line + LINES_PER_ID3_ITEM; } #if CONFIG_CODEC == SWCODEC @@ -1320,25 +1327,24 @@ #define ID3_ITEMS 11 #endif -bool browse_id3(void) +bool browse_id3_entry(const struct mp3entry *id3, const bool is_playing) { char buf[64]; - const struct mp3entry* id3 = audio_current_track(); #if defined(HAVE_LCD_BITMAP) const int y_margin = lcd_getymargin(); const int line_height = font_get(FONT_UI)->height; const int rows = (LCD_HEIGHT - y_margin) / line_height; const bool show_scrollbar = global_settings.scrollbar - && (ID3_ITEMS * 2 > rows); + && (ID3_ITEMS * LINES_PER_ID3_ITEM > rows); #else const int rows = 2; #endif - const int top_max = (ID3_ITEMS * 2) - (rows & ~1); + const int top_max = (ID3_ITEMS * LINES_PER_ID3_ITEM) - rows + rows%LINES_PER_ID3_ITEM; int top = 0; int button; bool exit = false; - if (!id3 || (!(audio_status() & AUDIO_STATUS_PLAY))) + if (!id3) { return false; } @@ -1397,9 +1403,17 @@ wps_format_time(buf, sizeof(buf), id3->length); line = draw_id3_item(line, top, LANG_ID3_LENGHT, buf); - snprintf(buf, sizeof(buf), "%d/%d", playlist_get_display_index(), - playlist_amount()); - line = draw_id3_item(line, top, LANG_ID3_PLAYLIST, buf); + if (is_playing) + { + snprintf(buf, sizeof(buf), "%d/%d", playlist_get_display_index(), + playlist_amount()); + body = buf; + } + else + { + body = NULL; + } + line = draw_id3_item(line, top, LANG_ID3_PLAYLIST, body); snprintf(buf, sizeof(buf), "%d kbps%s", id3->bitrate, id3->vbr ? str(LANG_ID3_VBR) : (const unsigned char*) ""); @@ -1422,7 +1436,8 @@ if (show_scrollbar) { scrollbar(0, y_margin, SCROLLBAR_WIDTH - 1, rows * line_height, - ID3_ITEMS * 2 + (rows & 1), top, top + rows, VERTICAL); + (ID3_ITEMS * LINES_PER_ID3_ITEM) + rows%LINES_PER_ID3_ITEM, + top, top + rows, VERTICAL); } #endif @@ -1445,7 +1460,7 @@ #endif if (top > 0) { - top -= 2; + top -= LINES_PER_ID3_ITEM; } else if (!(button & BUTTON_REPEAT)) { @@ -1462,7 +1477,7 @@ #endif if (top < top_max) { - top += 2; + top += LINES_PER_ID3_ITEM; } else if (!(button & BUTTON_REPEAT)) { @@ -1495,6 +1510,46 @@ return false; } +bool browse_id3(void) +{ + return browse_id3_entry( audio_current_track(), true ); +} + +bool browse_id3_file(const char* filename) +{ + bool ret; + bool v1first = false; /* FIXME: is this an option? */ + struct track_info track; + +#if CONFIG_CODEC == SWCODEC + memset( &(track.id3), 0, sizeof(struct mp3entry) ); + + unsigned int filetype = probe_file_format(filename); + if (filetype == AFMT_UNKNOWN) + { + return false; + } + track.id3.codectype = filetype; + + int fd = open(filename, O_RDONLY); + if (fd < 0) + { + return false; + } + + ret = get_metadata(&track, fd, filename, v1first); +#else + ret = mp3info( &(track.id3), filename, v1first ); +#endif + + if (ret) + { + return browse_id3_entry( &(track.id3), false); + } + + return false; +} + bool set_rating(void) { struct mp3entry* id3 = audio_current_track(); --- ../rockbox-devel-orig/apps/screens.h 2005-07-05 11:21:02.000000000 -0400 +++ apps/screens.h 2005-10-06 15:19:45.651903900 -0400 @@ -55,6 +55,7 @@ bool shutdown_screen(void); bool browse_id3(void); +bool browse_id3_file(const char* filename); bool set_rating(void); #endif