Index: apps/onplay.c =================================================================== --- apps/onplay.c (revision 15026) +++ apps/onplay.c (working copy) @@ -158,7 +158,6 @@ static bool add_to_playlist(int position, bool queue) { - bool new_playlist = !(audio_status() & AUDIO_STATUS_PLAY); char *lines[] = { ID2P(LANG_RECURSE_DIRECTORY_QUESTION), selected_file @@ -166,9 +165,27 @@ struct text_message message={lines, 2}; gui_syncsplash(0, ID2P(LANG_WAIT)); - - if (new_playlist) + + bool have_list = audio_status() & (AUDIO_STATUS_PLAY | AUDIO_STATUS_PAUSE); + if (!have_list && position != PLAYLIST_REPLACE) + { + if (global_status.resume_index != -1) + { + /* Try to restore the list from control file */ + have_list = (playlist_resume() != -1); + } + if (!have_list && playlist_amount() > 0) + { + /*If dynamic playlist still exists, view it anyway even + if playback has reached the end of the playlist */ + have_list = true; + } + } + if (!have_list) + { playlist_create(NULL, NULL); + } + /* always set seed before inserting shuffled */ if (position == PLAYLIST_INSERT_SHUFFLED) @@ -203,17 +220,6 @@ playlist_insert_playlist(NULL, selected_file, position, queue); } - if (new_playlist && (playlist_amount() > 0)) - { - /* nothing is currently playing so begin playing what we just - inserted */ - if (global_settings.playlist_shuffle) - playlist_shuffle(current_tick, -1); - playlist_start(0,0); - gui_syncstatusbar_draw(&statusbars, false); - onplay_result = ONPLAY_START_PLAY; - } - return false; } @@ -312,39 +318,20 @@ add_to_playlist((intptr_t)param, true); return 0; } -static int treeplaylist_wplayback_callback(int action, - const struct menu_item_ex* - this_item) -{ - (void)this_item; - switch (action) - { - case ACTION_REQUEST_MENUITEM: - if (audio_status() & AUDIO_STATUS_PLAY) - return action; - else - return ACTION_EXIT_MENUITEM; - break; - } - return action; -} static int treeplaylist_callback(int action, const struct menu_item_ex *this_item); /* insert items */ -MENUITEM_FUNCTION(i_pl_item_no_play, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT), - playlist_insert_func, (intptr_t*)PLAYLIST_INSERT_LAST, - treeplaylist_callback, Icon_Playlist); MENUITEM_FUNCTION(i_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT), playlist_insert_func, (intptr_t*)PLAYLIST_INSERT, - treeplaylist_wplayback_callback, Icon_Playlist); + treeplaylist_callback, Icon_Playlist); MENUITEM_FUNCTION(i_first_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT_FIRST), playlist_insert_func, (intptr_t*)PLAYLIST_INSERT_FIRST, - treeplaylist_wplayback_callback, Icon_Playlist); + treeplaylist_callback, Icon_Playlist); MENUITEM_FUNCTION(i_last_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT_LAST), playlist_insert_func, (intptr_t*)PLAYLIST_INSERT_LAST, - treeplaylist_wplayback_callback, Icon_Playlist); + treeplaylist_callback, Icon_Playlist); MENUITEM_FUNCTION(i_shuf_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT_SHUFFLED), playlist_insert_func, (intptr_t*)PLAYLIST_INSERT_SHUFFLED, treeplaylist_callback, @@ -352,21 +339,21 @@ /* queue items */ MENUITEM_FUNCTION(q_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_QUEUE), playlist_queue_func, (intptr_t*)PLAYLIST_INSERT, - treeplaylist_wplayback_callback, Icon_Playlist); + treeplaylist_callback, Icon_Playlist); MENUITEM_FUNCTION(q_first_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_QUEUE_FIRST), playlist_queue_func, (intptr_t*)PLAYLIST_INSERT_FIRST, - treeplaylist_wplayback_callback, Icon_Playlist); + treeplaylist_callback, Icon_Playlist); MENUITEM_FUNCTION(q_last_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_QUEUE_LAST), playlist_queue_func, (intptr_t*)PLAYLIST_INSERT_LAST, - treeplaylist_wplayback_callback, Icon_Playlist); + treeplaylist_callback, Icon_Playlist); MENUITEM_FUNCTION(q_shuf_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_QUEUE_SHUFFLED), playlist_queue_func, (intptr_t*)PLAYLIST_INSERT_SHUFFLED, - treeplaylist_wplayback_callback, Icon_Playlist); + treeplaylist_callback, Icon_Playlist); /* replace playlist */ MENUITEM_FUNCTION(replace_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_REPLACE), playlist_insert_func, (intptr_t*)PLAYLIST_REPLACE, - treeplaylist_wplayback_callback, Icon_Playlist); + treeplaylist_callback, Icon_Playlist); /* others */ MENUITEM_FUNCTION(view_playlist_item, 0, ID2P(LANG_VIEW), @@ -380,7 +367,7 @@ &view_playlist_item, /* insert */ - &i_pl_item_no_play, &i_pl_item, &i_first_pl_item, + &i_pl_item, &i_first_pl_item, &i_last_pl_item, &i_shuf_pl_item, /* queue */ @@ -417,31 +404,6 @@ else return ACTION_EXIT_MENUITEM; } - else if (this_item == &i_pl_item_no_play) - { - if (!(audio_status() & AUDIO_STATUS_PLAY)) - { - return action; - } - else - return ACTION_EXIT_MENUITEM; - } - else if (this_item == &i_shuf_pl_item) - { - - if (audio_status() & AUDIO_STATUS_PLAY) - { - return action; - } - else if ((this_item == &i_shuf_pl_item) && - ((selected_file_attr & ATTR_DIRECTORY) || - ((selected_file_attr & FILE_ATTR_MASK) == - FILE_ATTR_M3U))) - { - return action; - } - return ACTION_EXIT_MENUITEM; - } break; } return action;