diff options
-rw-r--r-- | apps/filetree.c | 12 | ||||
-rw-r--r-- | apps/lang/english.lang | 46 | ||||
-rw-r--r-- | apps/menus/playlist_menu.c | 53 | ||||
-rw-r--r-- | apps/misc.h | 3 | ||||
-rw-r--r-- | apps/onplay.c | 40 | ||||
-rw-r--r-- | apps/onplay.h | 4 | ||||
-rw-r--r-- | apps/playlist_catalog.c | 41 | ||||
-rw-r--r-- | apps/playlist_catalog.h | 6 | ||||
-rw-r--r-- | apps/playlist_viewer.c | 71 | ||||
-rw-r--r-- | apps/playlist_viewer.h | 1 | ||||
-rw-r--r-- | apps/root_menu.c | 29 | ||||
-rw-r--r-- | apps/tree.c | 11 |
12 files changed, 235 insertions, 82 deletions
diff --git a/apps/filetree.c b/apps/filetree.c index b7f3c9e981..654d33d347 100644 --- a/apps/filetree.c +++ b/apps/filetree.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * __________ __ ___. | 2 | * __________ __ ___. |
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
@@ -43,6 +43,7 @@ | |||
43 | #include "filetree.h" | 43 | #include "filetree.h" |
44 | #include "misc.h" | 44 | #include "misc.h" |
45 | #include "strnatcmp.h" | 45 | #include "strnatcmp.h" |
46 | #include "playlist_viewer.h" | ||
46 | #ifdef HAVE_LCD_BITMAP | 47 | #ifdef HAVE_LCD_BITMAP |
47 | #include "keyboard.h" | 48 | #include "keyboard.h" |
48 | #endif | 49 | #endif |
@@ -445,13 +446,8 @@ int ft_enter(struct tree_context* c) | |||
445 | 446 | ||
446 | switch ( file->attr & FILE_ATTR_MASK ) { | 447 | switch ( file->attr & FILE_ATTR_MASK ) { |
447 | case FILE_ATTR_M3U: | 448 | case FILE_ATTR_M3U: |
448 | play = ft_play_playlist(buf, c->currdir, file->name); | 449 | if (!bookmark_autoload(buf)) |
449 | 450 | playlist_viewer_ex(buf); | |
450 | if (play) | ||
451 | { | ||
452 | start_index = 0; | ||
453 | } | ||
454 | |||
455 | break; | 451 | break; |
456 | 452 | ||
457 | case FILE_ATTR_AUDIO: | 453 | case FILE_ATTR_AUDIO: |
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index e0811fad09..e9d1dbaccc 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang | |||
@@ -502,7 +502,7 @@ | |||
502 | </phrase> | 502 | </phrase> |
503 | <phrase> | 503 | <phrase> |
504 | id: LANG_PLAYLISTS | 504 | id: LANG_PLAYLISTS |
505 | desc: in the main menu and file view setting | 505 | desc: in the file view setting |
506 | user: core | 506 | user: core |
507 | <source> | 507 | <source> |
508 | *: "Playlists" | 508 | *: "Playlists" |
@@ -6544,7 +6544,7 @@ | |||
6544 | </phrase> | 6544 | </phrase> |
6545 | <phrase> | 6545 | <phrase> |
6546 | id: LANG_CATALOG | 6546 | id: LANG_CATALOG |
6547 | desc: in onplay menu | 6547 | desc: in main menu and onplay menu |
6548 | user: core | 6548 | user: core |
6549 | <source> | 6549 | <source> |
6550 | *: "Playlist Catalog" | 6550 | *: "Playlist Catalog" |
@@ -12757,3 +12757,45 @@ | |||
12757 | *: "Rewind on Pause" | 12757 | *: "Rewind on Pause" |
12758 | </voice> | 12758 | </voice> |
12759 | </phrase> | 12759 | </phrase> |
12760 | <phrase> | ||
12761 | id: LANG_SET_AS_PLAYLISTCAT_DIR | ||
12762 | desc: used in the onplay menu to set a playlist catalog dir | ||
12763 | user: core | ||
12764 | <source> | ||
12765 | *: "Set As Playlist Catalog Directory" | ||
12766 | </source> | ||
12767 | <dest> | ||
12768 | *: "Set As Playlist Catalog Directory" | ||
12769 | </dest> | ||
12770 | <voice> | ||
12771 | *: "Set As Playlist Catalog Directory" | ||
12772 | </voice> | ||
12773 | </phrase> | ||
12774 | <phrase> | ||
12775 | id: LANG_RESET_PLAYLISTCAT_DIR | ||
12776 | desc: | ||
12777 | user: core | ||
12778 | <source> | ||
12779 | *: "Reset Playlist Catalog Directory" | ||
12780 | </source> | ||
12781 | <dest> | ||
12782 | *: "Reset Playlist Catalog Directory" | ||
12783 | </dest> | ||
12784 | <voice> | ||
12785 | *: "Reset Playlist Catalog Directory" | ||
12786 | </voice> | ||
12787 | </phrase> | ||
12788 | <phrase> | ||
12789 | id: LANG_CURRENT_PLAYLIST | ||
12790 | desc: Used when you need to say playlist, also voiced | ||
12791 | user: core | ||
12792 | <source> | ||
12793 | *: "Current Playlist" | ||
12794 | </source> | ||
12795 | <dest> | ||
12796 | *: "Current Playlist" | ||
12797 | </dest> | ||
12798 | <voice> | ||
12799 | *: "Current Playlist" | ||
12800 | </voice> | ||
12801 | </phrase> | ||
diff --git a/apps/menus/playlist_menu.c b/apps/menus/playlist_menu.c index a47c3b15e4..be3ad307c4 100644 --- a/apps/menus/playlist_menu.c +++ b/apps/menus/playlist_menu.c | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include <stdbool.h> | 22 | #include <stdbool.h> |
23 | #include <string.h> | 23 | #include <string.h> |
24 | #include <stdio.h> | ||
24 | #include "config.h" | 25 | #include "config.h" |
25 | #include "lang.h" | 26 | #include "lang.h" |
26 | #include "action.h" | 27 | #include "action.h" |
@@ -35,20 +36,28 @@ | |||
35 | #include "playlist_viewer.h" | 36 | #include "playlist_viewer.h" |
36 | #include "talk.h" | 37 | #include "talk.h" |
37 | #include "playlist_catalog.h" | 38 | #include "playlist_catalog.h" |
39 | #include "splash.h" | ||
38 | 40 | ||
39 | int save_playlist_screen(struct playlist_info* playlist) | 41 | int save_playlist_screen(struct playlist_info* playlist) |
40 | { | 42 | { |
41 | char temp[MAX_PATH+1]; | 43 | char temp[MAX_PATH+1], *dot; |
42 | int len; | 44 | int len; |
43 | 45 | ||
44 | playlist_get_name(playlist, temp, sizeof(temp)-1); | 46 | playlist_get_name(playlist, temp, sizeof(temp)-1); |
45 | len = strlen(temp); | 47 | len = strlen(temp); |
46 | 48 | ||
47 | if (len > 4 && !strcasecmp(&temp[len-4], ".m3u")) | 49 | dot = strrchr(temp, '.'); |
50 | if (!dot) | ||
51 | { | ||
52 | /* folder of some type */ | ||
53 | if (temp[1] != '\0') | ||
54 | strcpy(&temp[len-1], ".m3u8"); | ||
55 | else | ||
56 | snprintf(temp, sizeof(temp), "%s%s", | ||
57 | catalog_get_directory(), DEFAULT_DYNAMIC_PLAYLIST_NAME); | ||
58 | } | ||
59 | else if (len > 4 && !strcasecmp(dot, ".m3u")) | ||
48 | strcat(temp, "8"); | 60 | strcat(temp, "8"); |
49 | |||
50 | if (len <= 5 || strcasecmp(&temp[len-5], ".m3u8")) | ||
51 | strcpy(temp, DEFAULT_DYNAMIC_PLAYLIST_NAME); | ||
52 | 61 | ||
53 | if (!kbd_input(temp, sizeof(temp))) | 62 | if (!kbd_input(temp, sizeof(temp))) |
54 | { | 63 | { |
@@ -63,27 +72,45 @@ int save_playlist_screen(struct playlist_info* playlist) | |||
63 | 72 | ||
64 | static int playlist_view_(void) | 73 | static int playlist_view_(void) |
65 | { | 74 | { |
66 | return GO_TO_PLAYLIST_VIEWER; | 75 | playlist_viewer_ex(NULL); |
76 | return 0; | ||
67 | } | 77 | } |
68 | 78 | ||
69 | MENUITEM_FUNCTION(create_playlist_item, 0, ID2P(LANG_CREATE_PLAYLIST), | 79 | MENUITEM_FUNCTION(create_playlist_item, 0, ID2P(LANG_CREATE_PLAYLIST), |
70 | (int(*)(void))create_playlist, NULL, NULL, Icon_NOICON); | 80 | (int(*)(void))create_playlist, NULL, NULL, Icon_NOICON); |
71 | MENUITEM_FUNCTION(view_cur_playlist, MENU_FUNC_CHECK_RETVAL, | 81 | MENUITEM_FUNCTION(view_cur_playlist, 0, |
72 | ID2P(LANG_VIEW_DYNAMIC_PLAYLIST), | 82 | ID2P(LANG_VIEW_DYNAMIC_PLAYLIST), |
73 | (int(*)(void))playlist_view_, NULL, NULL, Icon_NOICON); | 83 | (int(*)(void))playlist_view_, NULL, NULL, Icon_NOICON); |
74 | MENUITEM_FUNCTION(save_playlist, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), | 84 | MENUITEM_FUNCTION(save_playlist, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), |
75 | (int(*)(void*))save_playlist_screen, | 85 | (int(*)(void*))save_playlist_screen, |
76 | NULL, NULL, Icon_NOICON); | 86 | NULL, NULL, Icon_NOICON); |
77 | MENUITEM_FUNCTION(catalog, 0, ID2P(LANG_CATALOG_VIEW), | ||
78 | (int(*)(void))catalog_view_playlists, | ||
79 | NULL, NULL, Icon_NOICON); | ||
80 | MENUITEM_SETTING(recursive_dir_insert, &global_settings.recursive_dir_insert, NULL); | 87 | MENUITEM_SETTING(recursive_dir_insert, &global_settings.recursive_dir_insert, NULL); |
81 | MENUITEM_SETTING(warn_on_erase, &global_settings.warnon_erase_dynplaylist, NULL); | 88 | MENUITEM_SETTING(warn_on_erase, &global_settings.warnon_erase_dynplaylist, NULL); |
89 | static int clear_catalog_directory(void) | ||
90 | { | ||
91 | catalog_set_directory(NULL); | ||
92 | settings_save(); | ||
93 | splash(HZ, ID2P(LANG_RESET_DONE_CLEAR)); | ||
94 | return false; | ||
95 | } | ||
96 | MENUITEM_FUNCTION(clear_catalog_directory_item, 0, ID2P(LANG_RESET_PLAYLISTCAT_DIR), | ||
97 | clear_catalog_directory, NULL, NULL, Icon_file_view_menu); | ||
98 | |||
99 | /* Playlist viewer settings submenu */ | ||
100 | MENUITEM_SETTING(show_icons, &global_settings.playlist_viewer_icons, NULL); | ||
101 | MENUITEM_SETTING(show_indices, &global_settings.playlist_viewer_indices, NULL); | ||
102 | MENUITEM_SETTING(track_display, | ||
103 | &global_settings.playlist_viewer_track_display, NULL); | ||
104 | MAKE_MENU(viewer_settings_menu, ID2P(LANG_PLAYLISTVIEWER_SETTINGS), | ||
105 | NULL, Icon_Playlist, | ||
106 | &show_icons, &show_indices, &track_display); | ||
107 | |||
82 | 108 | ||
83 | MAKE_MENU(playlist_settings, ID2P(LANG_PLAYLISTS), NULL, | 109 | MAKE_MENU(playlist_settings, ID2P(LANG_PLAYLISTS), NULL, |
84 | Icon_Playlist, | 110 | Icon_Playlist, |
85 | &recursive_dir_insert, &warn_on_erase); | 111 | &viewer_settings_menu, &recursive_dir_insert, &warn_on_erase); |
86 | MAKE_MENU(playlist_options, ID2P(LANG_PLAYLISTS), NULL, | 112 | MAKE_MENU(playlist_options, ID2P(LANG_PLAYLISTS), NULL, |
87 | Icon_Playlist, | 113 | Icon_Playlist, |
88 | &create_playlist_item, &view_cur_playlist, &save_playlist, &catalog); | 114 | &create_playlist_item, &view_cur_playlist, |
115 | &save_playlist, &clear_catalog_directory_item); | ||
89 | 116 | ||
diff --git a/apps/misc.h b/apps/misc.h index 7ea5360db5..1e151f0ebc 100644 --- a/apps/misc.h +++ b/apps/misc.h | |||
@@ -113,7 +113,8 @@ enum current_activity { | |||
113 | ACTIVITY_PLUGINBROWSER, | 113 | ACTIVITY_PLUGINBROWSER, |
114 | ACTIVITY_QUICKSCREEN, | 114 | ACTIVITY_QUICKSCREEN, |
115 | ACTIVITY_PITCHSCREEN, | 115 | ACTIVITY_PITCHSCREEN, |
116 | ACTIVITY_OPTIONSELECT | 116 | ACTIVITY_OPTIONSELECT, |
117 | ACTIVITY_PLAYLISTBROWSER | ||
117 | }; | 118 | }; |
118 | 119 | ||
119 | #if CONFIG_CODEC == SWCODEC | 120 | #if CONFIG_CODEC == SWCODEC |
diff --git a/apps/onplay.c b/apps/onplay.c index a2a3671d3e..da06f937b6 100644 --- a/apps/onplay.c +++ b/apps/onplay.c | |||
@@ -315,7 +315,7 @@ MENUITEM_FUNCTION(view_playlist_item, 0, ID2P(LANG_VIEW), | |||
315 | view_playlist, NULL, | 315 | view_playlist, NULL, |
316 | treeplaylist_callback, Icon_Playlist); | 316 | treeplaylist_callback, Icon_Playlist); |
317 | 317 | ||
318 | MAKE_ONPLAYMENU( tree_playlist_menu, ID2P(LANG_PLAYLIST), | 318 | MAKE_ONPLAYMENU( tree_playlist_menu, ID2P(LANG_CURRENT_PLAYLIST), |
319 | treeplaylist_callback, Icon_Playlist, | 319 | treeplaylist_callback, Icon_Playlist, |
320 | 320 | ||
321 | /* view */ | 321 | /* view */ |
@@ -382,6 +382,12 @@ static int treeplaylist_callback(int action, | |||
382 | return action; | 382 | return action; |
383 | } | 383 | } |
384 | 384 | ||
385 | void onplay_show_playlist_menu(char* track_name) | ||
386 | { | ||
387 | selected_file = track_name; | ||
388 | selected_file_attr = FILE_ATTR_AUDIO; | ||
389 | do_menu(&tree_playlist_menu, NULL, NULL, false); | ||
390 | } | ||
385 | 391 | ||
386 | /* playlist catalog options */ | 392 | /* playlist catalog options */ |
387 | static bool cat_add_to_a_playlist(void) | 393 | static bool cat_add_to_a_playlist(void) |
@@ -395,23 +401,37 @@ static bool cat_add_to_a_new_playlist(void) | |||
395 | return catalog_add_to_a_playlist(selected_file, selected_file_attr, | 401 | return catalog_add_to_a_playlist(selected_file, selected_file_attr, |
396 | true, NULL); | 402 | true, NULL); |
397 | } | 403 | } |
404 | static int clipboard_callback(int action,const struct menu_item_ex *this_item); | ||
405 | static bool set_catalogdir(void) | ||
406 | { | ||
407 | catalog_set_directory(selected_file); | ||
408 | settings_save(); | ||
409 | return false; | ||
410 | } | ||
411 | MENUITEM_FUNCTION(set_catalogdir_item, 0, ID2P(LANG_SET_AS_PLAYLISTCAT_DIR), | ||
412 | set_catalogdir, NULL, clipboard_callback, Icon_Playlist); | ||
398 | 413 | ||
399 | static int cat_playlist_callback(int action, | 414 | static int cat_playlist_callback(int action, |
400 | const struct menu_item_ex *this_item); | 415 | const struct menu_item_ex *this_item); |
401 | MENUITEM_FUNCTION(cat_view_lists, 0, ID2P(LANG_CATALOG_VIEW), | ||
402 | catalog_view_playlists, 0, | ||
403 | cat_playlist_callback, Icon_Playlist); | ||
404 | MENUITEM_FUNCTION(cat_add_to_list, 0, ID2P(LANG_CATALOG_ADD_TO), | 416 | MENUITEM_FUNCTION(cat_add_to_list, 0, ID2P(LANG_CATALOG_ADD_TO), |
405 | cat_add_to_a_playlist, 0, NULL, Icon_Playlist); | 417 | cat_add_to_a_playlist, 0, NULL, Icon_Playlist); |
406 | MENUITEM_FUNCTION(cat_add_to_new, 0, ID2P(LANG_CATALOG_ADD_TO_NEW), | 418 | MENUITEM_FUNCTION(cat_add_to_new, 0, ID2P(LANG_CATALOG_ADD_TO_NEW), |
407 | cat_add_to_a_new_playlist, 0, NULL, Icon_Playlist); | 419 | cat_add_to_a_new_playlist, 0, NULL, Icon_Playlist); |
408 | MAKE_ONPLAYMENU(cat_playlist_menu, ID2P(LANG_CATALOG), | 420 | MAKE_ONPLAYMENU(cat_playlist_menu, ID2P(LANG_CATALOG), |
409 | cat_playlist_callback, Icon_Playlist, | 421 | cat_playlist_callback, Icon_Playlist, |
410 | &cat_view_lists, &cat_add_to_list, &cat_add_to_new); | 422 | &cat_add_to_list, &cat_add_to_new, &set_catalogdir_item); |
423 | |||
424 | void onplay_show_playlist_cat_menu(char* track_name) | ||
425 | { | ||
426 | selected_file = track_name; | ||
427 | selected_file_attr = FILE_ATTR_AUDIO; | ||
428 | do_menu(&cat_playlist_menu, NULL, NULL, false); | ||
429 | } | ||
411 | 430 | ||
412 | static int cat_playlist_callback(int action, | 431 | static int cat_playlist_callback(int action, |
413 | const struct menu_item_ex *this_item) | 432 | const struct menu_item_ex *this_item) |
414 | { | 433 | { |
434 | (void)this_item; | ||
415 | if (!selected_file || | 435 | if (!selected_file || |
416 | (((selected_file_attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) && | 436 | (((selected_file_attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) && |
417 | ((selected_file_attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) && | 437 | ((selected_file_attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) && |
@@ -430,12 +450,7 @@ static int cat_playlist_callback(int action, | |||
430 | switch (action) | 450 | switch (action) |
431 | { | 451 | { |
432 | case ACTION_REQUEST_MENUITEM: | 452 | case ACTION_REQUEST_MENUITEM: |
433 | if (this_item == &cat_view_lists) | 453 | if ((audio_status() & AUDIO_STATUS_PLAY) || context != CONTEXT_WPS) |
434 | { | ||
435 | return action; | ||
436 | } | ||
437 | else if ((audio_status() & AUDIO_STATUS_PLAY) || | ||
438 | context != CONTEXT_WPS) | ||
439 | { | 454 | { |
440 | return action; | 455 | return action; |
441 | } | 456 | } |
@@ -1100,7 +1115,8 @@ static int clipboard_callback(int action,const struct menu_item_ex *this_item) | |||
1100 | { | 1115 | { |
1101 | /* only for directories */ | 1116 | /* only for directories */ |
1102 | if (this_item == &delete_dir_item || | 1117 | if (this_item == &delete_dir_item || |
1103 | this_item == &set_startdir_item | 1118 | this_item == &set_startdir_item || |
1119 | this_item == &set_catalogdir_item | ||
1104 | #ifdef HAVE_RECORDING | 1120 | #ifdef HAVE_RECORDING |
1105 | || this_item == &set_recdir_item | 1121 | || this_item == &set_recdir_item |
1106 | #endif | 1122 | #endif |
diff --git a/apps/onplay.h b/apps/onplay.h index b129296a7b..921303cf57 100644 --- a/apps/onplay.h +++ b/apps/onplay.h | |||
@@ -48,4 +48,8 @@ enum hotkey_action { | |||
48 | }; | 48 | }; |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | /* needed for the playlist viewer.. eventually clean this up */ | ||
52 | void onplay_show_playlist_cat_menu(char* track_name); | ||
53 | void onplay_show_playlist_menu(char* track_name); | ||
54 | |||
51 | #endif | 55 | #endif |
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c index 9d4d707c08..3687681b66 100644 --- a/apps/playlist_catalog.c +++ b/apps/playlist_catalog.c | |||
@@ -43,6 +43,8 @@ | |||
43 | #include "debug.h" | 43 | #include "debug.h" |
44 | #include "playlist_catalog.h" | 44 | #include "playlist_catalog.h" |
45 | #include "talk.h" | 45 | #include "talk.h" |
46 | #include "playlist_viewer.h" | ||
47 | #include "bookmark.h" | ||
46 | 48 | ||
47 | /* Use for recursive directory search */ | 49 | /* Use for recursive directory search */ |
48 | struct add_track_context { | 50 | struct add_track_context { |
@@ -59,9 +61,9 @@ static int playlist_dir_length; | |||
59 | static bool playlist_dir_exists = false; | 61 | static bool playlist_dir_exists = false; |
60 | 62 | ||
61 | /* Retrieve playlist directory from config file and verify it exists */ | 63 | /* Retrieve playlist directory from config file and verify it exists */ |
64 | static bool initialized = false; | ||
62 | static int initialize_catalog(void) | 65 | static int initialize_catalog(void) |
63 | { | 66 | { |
64 | static bool initialized = false; | ||
65 | 67 | ||
66 | if (!initialized) | 68 | if (!initialized) |
67 | { | 69 | { |
@@ -110,6 +112,27 @@ static int initialize_catalog(void) | |||
110 | return 0; | 112 | return 0; |
111 | } | 113 | } |
112 | 114 | ||
115 | void catalog_set_directory(const char* directory) | ||
116 | { | ||
117 | if (directory == NULL) | ||
118 | { | ||
119 | global_settings.playlist_catalog_dir[0] = '\0'; | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | strcpy(global_settings.playlist_catalog_dir, directory); | ||
124 | } | ||
125 | initialized = false; | ||
126 | initialize_catalog(); | ||
127 | } | ||
128 | |||
129 | const char* catalog_get_directory(void) | ||
130 | { | ||
131 | if (initialize_catalog() == -1) | ||
132 | return ""; | ||
133 | return playlist_dir; | ||
134 | } | ||
135 | |||
113 | /* Display all playlists in catalog. Selected "playlist" is returned. | 136 | /* Display all playlists in catalog. Selected "playlist" is returned. |
114 | If "view" mode is set then we're not adding anything into playlist. */ | 137 | If "view" mode is set then we're not adding anything into playlist. */ |
115 | static int display_playlists(char* playlist, bool view) | 138 | static int display_playlists(char* playlist, bool view) |
@@ -126,6 +149,8 @@ static int display_playlists(char* playlist, bool view) | |||
126 | browse.buf = selected_playlist; | 149 | browse.buf = selected_playlist; |
127 | browse.bufsize = sizeof(selected_playlist); | 150 | browse.bufsize = sizeof(selected_playlist); |
128 | 151 | ||
152 | restart: | ||
153 | browse.flags &= ~BROWSE_SELECTED; | ||
129 | rockbox_browse(&browse); | 154 | rockbox_browse(&browse); |
130 | 155 | ||
131 | if (browse.flags & BROWSE_SELECTED) | 156 | if (browse.flags & BROWSE_SELECTED) |
@@ -135,9 +160,12 @@ static int display_playlists(char* playlist, bool view) | |||
135 | 160 | ||
136 | if (view) | 161 | if (view) |
137 | { | 162 | { |
138 | char *filename = strrchr(selected_playlist, '/')+1; | 163 | |
139 | /* In view mode, selecting a playlist starts playback */ | 164 | if (!bookmark_autoload(selected_playlist)) |
140 | ft_play_playlist(selected_playlist, playlist_dir, filename); | 165 | { |
166 | if (playlist_viewer_ex(selected_playlist) == PLAYLIST_VIEWER_CANCEL) | ||
167 | goto restart; | ||
168 | } | ||
141 | result = 0; | 169 | result = 0; |
142 | } | 170 | } |
143 | else | 171 | else |
@@ -311,8 +339,6 @@ bool catalog_add_to_a_playlist(const char* sel, int sel_attr, | |||
311 | snprintf(playlist, MAX_PATH, "%s/%s.m3u8", | 339 | snprintf(playlist, MAX_PATH, "%s/%s.m3u8", |
312 | playlist_dir, | 340 | playlist_dir, |
313 | (name!=NULL && (sel_attr & ATTR_DIRECTORY))?name+1:""); | 341 | (name!=NULL && (sel_attr & ATTR_DIRECTORY))?name+1:""); |
314 | if (kbd_input(playlist, MAX_PATH)) | ||
315 | return false; | ||
316 | } | 342 | } |
317 | else | 343 | else |
318 | strcpy(playlist, m3u8name); | 344 | strcpy(playlist, m3u8name); |
@@ -323,6 +349,9 @@ bool catalog_add_to_a_playlist(const char* sel, int sel_attr, | |||
323 | strcat(playlist, "8"); | 349 | strcat(playlist, "8"); |
324 | else if(len <= 5 || strcasecmp(&playlist[len-5], ".m3u8")) | 350 | else if(len <= 5 || strcasecmp(&playlist[len-5], ".m3u8")) |
325 | strcat(playlist, ".m3u8"); | 351 | strcat(playlist, ".m3u8"); |
352 | |||
353 | if (kbd_input(playlist, MAX_PATH)) | ||
354 | return false; | ||
326 | } | 355 | } |
327 | else | 356 | else |
328 | { | 357 | { |
diff --git a/apps/playlist_catalog.h b/apps/playlist_catalog.h index 2c2a2d4158..2e317128b7 100644 --- a/apps/playlist_catalog.h +++ b/apps/playlist_catalog.h | |||
@@ -21,6 +21,12 @@ | |||
21 | #ifndef _PLAYLIST_CATALOG_H_ | 21 | #ifndef _PLAYLIST_CATALOG_H_ |
22 | #define _PLAYLIST_CATALOG_H_ | 22 | #define _PLAYLIST_CATALOG_H_ |
23 | 23 | ||
24 | /* Gets the configured playlist catalog dir */ | ||
25 | const char* catalog_get_directory(void); | ||
26 | |||
27 | /* Set the playlist catalog dir */ | ||
28 | void catalog_set_directory(const char* directory); | ||
29 | |||
24 | /* | 30 | /* |
25 | * View list of playlists in catalog. | 31 | * View list of playlists in catalog. |
26 | * ret : true if no error | 32 | * ret : true if no error |
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index aaa45599b0..17b9cf5e39 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c | |||
@@ -125,7 +125,6 @@ static void format_line(const struct playlist_entry* track, char* str, | |||
125 | 125 | ||
126 | static bool update_playlist(bool force); | 126 | static bool update_playlist(bool force); |
127 | static int onplay_menu(int index); | 127 | static int onplay_menu(int index); |
128 | static bool viewer_menu(void); | ||
129 | static int save_playlist_func(void); | 128 | static int save_playlist_func(void); |
130 | 129 | ||
131 | static void playlist_buffer_init(struct playlist_buffer *pb, char *names_buffer, | 130 | static void playlist_buffer_init(struct playlist_buffer *pb, char *names_buffer, |
@@ -437,6 +436,9 @@ static bool update_playlist(bool force) | |||
437 | return true; | 436 | return true; |
438 | } | 437 | } |
439 | 438 | ||
439 | MENUITEM_FUNCTION(save_playlist_item, 0, ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), | ||
440 | save_playlist_func, 0, NULL, Icon_NOICON); | ||
441 | |||
440 | /* Menu of playlist commands. Invoked via ON+PLAY on main viewer screen. | 442 | /* Menu of playlist commands. Invoked via ON+PLAY on main viewer screen. |
441 | Returns -1 if USB attached, 0 if no playlist change, and 1 if playlist | 443 | Returns -1 if USB attached, 0 if no playlist change, and 1 if playlist |
442 | changed. */ | 444 | changed. */ |
@@ -446,9 +448,9 @@ static int onplay_menu(int index) | |||
446 | struct playlist_entry * current_track = | 448 | struct playlist_entry * current_track = |
447 | playlist_buffer_get_track(&viewer.buffer, index); | 449 | playlist_buffer_get_track(&viewer.buffer, index); |
448 | MENUITEM_STRINGLIST(menu_items, ID2P(LANG_PLAYLIST), NULL, | 450 | MENUITEM_STRINGLIST(menu_items, ID2P(LANG_PLAYLIST), NULL, |
451 | ID2P(LANG_PLAYLIST), ID2P(LANG_CATALOG), | ||
449 | ID2P(LANG_REMOVE), ID2P(LANG_MOVE), | 452 | ID2P(LANG_REMOVE), ID2P(LANG_MOVE), |
450 | ID2P(LANG_CATALOG_ADD_TO), ID2P(LANG_CATALOG_ADD_TO_NEW), | 453 | ID2P(LANG_SAVE_DYNAMIC_PLAYLIST)); |
451 | ID2P(LANG_PLAYLISTVIEWER_SETTINGS)); | ||
452 | bool current = (current_track->index == viewer.current_playing_track); | 454 | bool current = (current_track->index == viewer.current_playing_track); |
453 | 455 | ||
454 | result = do_menu(&menu_items, NULL, NULL, false); | 456 | result = do_menu(&menu_items, NULL, NULL, false); |
@@ -465,6 +467,16 @@ static int onplay_menu(int index) | |||
465 | switch (result) | 467 | switch (result) |
466 | { | 468 | { |
467 | case 0: | 469 | case 0: |
470 | /* playlist */ | ||
471 | onplay_show_playlist_menu(current_track->name); | ||
472 | ret = 0; | ||
473 | break; | ||
474 | case 1: | ||
475 | /* add to catalog */ | ||
476 | onplay_show_playlist_cat_menu(current_track->name); | ||
477 | ret = 0; | ||
478 | break; | ||
479 | case 2: | ||
468 | /* delete track */ | 480 | /* delete track */ |
469 | playlist_delete(viewer.playlist, current_track->index); | 481 | playlist_delete(viewer.playlist, current_track->index); |
470 | if (current) | 482 | if (current) |
@@ -490,43 +502,22 @@ static int onplay_menu(int index) | |||
490 | } | 502 | } |
491 | ret = 1; | 503 | ret = 1; |
492 | break; | 504 | break; |
493 | case 1: | 505 | case 3: |
494 | /* move track */ | 506 | /* move track */ |
495 | viewer.moving_track = index; | 507 | viewer.moving_track = index; |
496 | viewer.moving_playlist_index = current_track->index; | 508 | viewer.moving_playlist_index = current_track->index; |
497 | ret = 0; | 509 | ret = 0; |
498 | break; | 510 | break; |
499 | case 2: /* add to catalog */ | 511 | case 4: |
500 | case 3: /* add to a new one */ | 512 | /* save playlist */ |
501 | catalog_add_to_a_playlist(current_track->name, | 513 | save_playlist_screen(viewer.playlist); |
502 | FILE_ATTR_AUDIO, | ||
503 | result == 3, NULL); | ||
504 | ret = 0; | 514 | ret = 0; |
505 | break; | 515 | break; |
506 | case 4: /* playlist viewer settings */ | ||
507 | /* true on usb connect */ | ||
508 | ret = viewer_menu() ? -1 : 0; | ||
509 | break; | ||
510 | } | 516 | } |
511 | } | 517 | } |
512 | return ret; | 518 | return ret; |
513 | } | 519 | } |
514 | 520 | ||
515 | /* Menu of viewer options. Invoked via F1(r) or Menu(p). */ | ||
516 | MENUITEM_SETTING(show_icons, &global_settings.playlist_viewer_icons, NULL); | ||
517 | MENUITEM_SETTING(show_indices, &global_settings.playlist_viewer_indices, NULL); | ||
518 | MENUITEM_SETTING(track_display, | ||
519 | &global_settings.playlist_viewer_track_display, NULL); | ||
520 | MENUITEM_FUNCTION(save_playlist_item, 0, ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), | ||
521 | save_playlist_func, 0, NULL, Icon_NOICON); | ||
522 | MAKE_MENU(viewer_settings_menu, ID2P(LANG_PLAYLISTVIEWER_SETTINGS), | ||
523 | NULL, Icon_Playlist, | ||
524 | &show_icons, &show_indices, &track_display, &save_playlist_item); | ||
525 | static bool viewer_menu(void) | ||
526 | { | ||
527 | return do_menu(&viewer_settings_menu, NULL, NULL, false) == MENU_ATTACHED_USB; | ||
528 | } | ||
529 | |||
530 | /* Save playlist to disk */ | 521 | /* Save playlist to disk */ |
531 | static int save_playlist_func(void) | 522 | static int save_playlist_func(void) |
532 | { | 523 | { |
@@ -712,7 +703,10 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename) | |||
712 | gui_synclist_draw(&playlist_lists); | 703 | gui_synclist_draw(&playlist_lists); |
713 | } | 704 | } |
714 | else | 705 | else |
706 | { | ||
715 | exit = true; | 707 | exit = true; |
708 | ret = PLAYLIST_VIEWER_CANCEL; | ||
709 | } | ||
716 | break; | 710 | break; |
717 | } | 711 | } |
718 | case ACTION_STD_OK: | 712 | case ACTION_STD_OK: |
@@ -739,20 +733,31 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename) | |||
739 | else if (!viewer.playlist) | 733 | else if (!viewer.playlist) |
740 | { | 734 | { |
741 | /* play new track */ | 735 | /* play new track */ |
742 | playlist_start(current_track->index, 0); | 736 | if (!global_settings.party_mode) |
743 | update_playlist(false); | 737 | { |
738 | playlist_start(current_track->index, 0); | ||
739 | update_playlist(false); | ||
740 | } | ||
744 | } | 741 | } |
745 | else | 742 | else if (!global_settings.party_mode) |
746 | { | 743 | { |
744 | int start_index = current_track->index; | ||
745 | if (!warn_on_pl_erase()) | ||
746 | { | ||
747 | gui_synclist_draw(&playlist_lists); | ||
748 | break; | ||
749 | } | ||
747 | /* New playlist */ | 750 | /* New playlist */ |
748 | if (playlist_set_current(viewer.playlist) < 0) | 751 | if (playlist_set_current(viewer.playlist) < 0) |
749 | goto exit; | 752 | goto exit; |
750 | 753 | if (global_settings.playlist_shuffle) | |
751 | playlist_start(current_track->index, 0); | 754 | start_index = playlist_shuffle(current_tick, start_index); |
755 | playlist_start(start_index, 0); | ||
752 | 756 | ||
753 | /* Our playlist is now the current list */ | 757 | /* Our playlist is now the current list */ |
754 | if (!playlist_viewer_init(&viewer, NULL, true)) | 758 | if (!playlist_viewer_init(&viewer, NULL, true)) |
755 | goto exit; | 759 | goto exit; |
760 | exit = true; | ||
756 | } | 761 | } |
757 | gui_synclist_draw(&playlist_lists); | 762 | gui_synclist_draw(&playlist_lists); |
758 | 763 | ||
diff --git a/apps/playlist_viewer.h b/apps/playlist_viewer.h index 97f5b0baef..0a54c1b2cd 100644 --- a/apps/playlist_viewer.h +++ b/apps/playlist_viewer.h | |||
@@ -29,6 +29,7 @@ bool search_playlist(void); | |||
29 | 29 | ||
30 | enum playlist_viewer_result { | 30 | enum playlist_viewer_result { |
31 | PLAYLIST_VIEWER_OK, | 31 | PLAYLIST_VIEWER_OK, |
32 | PLAYLIST_VIEWER_CANCEL, | ||
32 | PLAYLIST_VIEWER_USB, | 33 | PLAYLIST_VIEWER_USB, |
33 | PLAYLIST_VIEWER_MAINMENU, | 34 | PLAYLIST_VIEWER_MAINMENU, |
34 | }; | 35 | }; |
diff --git a/apps/root_menu.c b/apps/root_menu.c index 3e53bd9dc1..573ea9415c 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c | |||
@@ -60,6 +60,7 @@ | |||
60 | #include "bookmark.h" | 60 | #include "bookmark.h" |
61 | #include "playlist.h" | 61 | #include "playlist.h" |
62 | #include "playlist_viewer.h" | 62 | #include "playlist_viewer.h" |
63 | #include "playlist_catalog.h" | ||
63 | #include "menus/exported_menus.h" | 64 | #include "menus/exported_menus.h" |
64 | #ifdef HAVE_RTC_ALARM | 65 | #ifdef HAVE_RTC_ALARM |
65 | #include "rtc.h" | 66 | #include "rtc.h" |
@@ -335,7 +336,21 @@ static int miscscrn(void * param) | |||
335 | return GO_TO_ROOT; | 336 | return GO_TO_ROOT; |
336 | } | 337 | } |
337 | } | 338 | } |
338 | 339 | ||
340 | |||
341 | static int playlist_view_catalog(void * param) | ||
342 | { | ||
343 | /* kludge untill catalog_view_playlists() returns something useful */ | ||
344 | int old_playstatus = audio_status(); | ||
345 | (void)param; | ||
346 | push_current_activity(ACTIVITY_PLAYLISTBROWSER); | ||
347 | catalog_view_playlists(); | ||
348 | pop_current_activity(); | ||
349 | if (!old_playstatus && audio_status()) | ||
350 | return GO_TO_WPS; | ||
351 | return GO_TO_PREVIOUS; | ||
352 | } | ||
353 | |||
339 | static int playlist_view(void * param) | 354 | static int playlist_view(void * param) |
340 | { | 355 | { |
341 | (void)param; | 356 | (void)param; |
@@ -397,9 +412,9 @@ static const struct root_items items[] = { | |||
397 | 412 | ||
398 | [GO_TO_RECENTBMARKS] = { load_bmarks, NULL, &bookmark_settings_menu }, | 413 | [GO_TO_RECENTBMARKS] = { load_bmarks, NULL, &bookmark_settings_menu }, |
399 | [GO_TO_BROWSEPLUGINS] = { miscscrn, &plugin_menu, NULL }, | 414 | [GO_TO_BROWSEPLUGINS] = { miscscrn, &plugin_menu, NULL }, |
400 | [GO_TO_PLAYLISTS_SCREEN] = { miscscrn, &playlist_options, | 415 | [GO_TO_PLAYLISTS_SCREEN] = { playlist_view_catalog, NULL, |
401 | &playlist_settings }, | 416 | &playlist_options }, |
402 | [GO_TO_PLAYLIST_VIEWER] = { playlist_view, NULL, NULL }, | 417 | [GO_TO_PLAYLIST_VIEWER] = { playlist_view, NULL, &playlist_options }, |
403 | [GO_TO_SYSTEM_SCREEN] = { miscscrn, &info_menu, &system_menu }, | 418 | [GO_TO_SYSTEM_SCREEN] = { miscscrn, &info_menu, &system_menu }, |
404 | 419 | ||
405 | }; | 420 | }; |
@@ -415,6 +430,10 @@ MENUITEM_RETURNVALUE(db_browser, ID2P(LANG_TAGCACHE), GO_TO_DBBROWSER, | |||
415 | #endif | 430 | #endif |
416 | MENUITEM_RETURNVALUE(rocks_browser, ID2P(LANG_PLUGINS), GO_TO_BROWSEPLUGINS, | 431 | MENUITEM_RETURNVALUE(rocks_browser, ID2P(LANG_PLUGINS), GO_TO_BROWSEPLUGINS, |
417 | NULL, Icon_Plugin); | 432 | NULL, Icon_Plugin); |
433 | |||
434 | MENUITEM_RETURNVALUE(playlist_browser, ID2P(LANG_CATALOG), GO_TO_PLAYLIST_VIEWER, | ||
435 | NULL, Icon_Playlist); | ||
436 | |||
418 | static char *get_wps_item_name(int selected_item, void * data, char *buffer) | 437 | static char *get_wps_item_name(int selected_item, void * data, char *buffer) |
419 | { | 438 | { |
420 | (void)selected_item; (void)data; (void)buffer; | 439 | (void)selected_item; (void)data; (void)buffer; |
@@ -437,7 +456,7 @@ MENUITEM_RETURNVALUE(menu_, ID2P(LANG_SETTINGS), GO_TO_MAINMENU, | |||
437 | MENUITEM_RETURNVALUE(bookmarks, ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), | 456 | MENUITEM_RETURNVALUE(bookmarks, ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), |
438 | GO_TO_RECENTBMARKS, item_callback, | 457 | GO_TO_RECENTBMARKS, item_callback, |
439 | Icon_Bookmark); | 458 | Icon_Bookmark); |
440 | MENUITEM_RETURNVALUE(playlists, ID2P(LANG_PLAYLISTS), GO_TO_PLAYLISTS_SCREEN, | 459 | MENUITEM_RETURNVALUE(playlists, ID2P(LANG_CATALOG), GO_TO_PLAYLISTS_SCREEN, |
441 | NULL, Icon_Playlist); | 460 | NULL, Icon_Playlist); |
442 | MENUITEM_RETURNVALUE(system_menu_, ID2P(LANG_SYSTEM), GO_TO_SYSTEM_SCREEN, | 461 | MENUITEM_RETURNVALUE(system_menu_, ID2P(LANG_SYSTEM), GO_TO_SYSTEM_SCREEN, |
443 | NULL, Icon_System_menu); | 462 | NULL, Icon_System_menu); |
diff --git a/apps/tree.c b/apps/tree.c index a9e6a6e840..f38edb2ae6 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -917,8 +917,15 @@ bool create_playlist(void) | |||
917 | { | 917 | { |
918 | char filename[MAX_PATH]; | 918 | char filename[MAX_PATH]; |
919 | 919 | ||
920 | snprintf(filename, sizeof filename, "%s.m3u8", | 920 | if (tc.currdir[1]) |
921 | tc.currdir[1] ? tc.currdir : "/root"); | 921 | snprintf(filename, sizeof filename, "%s.m3u8", tc.currdir); |
922 | else | ||
923 | snprintf(filename, sizeof filename, "%s/all.m3u8", | ||
924 | catalog_get_directory()); | ||
925 | |||
926 | |||
927 | if (kbd_input(filename, MAX_PATH)) | ||
928 | return false; | ||
922 | splashf(0, "%s %s", str(LANG_CREATING), filename); | 929 | splashf(0, "%s %s", str(LANG_CREATING), filename); |
923 | 930 | ||
924 | trigger_cpu_boost(); | 931 | trigger_cpu_boost(); |