summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2007-08-14 11:56:15 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2007-08-14 11:56:15 +0000
commit9aa597f7f63a1f2752ed8691931a5febb97ed51b (patch)
treec88dcbd2885f3f5603e95b018e1498ee42927681 /apps
parentdb15e5d3ba88357626f87a7fbb4a1523fe3c9672 (diff)
downloadrockbox-9aa597f7f63a1f2752ed8691931a5febb97ed51b.tar.gz
rockbox-9aa597f7f63a1f2752ed8691931a5febb97ed51b.zip
Add a bit of metadata info in the properties plugin output.
When displaying the properties of a file, attempt to get metadata from it and on success, display the artist, title and album strings. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14328 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/properties.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c
index bc95548afe..17698e866c 100644
--- a/apps/plugins/properties.c
+++ b/apps/plugins/properties.c
@@ -33,6 +33,11 @@ char str_dircount[64];
char str_filecount[64];
char str_date[64];
char str_time[64];
+char str_title[MAX_PATH];
+char str_artist[MAX_PATH];
+char str_album[MAX_PATH];
+
+int num_properties;
static char* filesize2string(long long size, char* pstr, int len)
{
@@ -61,6 +66,8 @@ static bool file_properties(char* selected_file)
char tstr[MAX_PATH];
DIR* dir;
struct dirent* entry;
+ struct mp3entry id3;
+ int fd;
char* ptr = rb->strrchr(selected_file, '/') + 1;
int dirlen = (ptr - selected_file);
@@ -87,6 +94,25 @@ static bool file_properties(char* selected_file)
rb->snprintf(str_time, sizeof str_time, "Time: %02d:%02d",
((entry->wrttime >> 11) & 0x1F), /* hour */
((entry->wrttime >> 5 ) & 0x3F)); /* minutes */
+
+ num_properties = 5;
+
+ fd = rb->open(selected_file, O_RDONLY);
+ if (fd >= 0)
+ {
+ if (rb->get_metadata(&id3, fd, selected_file, false))
+ {
+ rb->snprintf(str_artist, sizeof str_artist,
+ "Artist: %s", id3.artist ? id3.artist : "");
+ rb->snprintf(str_title, sizeof str_title,
+ "Title: %s", id3.title ? id3.title : "");
+ rb->snprintf(str_album, sizeof str_album,
+ "Album: %s", id3.album ? id3.album : "");
+ num_properties = 8;
+ }
+ rb->close(fd);
+ }
+
found = true;
break;
}
@@ -181,6 +207,7 @@ static bool dir_properties(char* selected_file)
rb->snprintf(str_filecount, sizeof str_filecount, "Files: %d", dps.fc);
rb->snprintf(str_size, sizeof str_size, "Size: %s",
filesize2string(dps.bc, tstr, sizeof tstr));
+ num_properties = 4;
return true;
}
@@ -205,6 +232,15 @@ char * get_props(int selected_item, void* data, char *buffer)
case 4:
rb->strcpy(buffer, its_a_dir ? "" : str_time);
break;
+ case 5:
+ rb->strcpy(buffer, its_a_dir ? "" : str_artist);
+ break;
+ case 6:
+ rb->strcpy(buffer, its_a_dir ? "" : str_title);
+ break;
+ case 7:
+ rb->strcpy(buffer, its_a_dir ? "" : str_album);
+ break;
default:
rb->strcpy(buffer, "ERROR");
break;
@@ -271,7 +307,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* file)
"Directory properties" :
"File properties", NOICON);
rb->gui_synclist_set_icon_callback(&properties_lists, NULL);
- rb->gui_synclist_set_nb_items(&properties_lists, its_a_dir ? 4 : 5);
+ rb->gui_synclist_set_nb_items(&properties_lists, num_properties);
rb->gui_synclist_limit_scroll(&properties_lists, true);
rb->gui_synclist_select_item(&properties_lists, 0);
rb->gui_synclist_draw(&properties_lists);