diff options
-rw-r--r-- | apps/lang/english.lang | 12 | ||||
-rw-r--r-- | apps/onplay.c | 9 | ||||
-rw-r--r-- | apps/playlist_viewer.c | 110 | ||||
-rw-r--r-- | apps/playlist_viewer.h | 1 |
4 files changed, 130 insertions, 2 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index efb0a942f9..bc355f00e3 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang | |||
@@ -3784,3 +3784,15 @@ desc: splash when user selects an invalid colour | |||
3784 | eng: "Invalid colour" | 3784 | eng: "Invalid colour" |
3785 | voice: "" | 3785 | voice: "" |
3786 | new: | 3786 | new: |
3787 | |||
3788 | id: LANG_SEARCH_IN_PLAYLIST | ||
3789 | desc: in playlist menu. | ||
3790 | eng: "Search In Playlist" | ||
3791 | voice: | ||
3792 | new: | ||
3793 | |||
3794 | id: LANG_PLAYLIST_SEARCH_MSG | ||
3795 | desc: splash number of tracks inserted | ||
3796 | eng: "Searching... %d found (%s)" | ||
3797 | voice: "" | ||
3798 | new: | ||
diff --git a/apps/onplay.c b/apps/onplay.c index 88607f7754..be11b9a2da 100644 --- a/apps/onplay.c +++ b/apps/onplay.c | |||
@@ -243,8 +243,8 @@ static bool view_playlist(void) | |||
243 | /* Sub-menu for playlist options */ | 243 | /* Sub-menu for playlist options */ |
244 | static bool playlist_options(void) | 244 | static bool playlist_options(void) |
245 | { | 245 | { |
246 | struct menu_item items[12]; | 246 | struct menu_item items[13]; |
247 | struct playlist_args args[12]; /* increase these 2 if you add entries! */ | 247 | struct playlist_args args[13]; /* increase these 2 if you add entries! */ |
248 | int m, i=0, pstart=0, result; | 248 | int m, i=0, pstart=0, result; |
249 | bool ret = false; | 249 | bool ret = false; |
250 | 250 | ||
@@ -265,6 +265,11 @@ static bool playlist_options(void) | |||
265 | i++; | 265 | i++; |
266 | pstart++; | 266 | pstart++; |
267 | 267 | ||
268 | items[i].desc = ID2P(LANG_SEARCH_IN_PLAYLIST); | ||
269 | items[i].function = search_playlist; | ||
270 | i++; | ||
271 | pstart++; | ||
272 | |||
268 | items[i].desc = ID2P(LANG_SAVE_DYNAMIC_PLAYLIST); | 273 | items[i].desc = ID2P(LANG_SAVE_DYNAMIC_PLAYLIST); |
269 | items[i].function = save_playlist; | 274 | items[i].function = save_playlist; |
270 | i++; | 275 | i++; |
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index ddc238cb27..422c0047ff 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c | |||
@@ -804,3 +804,113 @@ exit: | |||
804 | playlist_close(viewer.playlist); | 804 | playlist_close(viewer.playlist); |
805 | return ret; | 805 | return ret; |
806 | } | 806 | } |
807 | char * playlist_search_callback_name(int selected_item, void * data, char *buffer) | ||
808 | { | ||
809 | int *found_indicies = (int*)data; | ||
810 | static struct playlist_track_info track; | ||
811 | playlist_get_track_info(viewer.playlist,found_indicies[selected_item],&track); | ||
812 | format_name(buffer,track.filename); | ||
813 | return(buffer); | ||
814 | } | ||
815 | |||
816 | |||
817 | void playlist_search_callback_icons(int selected_item, void * data, ICON * icon) | ||
818 | { | ||
819 | (void)selected_item; | ||
820 | (void)data; | ||
821 | #ifdef HAVE_LCD_BITMAP | ||
822 | *icon=0; | ||
823 | #else | ||
824 | *icon=-1; | ||
825 | #endif | ||
826 | } | ||
827 | bool search_playlist(void) | ||
828 | { | ||
829 | char search_str[32] = ""; | ||
830 | bool ret = false, exit = false; | ||
831 | int i, playlist_count; | ||
832 | int found_indicies[MAX_PLAYLIST_ENTRIES],found_indicies_count = 0; | ||
833 | int button; | ||
834 | struct gui_synclist playlist_lists; | ||
835 | struct playlist_track_info track; | ||
836 | |||
837 | if (!playlist_viewer_init(&viewer, 0, false)) | ||
838 | return ret; | ||
839 | if (kbd_input(search_str,sizeof(search_str)) == -1) | ||
840 | return ret; | ||
841 | lcd_clear_display(); | ||
842 | playlist_count = playlist_amount_ex(viewer.playlist); | ||
843 | for (i=0;(i<playlist_count)&&(found_indicies_count<MAX_PLAYLIST_ENTRIES);i++) | ||
844 | { | ||
845 | gui_syncsplash(0, true, str(LANG_PLAYLIST_SEARCH_MSG),found_indicies_count, | ||
846 | #if CONFIG_KEYPAD == PLAYER_PAD | ||
847 | str(LANG_STOP_ABORT) | ||
848 | #else | ||
849 | str(LANG_OFF_ABORT) | ||
850 | #endif | ||
851 | ); | ||
852 | if (SETTINGS_CANCEL == button_get(false)) | ||
853 | return ret; | ||
854 | playlist_get_track_info(viewer.playlist,i,&track); | ||
855 | if (strcasestr(track.filename,search_str)) | ||
856 | { | ||
857 | found_indicies[found_indicies_count++] = track.index; | ||
858 | } | ||
859 | } | ||
860 | if (!found_indicies_count) | ||
861 | { | ||
862 | return ret; | ||
863 | } | ||
864 | backlight_on(); | ||
865 | gui_synclist_init(&playlist_lists, playlist_search_callback_name, | ||
866 | found_indicies); | ||
867 | gui_synclist_set_icon_callback(&playlist_lists, | ||
868 | global_settings.playlist_viewer_icons? | ||
869 | &playlist_search_callback_icons:NULL); | ||
870 | gui_synclist_set_nb_items(&playlist_lists, found_indicies_count); | ||
871 | gui_synclist_select_item(&playlist_lists, 0); | ||
872 | gui_synclist_draw(&playlist_lists); | ||
873 | while (!exit) | ||
874 | { | ||
875 | button = button_get(true); | ||
876 | if (gui_synclist_do_button(&playlist_lists, button)) | ||
877 | continue; | ||
878 | switch (button) | ||
879 | { | ||
880 | case TREE_EXIT: | ||
881 | #ifdef TREE_RC_EXIT | ||
882 | case TREE_RC_EXIT: | ||
883 | #endif | ||
884 | #ifdef TREE_OFF | ||
885 | case TREE_OFF: | ||
886 | #endif | ||
887 | exit = true; | ||
888 | break; | ||
889 | |||
890 | #ifdef TREE_ENTER | ||
891 | case TREE_ENTER: | ||
892 | case TREE_ENTER | BUTTON_REPEAT: | ||
893 | #endif | ||
894 | #ifdef TREE_RC_RUN | ||
895 | case TREE_RC_RUN: | ||
896 | #endif | ||
897 | case TREE_RUN: | ||
898 | playlist_start( | ||
899 | found_indicies[gui_synclist_get_sel_pos(&playlist_lists)] | ||
900 | ,0); | ||
901 | exit = 1; | ||
902 | break; | ||
903 | case BUTTON_NONE: | ||
904 | break; | ||
905 | default: | ||
906 | if(default_event_handler(button) == SYS_USB_CONNECTED) | ||
907 | { | ||
908 | ret = true; | ||
909 | exit = true; | ||
910 | } | ||
911 | break; | ||
912 | } | ||
913 | } | ||
914 | return ret; | ||
915 | } | ||
916 | |||
diff --git a/apps/playlist_viewer.h b/apps/playlist_viewer.h index 69f9d03559..27f2e354c5 100644 --- a/apps/playlist_viewer.h +++ b/apps/playlist_viewer.h | |||
@@ -23,5 +23,6 @@ | |||
23 | 23 | ||
24 | bool playlist_viewer(void); | 24 | bool playlist_viewer(void); |
25 | bool playlist_viewer_ex(char* filename); | 25 | bool playlist_viewer_ex(char* filename); |
26 | bool search_playlist(void); | ||
26 | 27 | ||
27 | #endif | 28 | #endif |