/* CONTEXT_WPS playlist options */ static bool shuffle_playlist(void) { playlist_sort(NULL, true); playlist_randomise(NULL, current_tick, true); return false; }
static int playback_callback(int action,const struct menu_item_ex *this_item) { static bool old_shuffle = false; switch (action) { case ACTION_ENTER_MENUITEM: if (this_item == &shuffle_item) old_shuffle = global_settings.playlist_shuffle; break; case ACTION_EXIT_MENUITEM: /* on exit */ if ((this_item == &shuffle_item) && (old_shuffle != global_settings.playlist_shuffle) && (audio_status() & AUDIO_STATUS_PLAY)) { #if CONFIG_CODEC == SWCODEC dsp_set_replaygain(); #endif if (global_settings.playlist_shuffle) { playlist_randomise(NULL, current_tick, true); } else { playlist_sort(NULL, true); } } break; } return action; }
static int playback_callback(int action,const struct menu_item_ex *this_item) { static bool old_shuffle = false; static int old_repeat = 0; switch (action) { case ACTION_ENTER_MENUITEM: if (this_item == &shuffle_item) { old_shuffle = global_settings.playlist_shuffle; } else if (this_item == &repeat_mode) { old_repeat = global_settings.repeat_mode; } break; case ACTION_EXIT_MENUITEM: /* on exit */ if (!(audio_status() & AUDIO_STATUS_PLAY)) break; if (this_item == &shuffle_item) { if (old_shuffle == global_settings.playlist_shuffle) break; #if CONFIG_CODEC == SWCODEC dsp_set_replaygain(); #endif if (global_settings.playlist_shuffle) { playlist_randomise(NULL, current_tick, true); } else { playlist_sort(NULL, true); } } else if (this_item == &repeat_mode) { if (old_repeat == global_settings.repeat_mode) break; audio_flush_and_reload_tracks(); } break; } return action; }
static bool playback_settings_menu(void) { int m; bool result; static const struct menu_item items[] = { { ID2P(LANG_SHUFFLE), shuffle }, { ID2P(LANG_REPEAT), repeat_mode }, { ID2P(LANG_PLAY_SELECTED), play_selected }, { ID2P(LANG_RESUME), resume }, { ID2P(LANG_WIND_MENU), ff_rewind_settings_menu }, { ID2P(LANG_MP3BUFFER_MARGIN), buffer_margin }, { ID2P(LANG_FADE_ON_STOP), set_fade_on_stop }, #if CONFIG_CODEC == SWCODEC { ID2P(LANG_CROSSFADE), crossfade }, { ID2P(LANG_CROSSFADE_DURATION), crossfade_duration }, { ID2P(LANG_REPLAYGAIN), replaygain_settings_menu }, { ID2P(LANG_BEEP), beep }, #endif #ifdef HAVE_SPDIF_POWER { ID2P(LANG_SPDIF_ENABLE), spdif }, #endif { ID2P(LANG_ID3_ORDER), id3_order }, { ID2P(LANG_NEXT_FOLDER), next_folder }, { ID2P(LANG_RUNTIMEDB_ACTIVE), runtimedb }, }; bool old_shuffle = global_settings.playlist_shuffle; m=menu_init( items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); result = menu_run(m); menu_exit(m); if ((old_shuffle != global_settings.playlist_shuffle) && (audio_status() & AUDIO_STATUS_PLAY)) { if (global_settings.playlist_shuffle) { playlist_randomise(NULL, current_tick, true); } else { playlist_sort(NULL, true); } } return result; }
bool quick_screen_quick(int button_enter) { struct gui_quickscreen qs; bool oldshuffle = global_settings.playlist_shuffle; int oldrepeat = global_settings.repeat_mode; qs.items[QUICKSCREEN_TOP] = get_setting(global_settings.qs_items[QUICKSCREEN_TOP], find_setting(&global_settings.party_mode, NULL)); qs.items[QUICKSCREEN_LEFT] = get_setting(global_settings.qs_items[QUICKSCREEN_LEFT], find_setting(&global_settings.playlist_shuffle, NULL)); qs.items[QUICKSCREEN_RIGHT] = get_setting(global_settings.qs_items[QUICKSCREEN_RIGHT], find_setting(&global_settings.repeat_mode, NULL)); qs.items[QUICKSCREEN_BOTTOM] = get_setting(global_settings.qs_items[QUICKSCREEN_BOTTOM], find_setting(&global_settings.dirfilter, NULL)); qs.callback = NULL; if (gui_syncquickscreen_run(&qs, button_enter)) { settings_save(); settings_apply(false); /* make sure repeat/shuffle/any other nasty ones get updated */ if ( oldrepeat != global_settings.repeat_mode && (audio_status() & AUDIO_STATUS_PLAY) ) { audio_flush_and_reload_tracks(); } if (oldshuffle != global_settings.playlist_shuffle && audio_status() & AUDIO_STATUS_PLAY) { #if CONFIG_CODEC == SWCODEC dsp_set_replaygain(); #endif if (global_settings.playlist_shuffle) playlist_randomise(NULL, current_tick, true); else playlist_sort(NULL, true); } } return(0); }
bool quick_screen_quick(int button_enter) { struct gui_quickscreen qs; bool oldshuffle = global_settings.playlist_shuffle; int oldrepeat = global_settings.repeat_mode; bool usb = false; if (global_settings.shortcuts_replaces_qs) return do_shortcut_menu(NULL); qs.items[QUICKSCREEN_TOP] = get_setting(global_settings.qs_items[QUICKSCREEN_TOP], NULL); qs.items[QUICKSCREEN_LEFT] = get_setting(global_settings.qs_items[QUICKSCREEN_LEFT], find_setting(&global_settings.playlist_shuffle, NULL)); qs.items[QUICKSCREEN_RIGHT] = get_setting(global_settings.qs_items[QUICKSCREEN_RIGHT], find_setting(&global_settings.repeat_mode, NULL)); qs.items[QUICKSCREEN_BOTTOM] = get_setting(global_settings.qs_items[QUICKSCREEN_BOTTOM], NULL); qs.callback = NULL; if (gui_syncquickscreen_run(&qs, button_enter, &usb)) { settings_save(); settings_apply(false); /* make sure repeat/shuffle/any other nasty ones get updated */ if ( oldrepeat != global_settings.repeat_mode && (audio_status() & AUDIO_STATUS_PLAY) ) { audio_flush_and_reload_tracks(); } if (oldshuffle != global_settings.playlist_shuffle && audio_status() & AUDIO_STATUS_PLAY) { replaygain_update(); if (global_settings.playlist_shuffle) playlist_randomise(NULL, current_tick, true); else playlist_sort(NULL, true); } } return usb; }
/* Get the touched action. * egde_offset is a percentage value for the position of the touch * inside the bar for regions which arnt WPS_TOUCHREGION_ACTION type. */ int skin_get_touchaction(struct wps_data *data, int* edge_offset, struct touchregion **retregion) { int returncode = ACTION_NONE; short x,y; short vx, vy; int type = action_get_touchscreen_press(&x, &y); struct skin_viewport *wvp; struct touchregion *r, *temp = NULL; char* skin_buffer = get_skin_buffer(data); bool repeated = (type == BUTTON_REPEAT); bool released = (type == BUTTON_REL); bool pressed = (type == BUTTON_TOUCHSCREEN); struct skin_token_list *regions = SKINOFFSETTOPTR(skin_buffer, data->touchregions); bool needs_repeat; while (regions) { struct wps_token *token = SKINOFFSETTOPTR(skin_buffer, regions->token); r = SKINOFFSETTOPTR(skin_buffer, token->value.data); wvp = SKINOFFSETTOPTR(skin_buffer, r->wvp); /* make sure this region's viewport is visible */ if (wvp->hidden_flags&VP_DRAW_HIDDEN) { regions = SKINOFFSETTOPTR(skin_buffer, regions->next); continue; } if (data->touchscreen_locked && (r->action != ACTION_TOUCH_SOFTLOCK && !r->allow_while_locked)) { regions = SKINOFFSETTOPTR(skin_buffer, regions->next); continue; } needs_repeat = r->press_length != PRESS; /* check if it's inside this viewport */ if (viewport_point_within_vp(&(wvp->vp), x, y)) { /* reposition the touch inside the viewport since touchregions * are relative to a preceding viewport */ vx = x - wvp->vp.x; vy = y - wvp->vp.y; /* now see if the point is inside this region */ if (vx >= r->x && vx < r->x+r->width && vy >= r->y && vy < r->y+r->height) { /* reposition the touch within the area */ vx -= r->x; vy -= r->y; switch(r->action) { case ACTION_TOUCH_SCROLLBAR: case ACTION_TOUCH_VOLUME: case ACTION_TOUCH_SETTING: if (edge_offset) { struct progressbar *bar = SKINOFFSETTOPTR(skin_buffer, r->bar); if(r->width > r->height) *edge_offset = vx*100/r->width; else *edge_offset = vy*100/r->height; if (r->reverse_bar || (bar && bar->invert_fill_direction)) *edge_offset = 100 - *edge_offset; } temp = r; returncode = r->action; r->last_press = current_tick; break; default: if (r->armed && ((repeated && needs_repeat) || (released && !needs_repeat))) { returncode = r->action; temp = r; } if (pressed) { r->armed = true; r->last_press = current_tick; } break; } } } regions = SKINOFFSETTOPTR(skin_buffer, regions->next); } /* On release, all regions are disarmed. */ if (released) skin_disarm_touchregions(data); if (retregion && temp) *retregion = temp; if (temp && temp->press_length == LONG_PRESS) temp->armed = false; if (returncode != ACTION_NONE) { if (global_settings.party_mode) { switch (returncode) { case ACTION_WPS_PLAY: case ACTION_WPS_SKIPPREV: case ACTION_WPS_SKIPNEXT: case ACTION_WPS_STOP: returncode = ACTION_NONE; break; default: break; } } switch (returncode) { case ACTION_TOUCH_SOFTLOCK: data->touchscreen_locked = !data->touchscreen_locked; returncode = ACTION_NONE; break; case ACTION_WPS_PLAY: if (!audio_status()) { if ( global_status.resume_index != -1 ) { if (playlist_resume() != -1) { playlist_start(global_status.resume_index, global_status.resume_offset); } } else { splash(HZ*2, ID2P(LANG_NOTHING_TO_RESUME)); } } else { wps_do_playpause(false); } returncode = ACTION_REDRAW; break; case ACTION_WPS_SKIPPREV: audio_prev(); returncode = ACTION_REDRAW; break; case ACTION_WPS_SKIPNEXT: audio_next(); returncode = ACTION_REDRAW; break; case ACTION_WPS_STOP: audio_stop(); returncode = ACTION_REDRAW; break; case ACTION_SETTINGS_INC: case ACTION_SETTINGS_DEC: { const struct settings_list *setting = temp->setting_data.setting; option_select_next_val(setting, returncode == ACTION_SETTINGS_DEC, true); returncode = ACTION_REDRAW; } break; case ACTION_SETTINGS_SET: { struct touchsetting *data = &temp->setting_data; const struct settings_list *s = data->setting; void (*f)(int) = NULL; switch (s->flags&F_T_MASK) { case F_T_CUSTOM: s->custom_setting ->load_from_cfg(s->setting, SKINOFFSETTOPTR(skin_buffer, data->value.text)); break; case F_T_INT: case F_T_UINT: *(int*)s->setting = data->value.number; if ((s->flags & F_T_SOUND) == F_T_SOUND) sound_set(s->sound_setting->setting, data->value.number); else if (s->flags&F_CHOICE_SETTING) f = s->choice_setting->option_callback; else if (s->flags&F_TABLE_SETTING) f = s->table_setting->option_callback; else f = s->int_setting->option_callback; if (f) f(data->value.number); break; case F_T_BOOL: *(bool*)s->setting = data->value.number ? true : false; if (s->bool_setting->option_callback) s->bool_setting ->option_callback(data->value.number ? true : false); break; } returncode = ACTION_REDRAW; } break; case ACTION_TOUCH_MUTE: { const int min_vol = sound_min(SOUND_VOLUME); if (global_settings.volume == min_vol) global_settings.volume = temp->value; else { temp->value = global_settings.volume; global_settings.volume = min_vol; } setvol(); returncode = ACTION_REDRAW; } break; case ACTION_TOUCH_SHUFFLE: /* toggle shuffle mode */ { global_settings.playlist_shuffle = !global_settings.playlist_shuffle; replaygain_update(); if (global_settings.playlist_shuffle) playlist_randomise(NULL, current_tick, true); else playlist_sort(NULL, true); returncode = ACTION_REDRAW; } break; case ACTION_TOUCH_REPMODE: /* cycle the repeat mode setting */ { const struct settings_list *rep_setting = find_setting(&global_settings.repeat_mode, NULL); option_select_next_val(rep_setting, false, true); audio_flush_and_reload_tracks(); returncode = ACTION_REDRAW; } break; case ACTION_TOUCH_SETTING: { struct progressbar *bar = SKINOFFSETTOPTR(skin_buffer, temp->bar); if (bar && edge_offset) { int val, count; get_setting_info_for_bar(bar->setting_id, &count, &val); val = *edge_offset * count / 100; update_setting_value_from_touch(bar->setting_id, val); } } break; } return returncode; } return ACTION_TOUCHSCREEN; }
/* Menu of playlist commands. Invoked via ON+PLAY on main viewer screen. Returns -1 if USB attached, 0 if no playlist change, and 1 if playlist changed. */ static int onplay_menu(int index) { int result, ret = 0; struct playlist_entry * current_track = playlist_buffer_get_track(&viewer.buffer, index); MENUITEM_STRINGLIST(menu_items, ID2P(LANG_PLAYLIST), NULL, ID2P(LANG_CURRENT_PLAYLIST), ID2P(LANG_CATALOG), ID2P(LANG_REMOVE), ID2P(LANG_MOVE), ID2P(LANG_SHUFFLE), ID2P(LANG_SAVE_DYNAMIC_PLAYLIST)); bool current = (current_track->index == viewer.current_playing_track); result = do_menu(&menu_items, NULL, NULL, false); if (result == MENU_ATTACHED_USB) { ret = -1; } else if (result >= 0) { /* Abort current move */ viewer.moving_track = -1; viewer.moving_playlist_index = -1; switch (result) { case 0: /* playlist */ onplay_show_playlist_menu(current_track->name); ret = 0; break; case 1: /* add to catalog */ onplay_show_playlist_cat_menu(current_track->name); ret = 0; break; case 2: /* delete track */ playlist_delete(viewer.playlist, current_track->index); if (current) { if (playlist_amount_ex(viewer.playlist) <= 0) audio_stop(); else { /* Start playing new track except if it's the lasttrack track in the playlist and repeat mode is disabled */ current_track = playlist_buffer_get_track(&viewer.buffer, index); if (current_track->display_index!=viewer.num_tracks || global_settings.repeat_mode == REPEAT_ALL) { audio_play(0); viewer.current_playing_track = -1; } } } ret = 1; break; case 3: /* move track */ viewer.moving_track = index; viewer.moving_playlist_index = current_track->index; ret = 0; break; case 4: /* shuffle */ playlist_randomise(viewer.playlist, current_tick, false); ret = 1; break; case 5: /* save playlist */ save_playlist_screen(viewer.playlist); ret = 0; break; } } return ret; }