1
0
Fork 0
forked from len0rd/rockbox

Added basic playlist creation. Creates <dirname>.m3u in the parent directory, containing all mp3/mp2/mpa files found recursively. The process can be aborted with OFF or STOP.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3185 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2003-01-29 13:20:22 +00:00
parent 38bc30b0d6
commit efb165f65c
4 changed files with 117 additions and 4 deletions

View file

@ -1316,3 +1316,13 @@ id: LANG_ALARM_MOD_KEYS
desc: Shown key functions in alarm menu (for the RTC alarm mod). desc: Shown key functions in alarm menu (for the RTC alarm mod).
eng: "PLAY=Set OFF=Cancel" eng: "PLAY=Set OFF=Cancel"
new: new:
id: LANG_CREATE_PLAYLIST
desc: Menu option for creating a playlist
eng: "Create Playlist"
new:
id: LANG_CREATING
desc: Screen feedback during playlist creation
eng: "Creating"
new:

View file

@ -257,14 +257,15 @@ bool main_menu(void)
struct menu_items items[] = { struct menu_items items[] = {
{ str(LANG_SOUND_SETTINGS), sound_menu }, { str(LANG_SOUND_SETTINGS), sound_menu },
{ str(LANG_GENERAL_SETTINGS), settings_menu }, { str(LANG_GENERAL_SETTINGS), settings_menu },
#ifdef HAVE_MAS3587F
{ str(LANG_RECORDING), recording_screen },
{ str(LANG_RECORDING_SETTINGS), recording_menu },
#endif
{ str(LANG_CREATE_PLAYLIST), create_playlist },
{ str(LANG_SLEEP_TIMER), sleeptimer_screen }, { str(LANG_SLEEP_TIMER), sleeptimer_screen },
#ifdef HAVE_ALARM_MOD #ifdef HAVE_ALARM_MOD
{ str(LANG_ALARM_MOD_ALARM_MENU), alarm_screen }, { str(LANG_ALARM_MOD_ALARM_MENU), alarm_screen },
#endif #endif
#ifdef HAVE_MAS3587F
{ str(LANG_RECORDING_SETTINGS), recording_menu },
{ str(LANG_RECORDING), recording_screen },
#endif
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
#ifdef USE_GAMES #ifdef USE_GAMES
{ str(LANG_GAMES), games_menu }, { str(LANG_GAMES), games_menu },

View file

@ -1419,3 +1419,104 @@ bool dirbrowse(char *root)
return false; return false;
} }
static int plsize = 0;
static bool add_dir(char* dirname, int fd)
{
bool abort = false;
char buf[MAX_PATH/2]; /* saving a little stack... */
DEBUGF("add_dir(%s)\n",dirname);
/* check for user abort */
#ifdef HAVE_PLAYER_KEYPAD
if (button_get(false) == BUTTON_STOP)
#else
if (button_get(false) == BUTTON_OFF)
#endif
return true;
DIR* dir = opendir(dirname);
if(!dir)
return true;
while (true) {
struct dirent *entry;
entry = readdir(dir);
if (!entry)
break;
if (entry->attribute & ATTR_DIRECTORY) {
if (!strcmp(entry->d_name, ".") ||
!strcmp(entry->d_name, ".."))
continue;
snprintf(buf, sizeof buf, "%s/%s", dirname, entry->d_name);
if (add_dir(buf,fd)) {
abort = true;
break;
}
}
else {
int x = strlen(entry->d_name);
if ((!strcasecmp(&entry->d_name[x-4], ".mp3")) ||
(!strcasecmp(&entry->d_name[x-4], ".mp2")) ||
(!strcasecmp(&entry->d_name[x-4], ".mpa")))
{
DEBUGF("adding %s\n",entry->d_name);
write(fd, dirname, strlen(dirname));
write(fd, "/", 1);
write(fd, entry->d_name, x);
write(fd, "\n", 1);
plsize++;
snprintf(buf, sizeof buf, "%d", plsize);
#ifdef HAVE_LCD_BITMAP
lcd_puts(0,4,buf);
lcd_update();
#else
x = 10;
if (plsize > 999)
x=7;
else {
if (plsize > 99)
x=8;
else {
if (plsize > 9)
x=9;
}
}
lcd_puts(x,0,buf);
#endif
}
}
}
closedir(dir);
return abort;
}
bool create_playlist(void)
{
int fd;
char filename[MAX_PATH];
snprintf(filename, sizeof filename, "%s.m3u",
currdir[1] ? currdir : "/root");
lcd_clear_display();
lcd_puts(0,0,str(LANG_CREATING));
lcd_puts_scroll(0,1,filename);
lcd_update();
fd = creat(filename,0);
if (!fd)
return false;
plsize = 0;
add_dir(currdir[1] ? currdir : "/", fd);
close(fd);
sleep(HZ);
return false;
}

View file

@ -24,5 +24,6 @@
void browse_root(void); void browse_root(void);
void set_current_file(char *path); void set_current_file(char *path);
bool dirbrowse(char *root); bool dirbrowse(char *root);
bool create_playlist(void);
#endif #endif