summaryrefslogtreecommitdiff
path: root/apps/menus
diff options
context:
space:
mode:
authorDana Conrad <dconrad@fastmail.com>2021-04-18 13:00:41 -0500
committerSolomon Peachy <pizza@shaftnet.org>2021-05-03 20:10:27 +0000
commit4f83e66cd4e00bfa225f54b2c314a3d42d09ca7a (patch)
tree186717c39b55272249efc681091912a49e4872f2 /apps/menus
parent49edfc237ba9ae27eee5e915e86989d9ee01b1da (diff)
FS#13287 - Load a newly saved playlist and resume where it was
Works from any playlist saving operation accessed from the While Playing Screen, all other playlist saving operations are unchanged. Now a user-selectable setting! Located in General Settings -> Playlists -> Current Playlist -> Reload After Saving (Yes/No) Change-Id: I5085c3f4c56c518a812d5ee015d15cc4dca19a28
Diffstat (limited to 'apps/menus')
-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,