summaryrefslogtreecommitdiffstats
path: root/apps/menus/playlist_menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/menus/playlist_menu.c')
-rw-r--r--apps/menus/playlist_menu.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/apps/menus/playlist_menu.c b/apps/menus/playlist_menu.c
index 3122a4090f..b84abe0b37 100644
--- a/apps/menus/playlist_menu.c
+++ b/apps/menus/playlist_menu.c
@@ -38,9 +38,19 @@
#include "talk.h"
#include "playlist_catalog.h"
#include "splash.h"
+#include "filetree.h"
+/* load a screen to save the playlist passed in (or current playlist if NULL is passed) */
int save_playlist_screen(struct playlist_info* playlist)
{
+
+ char directoryonly[MAX_PATH+3];
+ char *filename;
+
+ int resume_index;
+ uint32_t resume_elapsed;
+ uint32_t resume_offset;
+
char temp[MAX_PATH+1], *dot;
int len;
@@ -71,6 +81,55 @@ int save_playlist_screen(struct playlist_info* playlist)
/* reload in case playlist was saved to cwd */
reload_directory();
+
+ /* only reload newly saved playlist if:
+ * playlist is null AND setting is turned on
+ *
+ * if playlist is null, we should be dealing with the current playlist,
+ * and thus we got here from the wps screen. That means we want to reload
+ * the current playlist so the user can make bookmarks. */
+ if ((global_settings.playlist_reload_after_save == true) &&
+ (playlist == NULL))
+ {
+
+ /* at least one slash exists in temp */
+ if (strrchr(temp, '/') != NULL)
+ {
+ filename = strrchr(temp, '/') + 1;
+
+ if (temp[0] == '/') /* most common situation - first char is a slash */
+ {
+ strcpy(directoryonly, temp);
+ directoryonly[filename - temp] = '\0';
+ } else /* there is a slash, but not at the beginning of temp - prepend one */
+ {
+ directoryonly[0] = '/';
+
+ strcpy(directoryonly+1, temp);
+ directoryonly[filename - temp + 1] = '\0';
+ }
+ } else /* temp doesn't contain any slashes, uncommon? */
+ {
+ directoryonly[0] = '/';
+ directoryonly[1] = '\0';
+ filename = temp;
+ }
+
+ /* can't trust index from id3 (don't know why), get it from playlist */
+ resume_index = playlist_get_current()->index;
+
+ struct mp3entry* id3 = audio_current_track();
+
+ /* record elapsed and offset so they don't change when we load new playlist */
+ resume_elapsed = id3->elapsed;
+ resume_offset = id3->offset;
+
+ ft_play_playlist(temp, directoryonly, filename, true);
+ playlist_start(resume_index, resume_elapsed, resume_offset);
+ }
+ /* cancelled out of name selection */
+ } else {
+ return 1;
}
return 0;
@@ -112,9 +171,10 @@ MAKE_MENU(viewer_settings_menu, ID2P(LANG_PLAYLISTVIEWER_SETTINGS),
MENUITEM_SETTING(warn_on_erase, &global_settings.warnon_erase_dynplaylist, NULL);
MENUITEM_SETTING(show_shuffled_adding_options, &global_settings.show_shuffled_adding_options, NULL);
MENUITEM_SETTING(show_queue_options, &global_settings.show_queue_options, NULL);
+MENUITEM_SETTING(playlist_reload_after_save, &global_settings.playlist_reload_after_save, NULL);
MAKE_MENU(currentplaylist_settings_menu, ID2P(LANG_CURRENT_PLAYLIST),
NULL, Icon_Playlist,
- &warn_on_erase, &show_shuffled_adding_options, &show_queue_options);
+ &warn_on_erase, &show_shuffled_adding_options, &show_queue_options, &playlist_reload_after_save);
MAKE_MENU(playlist_settings, ID2P(LANG_PLAYLISTS), NULL,
Icon_Playlist,