Display duration for audio files, by special demand and because it was easy to add.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20080 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1c7220491e
commit
f53630a168
1 changed files with 20 additions and 0 deletions
|
@ -35,6 +35,7 @@ char str_time[64];
|
|||
char str_title[MAX_PATH];
|
||||
char str_artist[MAX_PATH];
|
||||
char str_album[MAX_PATH];
|
||||
char str_duration[32];
|
||||
|
||||
int num_properties;
|
||||
|
||||
|
@ -103,6 +104,7 @@ static bool file_properties(char* selected_file)
|
|||
if (!rb->mp3info(&id3, selected_file))
|
||||
#endif
|
||||
{
|
||||
long dur = id3.length / 1000; /* seconds */
|
||||
rb->snprintf(str_artist, sizeof str_artist,
|
||||
"Artist: %s", id3.artist ? id3.artist : "");
|
||||
rb->snprintf(str_title, sizeof str_title,
|
||||
|
@ -110,6 +112,21 @@ static bool file_properties(char* selected_file)
|
|||
rb->snprintf(str_album, sizeof str_album,
|
||||
"Album: %s", id3.album ? id3.album : "");
|
||||
num_properties += 3;
|
||||
|
||||
if (dur > 0)
|
||||
{
|
||||
if (dur < 3600)
|
||||
rb->snprintf(str_duration, sizeof str_duration,
|
||||
"Duration: %d:%02d", (int)(dur / 60),
|
||||
(int)(dur % 60));
|
||||
else
|
||||
rb->snprintf(str_duration, sizeof str_duration,
|
||||
"Duration: %d:%02d:%02d",
|
||||
(int)(dur / 3600),
|
||||
(int)(dur % 3600 / 60),
|
||||
(int)(dur % 60));
|
||||
num_properties++;
|
||||
}
|
||||
}
|
||||
#if (CONFIG_CODEC == SWCODEC)
|
||||
rb->close(fd);
|
||||
|
@ -243,6 +260,9 @@ char * get_props(int selected_item, void* data, char *buffer, size_t buffer_len)
|
|||
case 7:
|
||||
rb->strncpy(buffer, its_a_dir ? "" : str_album, buffer_len);
|
||||
break;
|
||||
case 8:
|
||||
rb->strncpy(buffer, its_a_dir ? "" : str_duration, buffer_len);
|
||||
break;
|
||||
default:
|
||||
rb->strncpy(buffer, "ERROR", buffer_len);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue