diff options
Diffstat (limited to 'apps/plugins/pictureflow/pictureflow.c')
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 91 |
1 files changed, 78 insertions, 13 deletions
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 155b495ebf..3a150d10c0 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c | |||
@@ -58,6 +58,7 @@ PLUGIN_HEADER | |||
58 | #define PF_WPS ACTION_TREE_WPS | 58 | #define PF_WPS ACTION_TREE_WPS |
59 | 59 | ||
60 | #define PF_QUIT (LAST_ACTION_PLACEHOLDER + 1) | 60 | #define PF_QUIT (LAST_ACTION_PLACEHOLDER + 1) |
61 | #define PF_TRACKLIST (LAST_ACTION_PLACEHOLDER + 2) | ||
61 | 62 | ||
62 | #if defined(HAVE_SCROLLWHEEL) || CONFIG_KEYPAD == IRIVER_H10_PAD || \ | 63 | #if defined(HAVE_SCROLLWHEEL) || CONFIG_KEYPAD == IRIVER_H10_PAD || \ |
63 | CONFIG_KEYPAD == SAMSUNG_YH_PAD | 64 | CONFIG_KEYPAD == SAMSUNG_YH_PAD |
@@ -120,6 +121,7 @@ const struct button_mapping pf_context_buttons[] = | |||
120 | {PF_QUIT, BUTTON_POWER, BUTTON_NONE}, | 121 | {PF_QUIT, BUTTON_POWER, BUTTON_NONE}, |
121 | #elif CONFIG_KEYPAD == SANSA_FUZE_PAD | 122 | #elif CONFIG_KEYPAD == SANSA_FUZE_PAD |
122 | {PF_QUIT, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE}, | 123 | {PF_QUIT, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE}, |
124 | {PF_TRACKLIST, BUTTON_RIGHT, BUTTON_NONE}, | ||
123 | /* These all use short press of BUTTON_POWER for menu, map long POWER to quit | 125 | /* These all use short press of BUTTON_POWER for menu, map long POWER to quit |
124 | */ | 126 | */ |
125 | #elif CONFIG_KEYPAD == SANSA_C200_PAD || CONFIG_KEYPAD == SANSA_M200_PAD || \ | 127 | #elif CONFIG_KEYPAD == SANSA_C200_PAD || CONFIG_KEYPAD == SANSA_M200_PAD || \ |
@@ -311,6 +313,8 @@ static int center_margin = (LCD_WIDTH - DISPLAY_WIDTH) / 12; | |||
311 | static int num_slides = 4; | 313 | static int num_slides = 4; |
312 | static int zoom = 100; | 314 | static int zoom = 100; |
313 | static bool show_fps = false; | 315 | static bool show_fps = false; |
316 | static int auto_wps = 0; | ||
317 | static int last_album = 0; | ||
314 | static bool resize = true; | 318 | static bool resize = true; |
315 | static int cache_version = 0; | 319 | static int cache_version = 0; |
316 | static int show_album_name = (LCD_HEIGHT > 100) | 320 | static int show_album_name = (LCD_HEIGHT > 100) |
@@ -328,8 +332,10 @@ static struct configdata config[] = | |||
328 | { TYPE_BOOL, 0, 1, { .bool_p = &show_fps }, "show fps", NULL }, | 332 | { TYPE_BOOL, 0, 1, { .bool_p = &show_fps }, "show fps", NULL }, |
329 | { TYPE_BOOL, 0, 1, { .bool_p = &resize }, "resize", NULL }, | 333 | { TYPE_BOOL, 0, 1, { .bool_p = &resize }, "resize", NULL }, |
330 | { TYPE_INT, 0, 100, { .int_p = &cache_version }, "cache version", NULL }, | 334 | { TYPE_INT, 0, 100, { .int_p = &cache_version }, "cache version", NULL }, |
331 | { TYPE_ENUM, 0, 2, { .int_p = &show_album_name }, "show album name", | 335 | { TYPE_ENUM, 0, 3, { .int_p = &show_album_name }, "show album name", |
332 | show_album_name_conf } | 336 | show_album_name_conf }, |
337 | { TYPE_INT, 0, 2, { .int_p = &auto_wps }, "auto wps", NULL }, | ||
338 | { TYPE_INT, 0, 999999, { .int_p = &last_album }, "last album", NULL } | ||
333 | }; | 339 | }; |
334 | 340 | ||
335 | #define CONFIG_NUM_ITEMS (sizeof(config) / sizeof(struct configdata)) | 341 | #define CONFIG_NUM_ITEMS (sizeof(config) / sizeof(struct configdata)) |
@@ -782,6 +788,18 @@ char* get_track_filename(const int track_index) | |||
782 | return track_names + tracks[track_index].filename_idx; | 788 | return track_names + tracks[track_index].filename_idx; |
783 | return 0; | 789 | return 0; |
784 | } | 790 | } |
791 | |||
792 | int get_wps_current_index(void) | ||
793 | { | ||
794 | struct mp3entry *id3 = rb->audio_current_track(); | ||
795 | if(id3 && id3->album) { | ||
796 | int i; | ||
797 | for( i=0; i < album_count; i++ ) | ||
798 | if(!rb->strcmp(album_names + album[i].name_idx, id3->album)) | ||
799 | return i; | ||
800 | } | ||
801 | return last_album; | ||
802 | } | ||
785 | #endif | 803 | #endif |
786 | /** | 804 | /** |
787 | Compare two unsigned ints passed via pointers. | 805 | Compare two unsigned ints passed via pointers. |
@@ -2071,13 +2089,19 @@ int settings_menu(void) | |||
2071 | 2089 | ||
2072 | MENUITEM_STRINGLIST(settings_menu, "PictureFlow Settings", NULL, "Show FPS", | 2090 | MENUITEM_STRINGLIST(settings_menu, "PictureFlow Settings", NULL, "Show FPS", |
2073 | "Spacing", "Centre margin", "Number of slides", "Zoom", | 2091 | "Spacing", "Centre margin", "Number of slides", "Zoom", |
2074 | "Show album title", "Resize Covers", "Rebuild cache"); | 2092 | "Show album title", "Resize Covers", "Rebuild cache", |
2093 | "WPS Integration"); | ||
2075 | 2094 | ||
2076 | static const struct opt_items album_name_options[] = { | 2095 | static const struct opt_items album_name_options[] = { |
2077 | { "Hide album title", -1 }, | 2096 | { "Hide album title", -1 }, |
2078 | { "Show at the bottom", -1 }, | 2097 | { "Show at the bottom", -1 }, |
2079 | { "Show at the top", -1 } | 2098 | { "Show at the top", -1 } |
2080 | }; | 2099 | }; |
2100 | static const struct opt_items wps_options[] = { | ||
2101 | { "Off", -1 }, | ||
2102 | { "Direct", -1 }, | ||
2103 | { "Via Track list", -1 } | ||
2104 | }; | ||
2081 | 2105 | ||
2082 | do { | 2106 | do { |
2083 | selection=rb->do_menu(&settings_menu,&selection, NULL, true); | 2107 | selection=rb->do_menu(&settings_menu,&selection, NULL, true); |
@@ -2134,6 +2158,9 @@ int settings_menu(void) | |||
2134 | rb->remove(EMPTY_SLIDE); | 2158 | rb->remove(EMPTY_SLIDE); |
2135 | rb->splash(HZ, "Cache will be rebuilt on next restart"); | 2159 | rb->splash(HZ, "Cache will be rebuilt on next restart"); |
2136 | break; | 2160 | break; |
2161 | case 8: | ||
2162 | rb->set_option("WPS Integration", &auto_wps, INT, wps_options, 3, NULL); | ||
2163 | break; | ||
2137 | 2164 | ||
2138 | case MENU_ATTACHED_USB: | 2165 | case MENU_ATTACHED_USB: |
2139 | return PLUGIN_USB_CONNECTED; | 2166 | return PLUGIN_USB_CONNECTED; |
@@ -2373,7 +2400,7 @@ void select_prev_track(void) | |||
2373 | /* | 2400 | /* |
2374 | * Puts the current tracklist into a newly created playlist and starts playling | 2401 | * Puts the current tracklist into a newly created playlist and starts playling |
2375 | */ | 2402 | */ |
2376 | void start_playback(void) | 2403 | void start_playback(bool append) |
2377 | { | 2404 | { |
2378 | static int old_playlist = -1, old_shuffle = 0; | 2405 | static int old_playlist = -1, old_shuffle = 0; |
2379 | int count = 0; | 2406 | int count = 0; |
@@ -2382,14 +2409,14 @@ void start_playback(void) | |||
2382 | /* reuse existing playlist if possible | 2409 | /* reuse existing playlist if possible |
2383 | * regenerate if shuffle is on or changed, since playlist index and | 2410 | * regenerate if shuffle is on or changed, since playlist index and |
2384 | * selected track are "out of sync" */ | 2411 | * selected track are "out of sync" */ |
2385 | if (!shuffle && center_slide.slide_index == old_playlist | 2412 | if (!shuffle && !append && center_slide.slide_index == old_playlist |
2386 | && (old_shuffle == shuffle)) | 2413 | && (old_shuffle == shuffle)) |
2387 | { | 2414 | { |
2388 | goto play; | 2415 | goto play; |
2389 | } | 2416 | } |
2390 | /* First, replace the current playlist with a new one */ | 2417 | /* First, replace the current playlist with a new one */ |
2391 | else if (rb->playlist_remove_all_tracks(NULL) == 0 | 2418 | else if (append || (rb->playlist_remove_all_tracks(NULL) == 0 |
2392 | && rb->playlist_create(NULL, NULL) == 0) | 2419 | && rb->playlist_create(NULL, NULL) == 0)) |
2393 | { | 2420 | { |
2394 | do { | 2421 | do { |
2395 | rb->yield(); | 2422 | rb->yield(); |
@@ -2408,7 +2435,8 @@ play: | |||
2408 | /* TODO: can we adjust selected_track if !play_selected ? | 2435 | /* TODO: can we adjust selected_track if !play_selected ? |
2409 | * if shuffle, we can't predict the playing track easily, and for either | 2436 | * if shuffle, we can't predict the playing track easily, and for either |
2410 | * case the track list doesn't get auto scrolled*/ | 2437 | * case the track list doesn't get auto scrolled*/ |
2411 | rb->playlist_start(position, 0); | 2438 | if(!append) |
2439 | rb->playlist_start(position, 0); | ||
2412 | old_playlist = center_slide.slide_index; | 2440 | old_playlist = center_slide.slide_index; |
2413 | old_shuffle = shuffle; | 2441 | old_shuffle = shuffle; |
2414 | } | 2442 | } |
@@ -2493,7 +2521,6 @@ int main(void) | |||
2493 | int ret; | 2521 | int ret; |
2494 | 2522 | ||
2495 | rb->lcd_setfont(FONT_UI); | 2523 | rb->lcd_setfont(FONT_UI); |
2496 | draw_splashscreen(); | ||
2497 | 2524 | ||
2498 | if ( ! rb->dir_exists( CACHE_PREFIX ) ) { | 2525 | if ( ! rb->dir_exists( CACHE_PREFIX ) ) { |
2499 | if ( rb->mkdir( CACHE_PREFIX ) < 0 ) { | 2526 | if ( rb->mkdir( CACHE_PREFIX ) < 0 ) { |
@@ -2502,7 +2529,9 @@ int main(void) | |||
2502 | } | 2529 | } |
2503 | } | 2530 | } |
2504 | 2531 | ||
2505 | configfile_load(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); | 2532 | configfile_load(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); |
2533 | if(auto_wps == 0) | ||
2534 | draw_splashscreen(); | ||
2506 | 2535 | ||
2507 | init_reflect_table(); | 2536 | init_reflect_table(); |
2508 | 2537 | ||
@@ -2581,6 +2610,7 @@ int main(void) | |||
2581 | 2610 | ||
2582 | recalc_offsets(); | 2611 | recalc_offsets(); |
2583 | reset_slides(); | 2612 | reset_slides(); |
2613 | set_current_slide(get_wps_current_index()); | ||
2584 | 2614 | ||
2585 | char fpstxt[10]; | 2615 | char fpstxt[10]; |
2586 | int button; | 2616 | int button; |
@@ -2713,13 +2743,48 @@ int main(void) | |||
2713 | show_previous_slide(); | 2743 | show_previous_slide(); |
2714 | break; | 2744 | break; |
2715 | 2745 | ||
2746 | case PF_CONTEXT: | ||
2747 | if ( auto_wps != 0 ) { | ||
2748 | if( pf_state == pf_idle ) { | ||
2749 | create_track_index(center_slide.slide_index); | ||
2750 | reset_track_list(); | ||
2751 | start_playback(true); | ||
2752 | rb->splash(HZ*2, "Added to playlist"); | ||
2753 | } | ||
2754 | else if( pf_state == pf_show_tracks ) { | ||
2755 | rb->playlist_insert_track(NULL, get_track_filename(selected_track), | ||
2756 | PLAYLIST_INSERT_LAST, false, true); | ||
2757 | rb->playlist_sync(NULL); | ||
2758 | rb->splash(HZ*2, "Added to playlist"); | ||
2759 | } | ||
2760 | } | ||
2761 | break; | ||
2762 | case PF_TRACKLIST: | ||
2763 | if ( auto_wps == 1 && pf_state == pf_idle ) { | ||
2764 | pf_state = pf_cover_in; | ||
2765 | break; | ||
2766 | } | ||
2716 | case PF_SELECT: | 2767 | case PF_SELECT: |
2717 | if ( pf_state == pf_idle ) { | 2768 | if ( pf_state == pf_idle ) { |
2718 | pf_state = pf_cover_in; | 2769 | #if PF_PLAYBACK_CAPABLE |
2770 | if(auto_wps == 1) { | ||
2771 | create_track_index(center_slide.slide_index); | ||
2772 | reset_track_list(); | ||
2773 | start_playback(false); | ||
2774 | last_album = center_index; | ||
2775 | return PLUGIN_GOTO_WPS; | ||
2776 | } | ||
2777 | else | ||
2778 | #endif | ||
2779 | pf_state = pf_cover_in; | ||
2719 | } | 2780 | } |
2720 | else if ( pf_state == pf_show_tracks ) { | 2781 | else if ( pf_state == pf_show_tracks ) { |
2721 | #if PF_PLAYBACK_CAPABLE | 2782 | #if PF_PLAYBACK_CAPABLE |
2722 | start_playback(); | 2783 | start_playback(false); |
2784 | if(auto_wps != 0) { | ||
2785 | last_album = center_index; | ||
2786 | return PLUGIN_GOTO_WPS; | ||
2787 | } | ||
2723 | #endif | 2788 | #endif |
2724 | } | 2789 | } |
2725 | break; | 2790 | break; |
@@ -2759,7 +2824,7 @@ enum plugin_status plugin_start(const void *parameter) | |||
2759 | #endif | 2824 | #endif |
2760 | #endif | 2825 | #endif |
2761 | ret = main(); | 2826 | ret = main(); |
2762 | if ( ret == PLUGIN_OK ) { | 2827 | if ( ret == PLUGIN_OK || ret == PLUGIN_GOTO_WPS) { |
2763 | if (configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, | 2828 | if (configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, |
2764 | CONFIG_VERSION)) | 2829 | CONFIG_VERSION)) |
2765 | { | 2830 | { |