summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/lang/english.lang14
-rw-r--r--apps/onplay.c5
-rw-r--r--apps/playlist.c52
-rw-r--r--apps/playlist.h4
-rw-r--r--apps/tagtree.c6
5 files changed, 79 insertions, 2 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 6681639aaa..84dea29f1b 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -10442,3 +10442,17 @@
*: "Clear Time?"
</voice>
</phrase>
+<phrase>
+ id: LANG_REPLACE
+ desc: in onplay menu. Replace the current playlist with a new one.
+ user:
+ <source>
+ *: "Play Next"
+ </source>
+ <dest>
+ *: "Play Next"
+ </dest>
+ <voice>
+ *: "Play Next"
+ </voice>
+</phrase>
diff --git a/apps/onplay.c b/apps/onplay.c
index af6fa9cc57..98b1270b89 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -368,6 +368,11 @@ static bool playlist_options(void)
args[i].position = PLAYLIST_INSERT_SHUFFLED;
args[i].queue = true;
i++;
+
+ items[i].desc = ID2P(LANG_REPLACE);
+ args[i].position = PLAYLIST_REPLACE;
+ args[i].queue = false;
+ i++;
}
else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) ||
(selected_file_attr & ATTR_DIRECTORY))
diff --git a/apps/playlist.c b/apps/playlist.c
index e8f9d48ce0..27c8676b96 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -561,6 +561,33 @@ exit:
}
/*
+ * Removes all tracks, from the playlist, leaving the presently playing
+ * track queued.
+ */
+int remove_all_tracks(struct playlist_info *playlist)
+{
+ int result;
+
+ if (playlist == NULL)
+ playlist = &current_playlist;
+
+ while (playlist->index > 0)
+ if ((result = remove_track_from_playlist(playlist, 0, true)) < 0)
+ return result;
+
+ while (playlist->amount > 1)
+ if ((result = remove_track_from_playlist(playlist, 1, true)) < 0)
+ return result;
+
+ if (playlist->amount == 1) {
+ playlist->indices[0] |= PLAYLIST_QUEUED;
+ }
+
+ return 0;
+}
+
+
+/*
* Add track to playlist at specified position. There are five special
* positions that can be specified:
* PLAYLIST_PREPEND - Add track at beginning of playlist
@@ -572,6 +599,8 @@ exit:
* PLAYLIST_INSERT_LAST - Add track to end of playlist
* PLAYLIST_INSERT_SHUFFLED - Add track at some random point between the
* current playing track and end of playlist
+ * PLAYLIST_REPLACE - Erase current playlist, Cue the current track
+ * and inster this track at the end.
*/
static int add_track_to_playlist(struct playlist_info* playlist,
const char *filename, int position,
@@ -648,6 +677,12 @@ static int add_track_to_playlist(struct playlist_info* playlist,
position = insert_position = (rand() % (playlist->amount+1));
break;
}
+ case PLAYLIST_REPLACE:
+ if (remove_all_tracks(playlist) < 0)
+ return -1;
+
+ position = insert_position = playlist->index + 1;
+ break;
}
if (queue)
@@ -2860,6 +2895,14 @@ int playlist_insert_directory(struct playlist_info* playlist,
return -1;
}
+ if (position == PLAYLIST_REPLACE)
+ {
+ if (remove_all_tracks(playlist) == 0)
+ position = PLAYLIST_INSERT_LAST;
+ else
+ return -1;
+ }
+
if (queue)
count_str = str(LANG_PLAYLIST_QUEUE_COUNT);
else
@@ -2871,7 +2914,7 @@ int playlist_insert_directory(struct playlist_info* playlist,
context.position = position;
context.queue = queue;
context.count = 0;
-
+
cpu_boost(true);
result = playlist_directory_tracksearch(dirname, recurse,
@@ -2941,6 +2984,13 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
display_playlist_count(count, count_str);
+ if (position == PLAYLIST_REPLACE)
+ {
+ if (remove_all_tracks(playlist) == 0)
+ position = PLAYLIST_INSERT_LAST;
+ else return -1;
+ }
+
cpu_boost(true);
while ((max = read_line(fd, temp_buf, sizeof(temp_buf))) > 0)
diff --git a/apps/playlist.h b/apps/playlist.h
index 3270bc55fa..af9a09523f 100644
--- a/apps/playlist.h
+++ b/apps/playlist.h
@@ -48,7 +48,8 @@ enum {
PLAYLIST_INSERT = -2,
PLAYLIST_INSERT_LAST = -3,
PLAYLIST_INSERT_FIRST = -4,
- PLAYLIST_INSERT_SHUFFLED = -5
+ PLAYLIST_INSERT_SHUFFLED = -5,
+ PLAYLIST_REPLACE = -6
};
enum {
@@ -163,5 +164,6 @@ int playlist_save(struct playlist_info* playlist, char *filename);
int playlist_directory_tracksearch(const char* dirname, bool recurse,
int (*callback)(char*, void*),
void* context);
+int remove_all_tracks(struct playlist_info *playlist);
#endif /* __PLAYLIST_H__ */
diff --git a/apps/tagtree.c b/apps/tagtree.c
index d75b9eb667..d5d70ac206 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -1468,6 +1468,12 @@ static bool insert_all_playlist(struct tree_context *c, int position, bool queue
return false;
}
+ if (position == PLAYLIST_REPLACE)
+ {
+ if (remove_all_tracks(NULL) == 0)
+ position = PLAYLIST_INSERT_LAST;
+ else return -1; }
+
if (position == PLAYLIST_INSERT_FIRST)
{
from = c->filesindir - 1;