Index: apps/playlist.c =================================================================== --- apps/playlist.c (revision 23340) +++ apps/playlist.c (working copy) @@ -751,8 +751,15 @@ } else position = insert_position = (rand() % (playlist->amount+1)); + break; } + case PLAYLIST_INSERT_LAST_SHUFFLED: + { + position = insert_position = playlist->last_shuffled_start + + rand() % (playlist->amount - playlist->last_shuffled_start + 1); + break; + } case PLAYLIST_REPLACE: if (playlist_remove_all_tracks(playlist) < 0) return -1; @@ -2639,7 +2646,13 @@ { return playlist_amount_ex(NULL); } - +/* set playlist->last_shuffle_start to playlist->amount for + PLAYLIST_INSERT_LAST_SHUFFLED command purposes*/ +void playlist_set_last_shuffled_start(void) +{ + struct playlist_info* playlist = ¤t_playlist; + playlist->last_shuffled_start = playlist->amount; +} /* * Create a new playlist If playlist is not NULL then we're loading a * playlist off disk for viewing/editing. The index_buffer is used to store Index: apps/playlist.h =================================================================== --- apps/playlist.h (revision 23340) +++ apps/playlist.h (working copy) @@ -53,7 +53,8 @@ PLAYLIST_INSERT_LAST = -3, PLAYLIST_INSERT_FIRST = -4, PLAYLIST_INSERT_SHUFFLED = -5, - PLAYLIST_REPLACE = -6 + PLAYLIST_REPLACE = -6, + PLAYLIST_INSERT_LAST_SHUFFLED = -7 }; enum { @@ -105,6 +106,8 @@ bool pending_control_sync; /* control file needs to be synced */ struct mutex control_mutex; /* mutex for control file access */ + int last_shuffled_start; /* number of tracks when insert last + shuffled command start */ }; struct playlist_track_info @@ -131,6 +134,7 @@ int playlist_update_resume_info(const struct mp3entry* id3); int playlist_get_display_index(void); int playlist_amount(void); +void playlist_set_last_shuffled_start(void); /* Exported functions for all playlists. Pass NULL for playlist_info structure to work with current playlist. */ Index: apps/lang/english.lang =================================================================== --- apps/lang/english.lang (revision 23340) +++ apps/lang/english.lang (working copy) @@ -13182,3 +13182,31 @@ usb_hid: "USB Human Interface Device" + + id: LANG_INSERT_LAST_SHUFFLED + desc: in onplay menu. insert a playlist randomly at end of dynamic playlist + user: core + + *: "Insert Last Shuffled" + + + *: "Insert Last Shuffled" + + + *: "Insert Last Shuffled" + + + + id: LANG_QUEUE_LAST_SHUFFLED + desc: in onplay menu. queue a playlist randomly at and of dynamic playlist + user: core + + *: "Queue Last Shuffled" + + + *: "Queue Last Shuffled" + + + *: "Queue Last Shuffled" + + Index: apps/onplay.c =================================================================== --- apps/onplay.c (revision 23340) +++ apps/onplay.c (working copy) @@ -173,8 +173,12 @@ playlist_create(NULL, NULL); /* always set seed before inserting shuffled */ - if (position == PLAYLIST_INSERT_SHUFFLED) + if (position == PLAYLIST_INSERT_SHUFFLED || position == PLAYLIST_INSERT_LAST_SHUFFLED) + { srand(current_tick); + if (position == PLAYLIST_INSERT_LAST_SHUFFLED) + playlist_set_last_shuffled_start(); + } #ifdef HAVE_TAGCACHE if (context == CONTEXT_ID3DB) @@ -355,6 +359,10 @@ ID2P(LANG_INSERT_SHUFFLED), playlist_insert_func, (intptr_t*)PLAYLIST_INSERT_SHUFFLED, treeplaylist_callback, Icon_Playlist); +MENUITEM_FUNCTION(i_last_shuf_pl_item, MENU_FUNC_USEPARAM, + ID2P(LANG_INSERT_LAST_SHUFFLED), playlist_insert_func, + (intptr_t*)PLAYLIST_INSERT_LAST_SHUFFLED, treeplaylist_callback, + Icon_Playlist); /* queue items */ MENUITEM_FUNCTION(q_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_QUEUE), playlist_queue_func, (intptr_t*)PLAYLIST_INSERT, @@ -369,6 +377,10 @@ ID2P(LANG_QUEUE_SHUFFLED), playlist_queue_func, (intptr_t*)PLAYLIST_INSERT_SHUFFLED, treeplaylist_wplayback_callback, Icon_Playlist); +MENUITEM_FUNCTION(q_last_shuf_pl_item, MENU_FUNC_USEPARAM, + ID2P(LANG_QUEUE_LAST_SHUFFLED), playlist_queue_func, + (intptr_t*)PLAYLIST_INSERT_LAST_SHUFFLED, + treeplaylist_callback, Icon_Playlist); /* replace playlist */ MENUITEM_FUNCTION(replace_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_REPLACE), playlist_insert_func, (intptr_t*)PLAYLIST_REPLACE, @@ -388,10 +400,12 @@ /* insert */ &i_pl_item, &i_first_pl_item, &i_last_pl_item, &i_shuf_pl_item, + &i_last_shuf_pl_item, /* queue */ &q_pl_item, &q_first_pl_item, &q_last_pl_item, &q_shuf_pl_item, + &q_last_shuf_pl_item, /* replace */ &replace_pl_item @@ -439,6 +453,15 @@ } return ACTION_EXIT_MENUITEM; } + else if (this_item == &i_last_shuf_pl_item || this_item == &q_last_shuf_pl_item) + { + if ((playlist_amount() > 0) && (audio_status() & AUDIO_STATUS_PLAY)) + { + return action; + } + else + return ACTION_EXIT_MENUITEM; + } break; } return action;