summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/onplay.c43
-rw-r--r--apps/tagtree.c83
-rw-r--r--apps/tagtree.h1
-rw-r--r--apps/tree.c2
4 files changed, 101 insertions, 28 deletions
diff --git a/apps/onplay.c b/apps/onplay.c
index d552e41..53058b3 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -64,6 +64,7 @@
#endif
#include "playlist_menu.h"
#include "playlist_catalog.h"
+#include "tagtree.h"
static int context;
static char* selected_file = NULL;
@@ -174,26 +175,33 @@ static bool add_to_playlist(int position, bool queue)
if (new_playlist)
playlist_create(NULL, NULL);
- if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA)
- playlist_insert_track(NULL, selected_file, position, queue);
- else if (selected_file_attr & ATTR_DIRECTORY)
+ if (context == CONTEXT_ID3DB)
{
- bool recurse = false;
-
- if (global_settings.recursive_dir_insert != RECURSE_ASK)
- recurse = (bool)global_settings.recursive_dir_insert;
- else
+ tagtree_insert_selection_playlist(position, queue);
+ }
+ else
+ {
+ if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA)
+ playlist_insert_track(NULL, selected_file, position, queue);
+ else if (selected_file_attr & ATTR_DIRECTORY)
{
- /* Ask if user wants to recurse directory */
- recurse = (gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES);
+ bool recurse = false;
+
+ if (global_settings.recursive_dir_insert != RECURSE_ASK)
+ recurse = (bool)global_settings.recursive_dir_insert;
+ else
+ {
+ /* Ask if user wants to recurse directory */
+ recurse = (gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES);
+ }
+
+ playlist_insert_directory(NULL, selected_file, position, queue,
+ recurse);
}
-
- playlist_insert_directory(NULL, selected_file, position, queue,
- recurse);
+ else if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)
+ playlist_insert_playlist(NULL, selected_file, position, queue);
}
- else if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)
- playlist_insert_playlist(NULL, selected_file, position, queue);
-
+
if (new_playlist && (playlist_amount() > 0))
{
/* nothing is currently playing so begin playing what we just
@@ -842,8 +850,7 @@ int onplay(char* file, int attr, int from)
if (context == CONTEXT_WPS ||
context == CONTEXT_TREE ||
- ((context == CONTEXT_ID3DB) &&
- (attr & TREE_ATTR_MASK) == TREE_ATTR_MPA))
+ (context == CONTEXT_ID3DB))
{
items[i].desc = ID2P(LANG_PLAYLIST);
items[i].function = playlist_options;
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 7321e9d..b92e4cb 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -81,6 +81,8 @@ static const char *strp;
static int current_offset;
static int current_entry_count;
+static struct tree_context *tc;
+
static int get_token_str(char *buf, int size)
{
/* Find the start. */
@@ -745,6 +747,7 @@ static int load_root(struct tree_context *c)
struct tagentry *dptr = (struct tagentry *)c->dircache;
int i;
+ tc = c;
c->currtable = root;
for (i = 0; i < si_count; i++)
{
@@ -924,23 +927,17 @@ int tagtree_get_filename(struct tree_context* c, char *buf, int buflen)
return 0;
}
-
-static int tagtree_play_folder(struct tree_context* c)
+
+bool insert_all_playlist(struct tree_context *c, int position, bool queue)
{
int i;
char buf[MAX_PATH];
- if (playlist_create(NULL, NULL) < 0)
- {
- logf("Failed creating playlist\n");
- return -1;
- }
-
cpu_boost(true);
if (!tagcache_search(&tcs, tag_filename))
{
gui_syncsplash(HZ, true, str(LANG_TAGCACHE_BUSY));
- return -1;
+ return false;
}
for (i=0; i < c->filesindir; i++)
@@ -954,11 +951,77 @@ static int tagtree_play_folder(struct tree_context* c)
continue;
}
- playlist_insert_track(NULL, buf, PLAYLIST_INSERT, false);
+ playlist_insert_track(NULL, buf, position, queue);
}
tagcache_search_finish(&tcs);
cpu_boost(false);
+ return true;
+}
+
+bool tagtree_insert_selection_playlist(int position, bool queue)
+{
+ struct tagentry *dptr;
+ int dirlevel = tc->dirlevel;
+
+ dptr = tagtree_get_entry(tc, tc->selected_item);
+
+ /* We need to set the table to allsubentries. */
+ if (dptr->newtable == navibrowse)
+ {
+ tagtree_enter(tc);
+ tagtree_load(tc);
+ dptr = tagtree_get_entry(tc, tc->selected_item);
+ }
+ else if (dptr->newtable != allsubentries)
+ {
+ logf("unsupported table: %d", dptr->newtable);
+ return false;
+ }
+
+ /* Now the current table should be allsubentries. */
+ if (dptr->newtable != playtrack)
+ {
+ tagtree_enter(tc);
+ tagtree_load(tc);
+ dptr = tagtree_get_entry(tc, tc->selected_item);
+
+ /* And now the newtable should be playtrack. */
+ if (dptr->newtable != playtrack)
+ {
+ logf("newtable: %d !!", dptr->newtable);
+ tc->dirlevel = dirlevel;
+ return false;
+ }
+ }
+
+ if (tc->filesindir <= 0)
+ gui_syncsplash(HZ, true, str(LANG_END_PLAYLIST_PLAYER));
+ else
+ {
+ logf("insert_all_playlist");
+ insert_all_playlist(tc, position, queue);
+ }
+
+ /* Finally return the dirlevel to its original value. */
+ while (tc->dirlevel > dirlevel)
+ tagtree_exit(tc);
+ tagtree_load(tc);
+
+ return true;
+}
+
+static int tagtree_play_folder(struct tree_context* c)
+{
+ if (playlist_create(NULL, NULL) < 0)
+ {
+ logf("Failed creating playlist\n");
+ return -1;
+ }
+
+ if (!insert_all_playlist(c, PLAYLIST_INSERT, false))
+ return -2;
+
if (global_settings.playlist_shuffle)
c->selected_item = playlist_shuffle(current_tick, c->selected_item);
if (!global_settings.play_selected)
diff --git a/apps/tagtree.h b/apps/tagtree.h
index e40dd1b..0c612ad 100644
--- a/apps/tagtree.h
+++ b/apps/tagtree.h
@@ -37,6 +37,7 @@ int tagtree_enter(struct tree_context* c);
void tagtree_exit(struct tree_context* c);
int tagtree_load(struct tree_context* c);
struct tagentry* tagtree_get_entry(struct tree_context *c, int id);
+bool tagtree_insert_selection_playlist(int position, bool queue);
int tagtree_get_attr(struct tree_context* c);
#ifdef HAVE_LCD_BITMAP
const unsigned char* tagtree_get_icon(struct tree_context* c);
diff --git a/apps/tree.c b/apps/tree.c
index 97c7557..83be023 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -782,6 +782,8 @@ static bool dirbrowse(void)
attr = TREE_ATTR_MPA;
tagtree_get_filename(&tc, buf, sizeof(buf));
}
+ else
+ attr = ATTR_DIRECTORY;
}
else
{