FS#11270 by Chris Savery - WPS integration for pictureflow

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26710 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2010-06-09 04:25:41 +00:00
parent 1596128296
commit d871ff8cce
8 changed files with 159 additions and 27 deletions

View File

@ -841,6 +841,8 @@ long gui_wps_show(void)
return GO_TO_ROOT;
else if (retval == ONPLAY_PLAYLIST)
return GO_TO_PLAYLIST_VIEWER;
else if (retval == ONPLAY_PICTUREFLOW)
return GO_TO_PICTUREFLOW;
restore = true;
}
break;

View File

@ -12540,3 +12540,17 @@
*: "Force"
</voice>
</phrase>
<phrase>
id: LANG_ONPLAY_PICTUREFLOW
desc: Onplay pictureflow
user: core
<source>
*: "PictureFlow"
</source>
<dest>
*: "PictureFlow"
</dest>
<voice>
*: "open picture flow"
</voice>
</phrase>

View File

@ -929,6 +929,8 @@ static int ratingitem_callback(int action,const struct menu_item_ex *this_item)
MENUITEM_FUNCTION(rating_item, 0, ID2P(LANG_MENU_SET_RATING),
set_rating_inline, NULL,
ratingitem_callback, Icon_Questionmark);
MENUITEM_RETURNVALUE(pictureflow_item, ID2P(LANG_ONPLAY_PICTUREFLOW),
GO_TO_PICTUREFLOW, NULL, Icon_NOICON);
#endif
static bool view_cue(void)
@ -1131,7 +1133,11 @@ MAKE_ONPLAYMENU( wps_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE),
#ifdef HAVE_TAGCACHE
&rating_item,
#endif
&bookmark_menu, &browse_id3_item, &list_viewers_item,
&bookmark_menu,
#ifdef HAVE_TAGCACHE
&pictureflow_item,
#endif
&browse_id3_item, &list_viewers_item,
&delete_file_item, &view_cue_item,
#ifdef HAVE_PITCHSCREEN
&pitch_screen_item,
@ -1244,6 +1250,11 @@ static struct hotkey_assignment hotkey_items[] = {
{ HOTKEY_INSERT_SHUFFLED, LANG_INSERT_SHUFFLED,
HOTKEY_FUNC(playlist_insert_shuffled, NULL),
ONPLAY_OK },
#ifdef HAVE_TAGCACHE
{ HOTKEY_PICTUREFLOW, LANG_ONPLAY_PICTUREFLOW,
HOTKEY_FUNC(NULL, NULL),
ONPLAY_PICTUREFLOW },
#endif
};
/* Return the language ID for this action */
@ -1316,6 +1327,7 @@ int onplay(char* file, int attr, int from, bool hotkey)
else
menu = &tree_onplay_menu;
menu_selection = do_menu(menu, NULL, NULL, false);
switch (menu_selection)
{
case GO_TO_WPS:
@ -1325,6 +1337,10 @@ int onplay(char* file, int attr, int from, bool hotkey)
return ONPLAY_MAINMENU;
case GO_TO_PLAYLIST_VIEWER:
return ONPLAY_PLAYLIST;
#ifdef HAVE_TAGCACHE
case GO_TO_PICTUREFLOW:
return ONPLAY_PICTUREFLOW;
#endif
default:
return onplay_result;
}

View File

@ -29,6 +29,7 @@ enum {
ONPLAY_RELOAD_DIR,
ONPLAY_START_PLAY,
ONPLAY_PLAYLIST,
ONPLAY_PICTUREFLOW,
};
#ifdef HAVE_HOTKEY
@ -43,6 +44,7 @@ enum hotkey_action {
HOTKEY_DELETE,
HOTKEY_INSERT,
HOTKEY_INSERT_SHUFFLED,
HOTKEY_PICTUREFLOW,
};
#endif

View File

@ -58,6 +58,7 @@ PLUGIN_HEADER
#define PF_WPS ACTION_TREE_WPS
#define PF_QUIT (LAST_ACTION_PLACEHOLDER + 1)
#define PF_TRACKLIST (LAST_ACTION_PLACEHOLDER + 2)
#if defined(HAVE_SCROLLWHEEL) || CONFIG_KEYPAD == IRIVER_H10_PAD || \
CONFIG_KEYPAD == SAMSUNG_YH_PAD
@ -120,6 +121,7 @@ const struct button_mapping pf_context_buttons[] =
{PF_QUIT, BUTTON_POWER, BUTTON_NONE},
#elif CONFIG_KEYPAD == SANSA_FUZE_PAD
{PF_QUIT, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE},
{PF_TRACKLIST, BUTTON_RIGHT, BUTTON_NONE},
/* These all use short press of BUTTON_POWER for menu, map long POWER to quit
*/
#elif CONFIG_KEYPAD == SANSA_C200_PAD || CONFIG_KEYPAD == SANSA_M200_PAD || \
@ -311,6 +313,8 @@ static int center_margin = (LCD_WIDTH - DISPLAY_WIDTH) / 12;
static int num_slides = 4;
static int zoom = 100;
static bool show_fps = false;
static int auto_wps = 0;
static int last_album = 0;
static bool resize = true;
static int cache_version = 0;
static int show_album_name = (LCD_HEIGHT > 100)
@ -328,8 +332,10 @@ static struct configdata config[] =
{ TYPE_BOOL, 0, 1, { .bool_p = &show_fps }, "show fps", NULL },
{ TYPE_BOOL, 0, 1, { .bool_p = &resize }, "resize", NULL },
{ TYPE_INT, 0, 100, { .int_p = &cache_version }, "cache version", NULL },
{ TYPE_ENUM, 0, 2, { .int_p = &show_album_name }, "show album name",
show_album_name_conf }
{ TYPE_ENUM, 0, 3, { .int_p = &show_album_name }, "show album name",
show_album_name_conf },
{ TYPE_INT, 0, 2, { .int_p = &auto_wps }, "auto wps", NULL },
{ TYPE_INT, 0, 999999, { .int_p = &last_album }, "last album", NULL }
};
#define CONFIG_NUM_ITEMS (sizeof(config) / sizeof(struct configdata))
@ -782,6 +788,18 @@ char* get_track_filename(const int track_index)
return track_names + tracks[track_index].filename_idx;
return 0;
}
int get_wps_current_index(void)
{
struct mp3entry *id3 = rb->audio_current_track();
if(id3 && id3->album) {
int i;
for( i=0; i < album_count; i++ )
if(!rb->strcmp(album_names + album[i].name_idx, id3->album))
return i;
}
return last_album;
}
#endif
/**
Compare two unsigned ints passed via pointers.
@ -2071,13 +2089,19 @@ int settings_menu(void)
MENUITEM_STRINGLIST(settings_menu, "PictureFlow Settings", NULL, "Show FPS",
"Spacing", "Centre margin", "Number of slides", "Zoom",
"Show album title", "Resize Covers", "Rebuild cache");
"Show album title", "Resize Covers", "Rebuild cache",
"WPS Integration");
static const struct opt_items album_name_options[] = {
{ "Hide album title", -1 },
{ "Show at the bottom", -1 },
{ "Show at the top", -1 }
};
static const struct opt_items wps_options[] = {
{ "Off", -1 },
{ "Direct", -1 },
{ "Via Track list", -1 }
};
do {
selection=rb->do_menu(&settings_menu,&selection, NULL, true);
@ -2134,6 +2158,9 @@ int settings_menu(void)
rb->remove(EMPTY_SLIDE);
rb->splash(HZ, "Cache will be rebuilt on next restart");
break;
case 8:
rb->set_option("WPS Integration", &auto_wps, INT, wps_options, 3, NULL);
break;
case MENU_ATTACHED_USB:
return PLUGIN_USB_CONNECTED;
@ -2373,7 +2400,7 @@ void select_prev_track(void)
/*
* Puts the current tracklist into a newly created playlist and starts playling
*/
void start_playback(void)
void start_playback(bool append)
{
static int old_playlist = -1, old_shuffle = 0;
int count = 0;
@ -2382,14 +2409,14 @@ void start_playback(void)
/* reuse existing playlist if possible
* regenerate if shuffle is on or changed, since playlist index and
* selected track are "out of sync" */
if (!shuffle && center_slide.slide_index == old_playlist
if (!shuffle && !append && center_slide.slide_index == old_playlist
&& (old_shuffle == shuffle))
{
goto play;
}
/* First, replace the current playlist with a new one */
else if (rb->playlist_remove_all_tracks(NULL) == 0
&& rb->playlist_create(NULL, NULL) == 0)
else if (append || (rb->playlist_remove_all_tracks(NULL) == 0
&& rb->playlist_create(NULL, NULL) == 0))
{
do {
rb->yield();
@ -2408,7 +2435,8 @@ play:
/* TODO: can we adjust selected_track if !play_selected ?
* if shuffle, we can't predict the playing track easily, and for either
* case the track list doesn't get auto scrolled*/
rb->playlist_start(position, 0);
if(!append)
rb->playlist_start(position, 0);
old_playlist = center_slide.slide_index;
old_shuffle = shuffle;
}
@ -2493,7 +2521,6 @@ int main(void)
int ret;
rb->lcd_setfont(FONT_UI);
draw_splashscreen();
if ( ! rb->dir_exists( CACHE_PREFIX ) ) {
if ( rb->mkdir( CACHE_PREFIX ) < 0 ) {
@ -2502,7 +2529,9 @@ int main(void)
}
}
configfile_load(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
configfile_load(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
if(auto_wps == 0)
draw_splashscreen();
init_reflect_table();
@ -2581,6 +2610,7 @@ int main(void)
recalc_offsets();
reset_slides();
set_current_slide(get_wps_current_index());
char fpstxt[10];
int button;
@ -2713,13 +2743,48 @@ int main(void)
show_previous_slide();
break;
case PF_CONTEXT:
if ( auto_wps != 0 ) {
if( pf_state == pf_idle ) {
create_track_index(center_slide.slide_index);
reset_track_list();
start_playback(true);
rb->splash(HZ*2, "Added to playlist");
}
else if( pf_state == pf_show_tracks ) {
rb->playlist_insert_track(NULL, get_track_filename(selected_track),
PLAYLIST_INSERT_LAST, false, true);
rb->playlist_sync(NULL);
rb->splash(HZ*2, "Added to playlist");
}
}
break;
case PF_TRACKLIST:
if ( auto_wps == 1 && pf_state == pf_idle ) {
pf_state = pf_cover_in;
break;
}
case PF_SELECT:
if ( pf_state == pf_idle ) {
pf_state = pf_cover_in;
#if PF_PLAYBACK_CAPABLE
if(auto_wps == 1) {
create_track_index(center_slide.slide_index);
reset_track_list();
start_playback(false);
last_album = center_index;
return PLUGIN_GOTO_WPS;
}
else
#endif
pf_state = pf_cover_in;
}
else if ( pf_state == pf_show_tracks ) {
#if PF_PLAYBACK_CAPABLE
start_playback();
start_playback(false);
if(auto_wps != 0) {
last_album = center_index;
return PLUGIN_GOTO_WPS;
}
#endif
}
break;
@ -2759,7 +2824,7 @@ enum plugin_status plugin_start(const void *parameter)
#endif
#endif
ret = main();
if ( ret == PLUGIN_OK ) {
if ( ret == PLUGIN_OK || ret == PLUGIN_GOTO_WPS) {
if (configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS,
CONFIG_VERSION))
{

View File

@ -68,6 +68,7 @@
#include "tagcache.h"
#endif
#include "language.h"
#include "plugin.h"
struct root_items {
int (*function)(void* param);
@ -544,6 +545,24 @@ static int load_context_screen(int selection)
return GO_TO_PREVIOUS;
}
#ifdef HAVE_TAGCACHE
static int load_plugin_screen(char *plug_path)
{
int ret_val;
int old_previous = last_screen;
last_screen = next_screen;
global_status.last_screen = (char)next_screen;
status_save();
ret_val = plugin_load(plug_path, NULL);
if (ret_val == PLUGIN_OK)
ret_val = GO_TO_PREVIOUS;
if (ret_val == GO_TO_PREVIOUS)
last_screen = (old_previous == next_screen) ? GO_TO_ROOT : old_previous;
return ret_val;
}
#endif
static int previous_music = GO_TO_WPS;
void previous_music_is_wps(void)
@ -619,6 +638,18 @@ void root_menu(void)
case GO_TO_ROOTITEM_CONTEXT:
next_screen = load_context_screen(selected);
break;
#ifdef HAVE_TAGCACHE
case GO_TO_PICTUREFLOW:
while ( !tagcache_is_usable() )
{
splash(0, str(LANG_TAGCACHE_BUSY));
if ( action_userabort(HZ/5) )
break;
}
next_screen = load_plugin_screen(PLUGIN_DEMOS_DIR "/pictureflow.rock");
previous_browser = GO_TO_PICTUREFLOW;
break;
#endif
default:
if (next_screen == GO_TO_FILEBROWSER
#ifdef HAVE_TAGCACHE

View File

@ -47,6 +47,7 @@ enum {
GO_TO_FM,
#endif
GO_TO_RECENTBMARKS,
GO_TO_PICTUREFLOW,
/* Do Not add any items above here unless you want it to be able to
be the "start screen" after a boot up. The setting in settings_list.c
will need editing if this is the case. */

View File

@ -1572,8 +1572,16 @@ const struct settings_list settings[] = {
#if CONFIG_TUNER
"radio,"
#endif
"bookmarks" ,NULL,
"bookmarks,pictureflow", NULL,
#if defined(HAVE_TAGCACHE)
#if defined(HAVE_RECORDING) && CONFIG_TUNER
10,
#elif defined(HAVE_RECORDING) || CONFIG_TUNER /* only one of them */
9,
#else
8,
#endif
#else
#if defined(HAVE_RECORDING) && CONFIG_TUNER
9,
#elif defined(HAVE_RECORDING) || CONFIG_TUNER /* only one of them */
@ -1581,14 +1589,6 @@ const struct settings_list settings[] = {
#else
7,
#endif
#else
#if defined(HAVE_RECORDING) && CONFIG_TUNER
8,
#elif defined(HAVE_RECORDING) || CONFIG_TUNER /* only one of them */
7,
#else
6,
#endif
#endif
ID2P(LANG_PREVIOUS_SCREEN), ID2P(LANG_MAIN_MENU),
ID2P(LANG_DIR_BROWSER),
@ -1602,7 +1602,8 @@ const struct settings_list settings[] = {
#if CONFIG_TUNER
ID2P(LANG_FM_RADIO),
#endif
ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS)
ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS),
ID2P(LANG_ONPLAY_PICTUREFLOW)
),
SYSTEM_SETTING(NVRAM(1),last_screen,-1),
#if defined(HAVE_RTC_ALARM) && \
@ -1746,10 +1747,10 @@ const struct settings_list settings[] = {
#ifdef HAVE_HOTKEY
TABLE_SETTING(F_ALLOW_ARBITRARY_VALS, hotkey_wps,
LANG_HOTKEY_WPS, HOTKEY_VIEW_PLAYLIST, "hotkey wps",
"off,view playlist,show track info,pitchscreen,open with,delete",
UNIT_INT, hotkey_formatter, hotkey_getlang, NULL, 6, HOTKEY_OFF,
"off,view playlist,show track info,pitchscreen,open with,delete,pictureflow",
UNIT_INT, hotkey_formatter, hotkey_getlang, NULL, 7, HOTKEY_OFF,
HOTKEY_VIEW_PLAYLIST, HOTKEY_SHOW_TRACK_INFO, HOTKEY_PITCHSCREEN,
HOTKEY_OPEN_WITH, HOTKEY_DELETE),
HOTKEY_OPEN_WITH, HOTKEY_DELETE, HOTKEY_PICTUREFLOW),
TABLE_SETTING(F_ALLOW_ARBITRARY_VALS, hotkey_tree,
LANG_HOTKEY_FILE_BROWSER, HOTKEY_OFF, "hotkey tree",
"off,open with,delete,insert,insert shuffled",