summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/lang/english.lang28
-rw-r--r--apps/onplay.c25
-rw-r--r--apps/playlist.c40
-rw-r--r--apps/playlist.h6
-rw-r--r--manual/working_with_playlists/main.tex6
5 files changed, 89 insertions, 16 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index d7dba2f3c0..e7e3acde0b 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -13182,3 +13182,31 @@
13182 usb_hid: "USB Human Interface Device" 13182 usb_hid: "USB Human Interface Device"
13183 </voice> 13183 </voice>
13184</phrase> 13184</phrase>
13185<phrase>
13186 id: LANG_INSERT_LAST_SHUFFLED
13187 desc: in onplay menu. insert a playlist randomly at end of dynamic playlist
13188 user: core
13189 <source>
13190 *: "Insert Last Shuffled"
13191 </source>
13192 <dest>
13193 *: "Insert Last Shuffled"
13194 </dest>
13195 <voice>
13196 *: "Insert Last Shuffled"
13197 </voice>
13198</phrase>
13199<phrase>
13200 id: LANG_QUEUE_LAST_SHUFFLED
13201 desc: in onplay menu. queue a playlist randomly at and of dynamic playlist
13202 user: core
13203 <source>
13204 *: "Queue Last Shuffled"
13205 </source>
13206 <dest>
13207 *: "Queue Last Shuffled"
13208 </dest>
13209 <voice>
13210 *: "Queue Last Shuffled"
13211 </voice>
13212</phrase>
diff --git a/apps/onplay.c b/apps/onplay.c
index 28bf7de8ae..7ad22d5d70 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -173,8 +173,12 @@ static bool add_to_playlist(int position, bool queue)
173 playlist_create(NULL, NULL); 173 playlist_create(NULL, NULL);
174 174
175 /* always set seed before inserting shuffled */ 175 /* always set seed before inserting shuffled */
176 if (position == PLAYLIST_INSERT_SHUFFLED) 176 if (position == PLAYLIST_INSERT_SHUFFLED || position == PLAYLIST_INSERT_LAST_SHUFFLED)
177 {
177 srand(current_tick); 178 srand(current_tick);
179 if (position == PLAYLIST_INSERT_LAST_SHUFFLED)
180 playlist_set_last_shuffled_start();
181 }
178 182
179#ifdef HAVE_TAGCACHE 183#ifdef HAVE_TAGCACHE
180 if (context == CONTEXT_ID3DB) 184 if (context == CONTEXT_ID3DB)
@@ -355,6 +359,10 @@ MENUITEM_FUNCTION(i_shuf_pl_item, MENU_FUNC_USEPARAM,
355 ID2P(LANG_INSERT_SHUFFLED), playlist_insert_func, 359 ID2P(LANG_INSERT_SHUFFLED), playlist_insert_func,
356 (intptr_t*)PLAYLIST_INSERT_SHUFFLED, treeplaylist_callback, 360 (intptr_t*)PLAYLIST_INSERT_SHUFFLED, treeplaylist_callback,
357 Icon_Playlist); 361 Icon_Playlist);
362MENUITEM_FUNCTION(i_last_shuf_pl_item, MENU_FUNC_USEPARAM,
363 ID2P(LANG_INSERT_LAST_SHUFFLED), playlist_insert_func,
364 (intptr_t*)PLAYLIST_INSERT_LAST_SHUFFLED, treeplaylist_callback,
365 Icon_Playlist);
358/* queue items */ 366/* queue items */
359MENUITEM_FUNCTION(q_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_QUEUE), 367MENUITEM_FUNCTION(q_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_QUEUE),
360 playlist_queue_func, (intptr_t*)PLAYLIST_INSERT, 368 playlist_queue_func, (intptr_t*)PLAYLIST_INSERT,
@@ -369,6 +377,10 @@ MENUITEM_FUNCTION(q_shuf_pl_item, MENU_FUNC_USEPARAM,
369 ID2P(LANG_QUEUE_SHUFFLED), playlist_queue_func, 377 ID2P(LANG_QUEUE_SHUFFLED), playlist_queue_func,
370 (intptr_t*)PLAYLIST_INSERT_SHUFFLED, 378 (intptr_t*)PLAYLIST_INSERT_SHUFFLED,
371 treeplaylist_wplayback_callback, Icon_Playlist); 379 treeplaylist_wplayback_callback, Icon_Playlist);
380MENUITEM_FUNCTION(q_last_shuf_pl_item, MENU_FUNC_USEPARAM,
381 ID2P(LANG_QUEUE_LAST_SHUFFLED), playlist_queue_func,
382 (intptr_t*)PLAYLIST_INSERT_LAST_SHUFFLED,
383 treeplaylist_callback, Icon_Playlist);
372/* replace playlist */ 384/* replace playlist */
373MENUITEM_FUNCTION(replace_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_REPLACE), 385MENUITEM_FUNCTION(replace_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_REPLACE),
374 playlist_insert_func, (intptr_t*)PLAYLIST_REPLACE, 386 playlist_insert_func, (intptr_t*)PLAYLIST_REPLACE,
@@ -388,10 +400,12 @@ MAKE_ONPLAYMENU( tree_playlist_menu, ID2P(LANG_PLAYLIST),
388 /* insert */ 400 /* insert */
389 &i_pl_item, &i_first_pl_item, 401 &i_pl_item, &i_first_pl_item,
390 &i_last_pl_item, &i_shuf_pl_item, 402 &i_last_pl_item, &i_shuf_pl_item,
403 &i_last_shuf_pl_item,
391 404
392 /* queue */ 405 /* queue */
393 &q_pl_item, &q_first_pl_item, &q_last_pl_item, 406 &q_pl_item, &q_first_pl_item, &q_last_pl_item,
394 &q_shuf_pl_item, 407 &q_shuf_pl_item,
408 &q_last_shuf_pl_item,
395 409
396 /* replace */ 410 /* replace */
397 &replace_pl_item 411 &replace_pl_item
@@ -439,6 +453,15 @@ static int treeplaylist_callback(int action,
439 } 453 }
440 return ACTION_EXIT_MENUITEM; 454 return ACTION_EXIT_MENUITEM;
441 } 455 }
456 else if (this_item == &i_last_shuf_pl_item || this_item == &q_last_shuf_pl_item)
457 {
458 if ((playlist_amount() > 0) && (audio_status() & AUDIO_STATUS_PLAY) && (selected_file_attr & ATTR_DIRECTORY))
459 {
460 return action;
461 }
462 else
463 return ACTION_EXIT_MENUITEM;
464 }
442 break; 465 break;
443 } 466 }
444 return action; 467 return action;
diff --git a/apps/playlist.c b/apps/playlist.c
index 1e96ebf46b..0c4fe9785b 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -664,19 +664,21 @@ int playlist_remove_all_tracks(struct playlist_info *playlist)
664 664
665 665
666/* 666/*
667 * Add track to playlist at specified position. There are five special 667 * Add track to playlist at specified position. There are seven special
668 * positions that can be specified: 668 * positions that can be specified:
669 * PLAYLIST_PREPEND - Add track at beginning of playlist 669 * PLAYLIST_PREPEND - Add track at beginning of playlist
670 * PLAYLIST_INSERT - Add track after current song. NOTE: If 670 * PLAYLIST_INSERT - Add track after current song. NOTE: If
671 * there are already inserted tracks then track 671 * there are already inserted tracks then track
672 * is added to the end of the insertion list 672 * is added to the end of the insertion list
673 * PLAYLIST_INSERT_FIRST - Add track immediately after current song, no 673 * PLAYLIST_INSERT_FIRST - Add track immediately after current song, no
674 * matter what other tracks have been inserted 674 * matter what other tracks have been inserted
675 * PLAYLIST_INSERT_LAST - Add track to end of playlist 675 * PLAYLIST_INSERT_LAST - Add track to end of playlist
676 * PLAYLIST_INSERT_SHUFFLED - Add track at some random point between the 676 * PLAYLIST_INSERT_SHUFFLED - Add track at some random point between the
677 * current playing track and end of playlist 677 * current playing track and end of playlist
678 * PLAYLIST_REPLACE - Erase current playlist, Cue the current track 678 * PLAYLIST_INSERT_LAST_SHUFFLED - Add tracks in random order to the end of
679 * and inster this track at the end. 679 * the playlist.
680 * PLAYLIST_REPLACE - Erase current playlist, Cue the current track
681 * and inster this track at the end.
680 */ 682 */
681static int add_track_to_playlist(struct playlist_info* playlist, 683static int add_track_to_playlist(struct playlist_info* playlist,
682 const char *filename, int position, 684 const char *filename, int position,
@@ -753,6 +755,12 @@ static int add_track_to_playlist(struct playlist_info* playlist,
753 position = insert_position = (rand() % (playlist->amount+1)); 755 position = insert_position = (rand() % (playlist->amount+1));
754 break; 756 break;
755 } 757 }
758 case PLAYLIST_INSERT_LAST_SHUFFLED:
759 {
760 position = insert_position = playlist->last_shuffled_start +
761 rand() % (playlist->amount - playlist->last_shuffled_start + 1);
762 break;
763 }
756 case PLAYLIST_REPLACE: 764 case PLAYLIST_REPLACE:
757 if (playlist_remove_all_tracks(playlist) < 0) 765 if (playlist_remove_all_tracks(playlist) < 0)
758 return -1; 766 return -1;
@@ -2639,7 +2647,13 @@ int playlist_amount(void)
2639{ 2647{
2640 return playlist_amount_ex(NULL); 2648 return playlist_amount_ex(NULL);
2641} 2649}
2642 2650/* set playlist->last_shuffle_start to playlist->amount for
2651 PLAYLIST_INSERT_LAST_SHUFFLED command purposes*/
2652void playlist_set_last_shuffled_start(void)
2653{
2654 struct playlist_info* playlist = &current_playlist;
2655 playlist->last_shuffled_start = playlist->amount;
2656}
2643/* 2657/*
2644 * Create a new playlist If playlist is not NULL then we're loading a 2658 * Create a new playlist If playlist is not NULL then we're loading a
2645 * playlist off disk for viewing/editing. The index_buffer is used to store 2659 * playlist off disk for viewing/editing. The index_buffer is used to store
diff --git a/apps/playlist.h b/apps/playlist.h
index 4f7b9cff3a..fa234f6c12 100644
--- a/apps/playlist.h
+++ b/apps/playlist.h
@@ -53,7 +53,8 @@ enum {
53 PLAYLIST_INSERT_LAST = -3, 53 PLAYLIST_INSERT_LAST = -3,
54 PLAYLIST_INSERT_FIRST = -4, 54 PLAYLIST_INSERT_FIRST = -4,
55 PLAYLIST_INSERT_SHUFFLED = -5, 55 PLAYLIST_INSERT_SHUFFLED = -5,
56 PLAYLIST_REPLACE = -6 56 PLAYLIST_REPLACE = -6,
57 PLAYLIST_INSERT_LAST_SHUFFLED = -7
57}; 58};
58 59
59enum { 60enum {
@@ -105,6 +106,8 @@ struct playlist_info
105 bool pending_control_sync; /* control file needs to be synced */ 106 bool pending_control_sync; /* control file needs to be synced */
106 107
107 struct mutex control_mutex; /* mutex for control file access */ 108 struct mutex control_mutex; /* mutex for control file access */
109 int last_shuffled_start; /* number of tracks when insert last
110 shuffled command start */
108}; 111};
109 112
110struct playlist_track_info 113struct playlist_track_info
@@ -131,6 +134,7 @@ int playlist_get_resume_info(int *resume_index);
131int playlist_update_resume_info(const struct mp3entry* id3); 134int playlist_update_resume_info(const struct mp3entry* id3);
132int playlist_get_display_index(void); 135int playlist_get_display_index(void);
133int playlist_amount(void); 136int playlist_amount(void);
137void playlist_set_last_shuffled_start(void);
134 138
135/* Exported functions for all playlists. Pass NULL for playlist_info 139/* Exported functions for all playlists. Pass NULL for playlist_info
136 structure to work with current playlist. */ 140 structure to work with current playlist. */
diff --git a/manual/working_with_playlists/main.tex b/manual/working_with_playlists/main.tex
index 96781e0324..311aa86071 100644
--- a/manual/working_with_playlists/main.tex
+++ b/manual/working_with_playlists/main.tex
@@ -100,7 +100,9 @@ options:
100\item [Insert Last.] Add track(s) to end of playlist. 100\item [Insert Last.] Add track(s) to end of playlist.
101 101
102\item [Insert Shuffled.] Add track(s) to the playlist in a random order. 102\item [Insert Shuffled.] Add track(s) to the playlist in a random order.
103 103
104\item [Insert Last Shuffled.] Add tracks in a random order to the end of the playlist.
105
104\item [Queue.] Queue is the same as Insert except queued tracks are 106\item [Queue.] Queue is the same as Insert except queued tracks are
105 deleted immediately from the playlist after they have been played. Also, 107 deleted immediately from the playlist after they have been played. Also,
106 queued tracks are not saved to the playlist file (see 108 queued tracks are not saved to the playlist file (see
@@ -112,6 +114,8 @@ options:
112 114
113\item [Queue Shuffled.] Queue track(s) in a random order. 115\item [Queue Shuffled.] Queue track(s) in a random order.
114 116
117\item [Queue Last Shuffled.] Queue tracks in a random order at the end of the playlist.
118
115\item [Play Next.] Replaces all but the current playing track with track(s). 119\item [Play Next.] Replaces all but the current playing track with track(s).
116 Current playing track is queued. 120 Current playing track is queued.
117\end{description} 121\end{description}