summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-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 d552e41826..53058b3bc9 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -64,6 +64,7 @@
64#endif 64#endif
65#include "playlist_menu.h" 65#include "playlist_menu.h"
66#include "playlist_catalog.h" 66#include "playlist_catalog.h"
67#include "tagtree.h"
67 68
68static int context; 69static int context;
69static char* selected_file = NULL; 70static char* selected_file = NULL;
@@ -174,26 +175,33 @@ static bool add_to_playlist(int position, bool queue)
174 if (new_playlist) 175 if (new_playlist)
175 playlist_create(NULL, NULL); 176 playlist_create(NULL, NULL);
176 177
177 if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) 178 if (context == CONTEXT_ID3DB)
178 playlist_insert_track(NULL, selected_file, position, queue);
179 else if (selected_file_attr & ATTR_DIRECTORY)
180 { 179 {
181 bool recurse = false; 180 tagtree_insert_selection_playlist(position, queue);
182 181 }
183 if (global_settings.recursive_dir_insert != RECURSE_ASK) 182 else
184 recurse = (bool)global_settings.recursive_dir_insert; 183 {
185 else 184 if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA)
185 playlist_insert_track(NULL, selected_file, position, queue);
186 else if (selected_file_attr & ATTR_DIRECTORY)
186 { 187 {
187 /* Ask if user wants to recurse directory */ 188 bool recurse = false;
188 recurse = (gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES); 189
190 if (global_settings.recursive_dir_insert != RECURSE_ASK)
191 recurse = (bool)global_settings.recursive_dir_insert;
192 else
193 {
194 /* Ask if user wants to recurse directory */
195 recurse = (gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES);
196 }
197
198 playlist_insert_directory(NULL, selected_file, position, queue,
199 recurse);
189 } 200 }
190 201 else if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)
191 playlist_insert_directory(NULL, selected_file, position, queue, 202 playlist_insert_playlist(NULL, selected_file, position, queue);
192 recurse);
193 } 203 }
194 else if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U) 204
195 playlist_insert_playlist(NULL, selected_file, position, queue);
196
197 if (new_playlist && (playlist_amount() > 0)) 205 if (new_playlist && (playlist_amount() > 0))
198 { 206 {
199 /* nothing is currently playing so begin playing what we just 207 /* nothing is currently playing so begin playing what we just
@@ -842,8 +850,7 @@ int onplay(char* file, int attr, int from)
842 850
843 if (context == CONTEXT_WPS || 851 if (context == CONTEXT_WPS ||
844 context == CONTEXT_TREE || 852 context == CONTEXT_TREE ||
845 ((context == CONTEXT_ID3DB) && 853 (context == CONTEXT_ID3DB))
846 (attr & TREE_ATTR_MASK) == TREE_ATTR_MPA))
847 { 854 {
848 items[i].desc = ID2P(LANG_PLAYLIST); 855 items[i].desc = ID2P(LANG_PLAYLIST);
849 items[i].function = playlist_options; 856 items[i].function = playlist_options;
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 7321e9df49..b92e4cb93c 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -81,6 +81,8 @@ static const char *strp;
81static int current_offset; 81static int current_offset;
82static int current_entry_count; 82static int current_entry_count;
83 83
84static struct tree_context *tc;
85
84static int get_token_str(char *buf, int size) 86static int get_token_str(char *buf, int size)
85{ 87{
86 /* Find the start. */ 88 /* Find the start. */
@@ -745,6 +747,7 @@ static int load_root(struct tree_context *c)
745 struct tagentry *dptr = (struct tagentry *)c->dircache; 747 struct tagentry *dptr = (struct tagentry *)c->dircache;
746 int i; 748 int i;
747 749
750 tc = c;
748 c->currtable = root; 751 c->currtable = root;
749 for (i = 0; i < si_count; i++) 752 for (i = 0; i < si_count; i++)
750 { 753 {
@@ -924,23 +927,17 @@ int tagtree_get_filename(struct tree_context* c, char *buf, int buflen)
924 927
925 return 0; 928 return 0;
926} 929}
927 930
928static int tagtree_play_folder(struct tree_context* c) 931bool insert_all_playlist(struct tree_context *c, int position, bool queue)
929{ 932{
930 int i; 933 int i;
931 char buf[MAX_PATH]; 934 char buf[MAX_PATH];
932 935
933 if (playlist_create(NULL, NULL) < 0)
934 {
935 logf("Failed creating playlist\n");
936 return -1;
937 }
938
939 cpu_boost(true); 936 cpu_boost(true);
940 if (!tagcache_search(&tcs, tag_filename)) 937 if (!tagcache_search(&tcs, tag_filename))
941 { 938 {
942 gui_syncsplash(HZ, true, str(LANG_TAGCACHE_BUSY)); 939 gui_syncsplash(HZ, true, str(LANG_TAGCACHE_BUSY));
943 return -1; 940 return false;
944 } 941 }
945 942
946 for (i=0; i < c->filesindir; i++) 943 for (i=0; i < c->filesindir; i++)
@@ -954,11 +951,77 @@ static int tagtree_play_folder(struct tree_context* c)
954 continue; 951 continue;
955 } 952 }
956 953
957 playlist_insert_track(NULL, buf, PLAYLIST_INSERT, false); 954 playlist_insert_track(NULL, buf, position, queue);
958 } 955 }
959 tagcache_search_finish(&tcs); 956 tagcache_search_finish(&tcs);
960 cpu_boost(false); 957 cpu_boost(false);
961 958
959 return true;
960}
961
962bool tagtree_insert_selection_playlist(int position, bool queue)
963{
964 struct tagentry *dptr;
965 int dirlevel = tc->dirlevel;
966
967 dptr = tagtree_get_entry(tc, tc->selected_item);
968
969 /* We need to set the table to allsubentries. */
970 if (dptr->newtable == navibrowse)
971 {
972 tagtree_enter(tc);
973 tagtree_load(tc);
974 dptr = tagtree_get_entry(tc, tc->selected_item);
975 }
976 else if (dptr->newtable != allsubentries)
977 {
978 logf("unsupported table: %d", dptr->newtable);
979 return false;
980 }
981
982 /* Now the current table should be allsubentries. */
983 if (dptr->newtable != playtrack)
984 {
985 tagtree_enter(tc);
986 tagtree_load(tc);
987 dptr = tagtree_get_entry(tc, tc->selected_item);
988
989 /* And now the newtable should be playtrack. */
990 if (dptr->newtable != playtrack)
991 {
992 logf("newtable: %d !!", dptr->newtable);
993 tc->dirlevel = dirlevel;
994 return false;
995 }
996 }
997
998 if (tc->filesindir <= 0)
999 gui_syncsplash(HZ, true, str(LANG_END_PLAYLIST_PLAYER));
1000 else
1001 {
1002 logf("insert_all_playlist");
1003 insert_all_playlist(tc, position, queue);
1004 }
1005
1006 /* Finally return the dirlevel to its original value. */
1007 while (tc->dirlevel > dirlevel)
1008 tagtree_exit(tc);
1009 tagtree_load(tc);
1010
1011 return true;
1012}
1013
1014static int tagtree_play_folder(struct tree_context* c)
1015{
1016 if (playlist_create(NULL, NULL) < 0)
1017 {
1018 logf("Failed creating playlist\n");
1019 return -1;
1020 }
1021
1022 if (!insert_all_playlist(c, PLAYLIST_INSERT, false))
1023 return -2;
1024
962 if (global_settings.playlist_shuffle) 1025 if (global_settings.playlist_shuffle)
963 c->selected_item = playlist_shuffle(current_tick, c->selected_item); 1026 c->selected_item = playlist_shuffle(current_tick, c->selected_item);
964 if (!global_settings.play_selected) 1027 if (!global_settings.play_selected)
diff --git a/apps/tagtree.h b/apps/tagtree.h
index e40dd1b45b..0c612ad395 100644
--- a/apps/tagtree.h
+++ b/apps/tagtree.h
@@ -37,6 +37,7 @@ int tagtree_enter(struct tree_context* c);
37void tagtree_exit(struct tree_context* c); 37void tagtree_exit(struct tree_context* c);
38int tagtree_load(struct tree_context* c); 38int tagtree_load(struct tree_context* c);
39struct tagentry* tagtree_get_entry(struct tree_context *c, int id); 39struct tagentry* tagtree_get_entry(struct tree_context *c, int id);
40bool tagtree_insert_selection_playlist(int position, bool queue);
40int tagtree_get_attr(struct tree_context* c); 41int tagtree_get_attr(struct tree_context* c);
41#ifdef HAVE_LCD_BITMAP 42#ifdef HAVE_LCD_BITMAP
42const unsigned char* tagtree_get_icon(struct tree_context* c); 43const unsigned char* tagtree_get_icon(struct tree_context* c);
diff --git a/apps/tree.c b/apps/tree.c
index 97c7557d3f..83be023475 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -782,6 +782,8 @@ static bool dirbrowse(void)
782 attr = TREE_ATTR_MPA; 782 attr = TREE_ATTR_MPA;
783 tagtree_get_filename(&tc, buf, sizeof(buf)); 783 tagtree_get_filename(&tc, buf, sizeof(buf));
784 } 784 }
785 else
786 attr = ATTR_DIRECTORY;
785 } 787 }
786 else 788 else
787 { 789 {