Index: apps/plugins/pictureflow.c =================================================================== --- apps/plugins/pictureflow.c (revision 16213) +++ apps/plugins/pictureflow.c (working copy) @@ -28,8 +28,9 @@ #include "picture.h" #include "pictureflow_logo.h" #include "pictureflow_emptyslide.h" +#include "tree.h" +#include "tagtree.h" - PLUGIN_HEADER /******************************* Globals ***********************************/ @@ -67,6 +68,7 @@ #define PICTUREFLOW_MENU PLA_MENU #define PICTUREFLOW_QUIT PLA_QUIT #define PICTUREFLOW_SELECT_ALBUM PLA_FIRE +#define PICTUREFLOW_PLAY_ALBUM PLA_START /* for fixed-point arithmetic, we need minimum 32-bit long @@ -125,6 +127,7 @@ /* Error return values */ #define ERROR_NO_ALBUMS -1 #define ERROR_BUFFER_FULL -2 +#define NO_FILE "NO FILE" /** structs we use */ @@ -355,6 +358,37 @@ return fsin(iangle + (IANGLE_MAX >> 2)); } +/* + Load id3 info for the stopped track and return the album name +*/ +char* get_album_info(void) +{ + + int fd; + char current_track[MAX_PATH]; + struct mp3entry id3; + + fd = rb->open(TEMP_PATH, O_RDONLY); + /* Entering plugin from file browser, no file exists */ + if (fd < 0) + return NO_FILE; + rb->read_line(fd, current_track, MAX_PATH); + rb->close(fd); + fd = rb->open(current_track, O_RDONLY); +#if (CONFIG_CODEC == SWCODEC) + if (fd >= 0 && rb->get_metadata(&id3, fd, current_track)) +#else + if (!rb->mp3info(&id3, current_track)); +#endif + rb->close(fd); + rb->remove(TEMP_PATH); /* Get rid of the temp file */ + + return id3.album; +} + +/* +*/ + /** Create an index of all albums from the database. Also store the album names so we can access them later. @@ -395,6 +429,37 @@ return album_names + album[slide_index].name_idx; } +/* +Seek through the center_index to find our current (stopped) track and then set +the center_index to it (flip to it). +*/ + +static int seek_ci(void) +{ + int c, seek; + char *curr_slide; + + c = 0; + + curr_slide = get_album_info(); + /* Check to make sure we didn't get a blank name */ + if (curr_slide == NO_FILE) + return 0; + while ((rb->strcmp(curr_slide, get_album_name(c))) != 0) + c++; + seek = rb->strcmp(curr_slide, get_album_name(c)); + if (seek == 0) + return c; + else + return 0; +} + +/* +Search tagcache for a matching album name of the current album. Return the +filename of the matching album. ***NOT CURRENTLY WORKING (NOT INCLUDED)*** +*/ + + /** Return a pointer to the track name of the active album create_track_index has to be called first. @@ -1934,7 +1999,7 @@ track_index = -1; extra_fade = 0; - center_index = 0; + center_index = seek_ci(); slide_frame = 0; step = 0; target = 0; @@ -2072,6 +2137,10 @@ if ( pf_state == pf_show_tracks ) pf_state = pf_cover_out; break; + + case PICTUREFLOW_PLAY_ALBUM: + play_album(); + break; default: if (rb->default_event_handler_ex(button, cleanup, NULL) Index: apps/onplay.c =================================================================== --- apps/onplay.c (revision 16213) +++ apps/onplay.c (working copy) @@ -1005,6 +1005,20 @@ } return action; } + +static void goto_pflow(void) +{ + int fd; + + struct mp3entry *id3 = audio_current_track(); + fd = open(TEMP_PATH, O_RDWR|O_CREAT); + fdprintf(fd, id3->path); + close(fd); + audio_stop(); + plugin_load(PICTUREFLOW, NULL); + return; +} + MENUITEM_FUNCTION(view_cue_item, 0, ID2P(LANG_BROWSE_CUESHEET), view_cue, NULL, view_cue_item_callback, Icon_NOICON); @@ -1021,7 +1035,12 @@ MENUITEM_FUNCTION(eq_browse_presets_item, 0, ID2P(LANG_EQUALIZER_BROWSE), eq_browse_presets, NULL, NULL, Icon_Audio); #endif +#if defined(HAVE_LCD_COLOR) && defined(HAVE_ALBUMART) && defined(HAVE_TAGCACHE) +MENUITEM_FUNCTION(to_pflow, 0, "Goto PictureFlow", goto_pflow, NULL, + NULL, Icon_Plugin); +#endif + /* CONTEXT_[TREE|ID3DB] items */ static int clipboard_callback(int action,const struct menu_item_ex *this_item); MENUITEM_FUNCTION(rename_file_item, 0, ID2P(LANG_RENAME), @@ -1151,6 +1170,9 @@ #if CONFIG_CODEC == SWCODEC &eq_menu_graphical_item, &eq_browse_presets_item, #endif +#if defined(HAVE_LCD_COLOR) && defined(HAVE_ALBUMART) && defined(HAVE_TAGCACHE) + &to_pflow, +#endif ); /* used when onplay() is not called in the CONTEXT_WPS context */ MAKE_ONPLAYMENU( tree_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE), Index: apps/settings.h =================================================================== --- apps/settings.h (revision 16213) +++ apps/settings.h (working copy) @@ -79,6 +79,8 @@ #define VIEWERS_CONFIG ROCKBOX_DIR "/viewers.config" #define CONFIGFILE ROCKBOX_DIR "/config.cfg" #define FIXEDSETTINGSFILE ROCKBOX_DIR "/fixed.cfg" +#define TEMP_PATH PLUGIN_DEMOS_DIR "/temp.pf" +#define PICTUREFLOW PLUGIN_DEMOS_DIR "/pictureflow.rock" #define MAX_FILENAME 32