summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/filetree.c80
-rw-r--r--apps/filetree.h1
-rw-r--r--apps/playlist_catalog.c28
3 files changed, 70 insertions, 39 deletions
diff --git a/apps/filetree.c b/apps/filetree.c
index 35be92e4b5..edd421cad9 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -79,6 +79,55 @@ int ft_build_playlist(struct tree_context* c, int start_index)
79 return start_index; 79 return start_index;
80} 80}
81 81
82/* Start playback of a playlist, checking for bookmark autoload, modified
83 * playlists, etc., as required. Returns false if playback wasn't started,
84 * or started via bookmark autoload, true otherwise.
85 *
86 * Pointers to both the full pathname and the separated parts needed to
87 * avoid allocating yet another path buffer on the stack (and save some
88 * code; the caller typically needs to create the full pathname anyway)...
89 */
90bool ft_play_playlist(char* pathname, char* dirname, char* filename)
91{
92 if (global_settings.party_mode)
93 {
94 gui_syncsplash(HZ, ID2P(LANG_PARTY_MODE));
95 return false;
96 }
97
98 if (bookmark_autoload(pathname))
99 {
100 return false;
101 }
102
103 gui_syncsplash(0, ID2P(LANG_WAIT));
104
105 /* about to create a new current playlist...
106 allow user to cancel the operation */
107 if (global_settings.warnon_erase_dynplaylist &&
108 playlist_modified(NULL))
109 {
110 char *lines[] = {ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
111 struct text_message message = {lines, 1};
112
113 if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
114 return false;
115 }
116
117 if (playlist_create(dirname, filename) != -1)
118 {
119 if (global_settings.playlist_shuffle)
120 {
121 playlist_shuffle(current_tick, -1);
122 }
123
124 playlist_start(0, 0);
125 return true;
126 }
127
128 return false;
129}
130
82/* walk a directory and check all dircache entries if a .talk file exists */ 131/* walk a directory and check all dircache entries if a .talk file exists */
83static void check_file_thumbnails(struct tree_context* c) 132static void check_file_thumbnails(struct tree_context* c)
84{ 133{
@@ -341,36 +390,13 @@ int ft_enter(struct tree_context* c)
341 390
342 switch ( file->attr & FILE_ATTR_MASK ) { 391 switch ( file->attr & FILE_ATTR_MASK ) {
343 case FILE_ATTR_M3U: 392 case FILE_ATTR_M3U:
344 if (global_settings.party_mode) { 393 play = ft_play_playlist(buf, c->currdir, file->name);
345 gui_syncsplash(HZ, ID2P(LANG_PARTY_MODE)); 394
346 break; 395 if (play)
347 }
348
349 if (bookmark_autoload(buf))
350 break;
351
352 gui_syncsplash(0, ID2P(LANG_WAIT));
353
354 /* about to create a new current playlist...
355 allow user to cancel the operation */
356 if (global_settings.warnon_erase_dynplaylist &&
357 playlist_modified(NULL))
358 { 396 {
359 char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
360 struct text_message message={lines, 1};
361
362 if(gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
363 break;
364 }
365
366 if (playlist_create(c->currdir, file->name) != -1)
367 {
368 if (global_settings.playlist_shuffle)
369 playlist_shuffle(seed, -1);
370 start_index = 0; 397 start_index = 0;
371 playlist_start(start_index,0);
372 play = true;
373 } 398 }
399
374 break; 400 break;
375 401
376 case FILE_ATTR_AUDIO: 402 case FILE_ATTR_AUDIO:
diff --git a/apps/filetree.h b/apps/filetree.h
index 66fbbb579a..c9d1157fe9 100644
--- a/apps/filetree.h
+++ b/apps/filetree.h
@@ -24,5 +24,6 @@ int ft_load(struct tree_context* c, const char* tempdir);
24int ft_enter(struct tree_context* c); 24int ft_enter(struct tree_context* c);
25int ft_exit(struct tree_context* c); 25int ft_exit(struct tree_context* c);
26int ft_build_playlist(struct tree_context* c, int start_index); 26int ft_build_playlist(struct tree_context* c, int start_index);
27bool ft_play_playlist(char* pathname, char* dirname, char* filename);
27 28
28#endif 29#endif
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index fda91bb1ee..f5c5bcb35b 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -38,6 +38,7 @@
38#include "tree.h" 38#include "tree.h"
39#include "yesno.h" 39#include "yesno.h"
40#include "filetypes.h" 40#include "filetypes.h"
41#include "debug.h"
41 42
42#define PLAYLIST_CATALOG_CFG ROCKBOX_DIR "/playlist_catalog.config" 43#define PLAYLIST_CATALOG_CFG ROCKBOX_DIR "/playlist_catalog.config"
43#define PLAYLIST_CATALOG_DEFAULT_DIR "/Playlists" 44#define PLAYLIST_CATALOG_DEFAULT_DIR "/Playlists"
@@ -212,6 +213,18 @@ static char* playlist_callback_name(int selected_item, void* data,
212 213
213 strncpy(buffer, playlists[selected_item], MAX_PATH); 214 strncpy(buffer, playlists[selected_item], MAX_PATH);
214 215
216 if (buffer[0] != '.' && !(global_settings.show_filename_ext == 1
217 || (global_settings.show_filename_ext == 3
218 && global_settings.dirfilter == 0)))
219 {
220 char* dot = strrchr(buffer, '.');
221
222 if (dot != NULL)
223 {
224 *dot = '\0';
225 }
226 }
227
215 return buffer; 228 return buffer;
216} 229}
217 230
@@ -260,21 +273,12 @@ static int display_playlists(char* playlist, bool view)
260 break; 273 break;
261 274
262 case ACTION_STD_OK: 275 case ACTION_STD_OK:
276 snprintf(playlist, MAX_PATH, "%s/%s", playlist_dir, sel_file);
277
263 if (view) 278 if (view)
264 { 279 {
265 /* In view mode, selecting a playlist starts playback */ 280 /* In view mode, selecting a playlist starts playback */
266 if (playlist_create(playlist_dir, sel_file) != -1) 281 ft_play_playlist(playlist, playlist_dir, sel_file);
267 {
268 if (global_settings.playlist_shuffle)
269 playlist_shuffle(current_tick, -1);
270 playlist_start(0, 0);
271 }
272 }
273 else
274 {
275 /* we found the playlist we want to add to */
276 snprintf(playlist, MAX_PATH, "%s/%s", playlist_dir,
277 sel_file);
278 } 282 }
279 283
280 result = 0; 284 result = 0;