diff options
-rw-r--r-- | apps/lang/english.lang | 14 | ||||
-rw-r--r-- | apps/onplay.c | 5 | ||||
-rw-r--r-- | apps/playlist.c | 52 | ||||
-rw-r--r-- | apps/playlist.h | 4 | ||||
-rw-r--r-- | apps/tagtree.c | 6 | ||||
-rw-r--r-- | docs/CREDITS | 1 |
6 files changed, 80 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 @@ | |||
10442 | *: "Clear Time?" | 10442 | *: "Clear Time?" |
10443 | </voice> | 10443 | </voice> |
10444 | </phrase> | 10444 | </phrase> |
10445 | <phrase> | ||
10446 | id: LANG_REPLACE | ||
10447 | desc: in onplay menu. Replace the current playlist with a new one. | ||
10448 | user: | ||
10449 | <source> | ||
10450 | *: "Play Next" | ||
10451 | </source> | ||
10452 | <dest> | ||
10453 | *: "Play Next" | ||
10454 | </dest> | ||
10455 | <voice> | ||
10456 | *: "Play Next" | ||
10457 | </voice> | ||
10458 | </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) | |||
368 | args[i].position = PLAYLIST_INSERT_SHUFFLED; | 368 | args[i].position = PLAYLIST_INSERT_SHUFFLED; |
369 | args[i].queue = true; | 369 | args[i].queue = true; |
370 | i++; | 370 | i++; |
371 | |||
372 | items[i].desc = ID2P(LANG_REPLACE); | ||
373 | args[i].position = PLAYLIST_REPLACE; | ||
374 | args[i].queue = false; | ||
375 | i++; | ||
371 | } | 376 | } |
372 | else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || | 377 | else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || |
373 | (selected_file_attr & ATTR_DIRECTORY)) | 378 | (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: | |||
561 | } | 561 | } |
562 | 562 | ||
563 | /* | 563 | /* |
564 | * Removes all tracks, from the playlist, leaving the presently playing | ||
565 | * track queued. | ||
566 | */ | ||
567 | int remove_all_tracks(struct playlist_info *playlist) | ||
568 | { | ||
569 | int result; | ||
570 | |||
571 | if (playlist == NULL) | ||
572 | playlist = ¤t_playlist; | ||
573 | |||
574 | while (playlist->index > 0) | ||
575 | if ((result = remove_track_from_playlist(playlist, 0, true)) < 0) | ||
576 | return result; | ||
577 | |||
578 | while (playlist->amount > 1) | ||
579 | if ((result = remove_track_from_playlist(playlist, 1, true)) < 0) | ||
580 | return result; | ||
581 | |||
582 | if (playlist->amount == 1) { | ||
583 | playlist->indices[0] |= PLAYLIST_QUEUED; | ||
584 | } | ||
585 | |||
586 | return 0; | ||
587 | } | ||
588 | |||
589 | |||
590 | /* | ||
564 | * Add track to playlist at specified position. There are five special | 591 | * Add track to playlist at specified position. There are five special |
565 | * positions that can be specified: | 592 | * positions that can be specified: |
566 | * PLAYLIST_PREPEND - Add track at beginning of playlist | 593 | * PLAYLIST_PREPEND - Add track at beginning of playlist |
@@ -572,6 +599,8 @@ exit: | |||
572 | * PLAYLIST_INSERT_LAST - Add track to end of playlist | 599 | * PLAYLIST_INSERT_LAST - Add track to end of playlist |
573 | * PLAYLIST_INSERT_SHUFFLED - Add track at some random point between the | 600 | * PLAYLIST_INSERT_SHUFFLED - Add track at some random point between the |
574 | * current playing track and end of playlist | 601 | * current playing track and end of playlist |
602 | * PLAYLIST_REPLACE - Erase current playlist, Cue the current track | ||
603 | * and inster this track at the end. | ||
575 | */ | 604 | */ |
576 | static int add_track_to_playlist(struct playlist_info* playlist, | 605 | static int add_track_to_playlist(struct playlist_info* playlist, |
577 | const char *filename, int position, | 606 | const char *filename, int position, |
@@ -648,6 +677,12 @@ static int add_track_to_playlist(struct playlist_info* playlist, | |||
648 | position = insert_position = (rand() % (playlist->amount+1)); | 677 | position = insert_position = (rand() % (playlist->amount+1)); |
649 | break; | 678 | break; |
650 | } | 679 | } |
680 | case PLAYLIST_REPLACE: | ||
681 | if (remove_all_tracks(playlist) < 0) | ||
682 | return -1; | ||
683 | |||
684 | position = insert_position = playlist->index + 1; | ||
685 | break; | ||
651 | } | 686 | } |
652 | 687 | ||
653 | if (queue) | 688 | if (queue) |
@@ -2860,6 +2895,14 @@ int playlist_insert_directory(struct playlist_info* playlist, | |||
2860 | return -1; | 2895 | return -1; |
2861 | } | 2896 | } |
2862 | 2897 | ||
2898 | if (position == PLAYLIST_REPLACE) | ||
2899 | { | ||
2900 | if (remove_all_tracks(playlist) == 0) | ||
2901 | position = PLAYLIST_INSERT_LAST; | ||
2902 | else | ||
2903 | return -1; | ||
2904 | } | ||
2905 | |||
2863 | if (queue) | 2906 | if (queue) |
2864 | count_str = str(LANG_PLAYLIST_QUEUE_COUNT); | 2907 | count_str = str(LANG_PLAYLIST_QUEUE_COUNT); |
2865 | else | 2908 | else |
@@ -2871,7 +2914,7 @@ int playlist_insert_directory(struct playlist_info* playlist, | |||
2871 | context.position = position; | 2914 | context.position = position; |
2872 | context.queue = queue; | 2915 | context.queue = queue; |
2873 | context.count = 0; | 2916 | context.count = 0; |
2874 | 2917 | ||
2875 | cpu_boost(true); | 2918 | cpu_boost(true); |
2876 | 2919 | ||
2877 | result = playlist_directory_tracksearch(dirname, recurse, | 2920 | result = playlist_directory_tracksearch(dirname, recurse, |
@@ -2941,6 +2984,13 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename, | |||
2941 | 2984 | ||
2942 | display_playlist_count(count, count_str); | 2985 | display_playlist_count(count, count_str); |
2943 | 2986 | ||
2987 | if (position == PLAYLIST_REPLACE) | ||
2988 | { | ||
2989 | if (remove_all_tracks(playlist) == 0) | ||
2990 | position = PLAYLIST_INSERT_LAST; | ||
2991 | else return -1; | ||
2992 | } | ||
2993 | |||
2944 | cpu_boost(true); | 2994 | cpu_boost(true); |
2945 | 2995 | ||
2946 | while ((max = read_line(fd, temp_buf, sizeof(temp_buf))) > 0) | 2996 | 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 { | |||
48 | PLAYLIST_INSERT = -2, | 48 | PLAYLIST_INSERT = -2, |
49 | PLAYLIST_INSERT_LAST = -3, | 49 | PLAYLIST_INSERT_LAST = -3, |
50 | PLAYLIST_INSERT_FIRST = -4, | 50 | PLAYLIST_INSERT_FIRST = -4, |
51 | PLAYLIST_INSERT_SHUFFLED = -5 | 51 | PLAYLIST_INSERT_SHUFFLED = -5, |
52 | PLAYLIST_REPLACE = -6 | ||
52 | }; | 53 | }; |
53 | 54 | ||
54 | enum { | 55 | enum { |
@@ -163,5 +164,6 @@ int playlist_save(struct playlist_info* playlist, char *filename); | |||
163 | int playlist_directory_tracksearch(const char* dirname, bool recurse, | 164 | int playlist_directory_tracksearch(const char* dirname, bool recurse, |
164 | int (*callback)(char*, void*), | 165 | int (*callback)(char*, void*), |
165 | void* context); | 166 | void* context); |
167 | int remove_all_tracks(struct playlist_info *playlist); | ||
166 | 168 | ||
167 | #endif /* __PLAYLIST_H__ */ | 169 | #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 | |||
1468 | return false; | 1468 | return false; |
1469 | } | 1469 | } |
1470 | 1470 | ||
1471 | if (position == PLAYLIST_REPLACE) | ||
1472 | { | ||
1473 | if (remove_all_tracks(NULL) == 0) | ||
1474 | position = PLAYLIST_INSERT_LAST; | ||
1475 | else return -1; } | ||
1476 | |||
1471 | if (position == PLAYLIST_INSERT_FIRST) | 1477 | if (position == PLAYLIST_INSERT_FIRST) |
1472 | { | 1478 | { |
1473 | from = c->filesindir - 1; | 1479 | from = c->filesindir - 1; |
diff --git a/docs/CREDITS b/docs/CREDITS index 67770a9e82..9599d60d4b 100644 --- a/docs/CREDITS +++ b/docs/CREDITS | |||
@@ -256,3 +256,4 @@ Robert Carboneau | |||
256 | Ye Wei | 256 | Ye Wei |
257 | Bryan Childs | 257 | Bryan Childs |
258 | Mike Schmitt | 258 | Mike Schmitt |
259 | Chris Taylor | ||