1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 Jonathan Gordon
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
21 #include "playback_control.h"
23 const struct plugin_api
* api
= 0;
24 struct viewport
*parentvp
= NULL
;
26 static bool prevtrack(void)
32 static bool play(void)
34 int audio_status
= api
->audio_status();
35 if (!audio_status
&& api
->global_status
->resume_index
!= -1)
37 if (api
->playlist_resume() != -1)
39 api
->playlist_start(api
->global_status
->resume_index
,
40 api
->global_status
->resume_offset
);
43 else if (audio_status
& AUDIO_STATUS_PAUSE
)
50 static bool stop(void)
56 static bool nexttrack(void)
62 static bool volume(void)
64 const struct settings_list
* vol
=
65 api
->find_setting(&api
->global_settings
->volume
, NULL
);
66 return api
->option_screen((struct settings_list
*)vol
, parentvp
, false, "Volume");
69 static bool shuffle(void)
71 const struct settings_list
* shuffle
=
72 api
->find_setting(&api
->global_settings
->playlist_shuffle
, NULL
);
73 return api
->option_screen((struct settings_list
*)shuffle
, parentvp
, false, "Shuffle");
76 static bool repeat_mode(void)
78 const struct settings_list
* repeat
=
79 api
->find_setting(&api
->global_settings
->repeat_mode
, NULL
);
80 int old_repeat
= api
->global_settings
->repeat_mode
;
82 api
->option_screen((struct settings_list
*)repeat
, parentvp
, false, "Repeat");
84 if (old_repeat
!= api
->global_settings
->repeat_mode
&&
85 (api
->audio_status() & AUDIO_STATUS_PLAY
))
86 api
->audio_flush_and_reload_tracks();
90 MENUITEM_FUNCTION(prevtrack_item
, 0, "Previous Track",
91 prevtrack
, NULL
, NULL
, Icon_NOICON
);
92 MENUITEM_FUNCTION(playpause_item
, 0, "Pause / Play",
93 play
, NULL
, NULL
, Icon_NOICON
);
94 MENUITEM_FUNCTION(stop_item
, 0, "Stop Playback",
95 stop
, NULL
, NULL
, Icon_NOICON
);
96 MENUITEM_FUNCTION(nexttrack_item
, 0, "Next Track",
97 nexttrack
, NULL
, NULL
, Icon_NOICON
);
98 MENUITEM_FUNCTION(volume_item
, 0, "Change Volume",
99 volume
, NULL
, NULL
, Icon_NOICON
);
100 MENUITEM_FUNCTION(shuffle_item
, 0, "Enable/Disable Shuffle",
101 shuffle
, NULL
, NULL
, Icon_NOICON
);
102 MENUITEM_FUNCTION(repeat_mode_item
, 0, "Change Repeat Mode",
103 repeat_mode
, NULL
, NULL
, Icon_NOICON
);
104 MAKE_MENU(playback_control_menu
, "Playback Control", NULL
, Icon_NOICON
,
105 &prevtrack_item
, &playpause_item
, &stop_item
, &nexttrack_item
,
106 &volume_item
, &shuffle_item
, &repeat_mode_item
);
108 void playback_control_init(const struct plugin_api
* newapi
,
109 struct viewport parent
[NB_SCREENS
])
115 bool playback_control(const struct plugin_api
* newapi
,
116 struct viewport parent
[NB_SCREENS
])
120 return api
->do_menu(&playback_control_menu
, NULL
, parent
, false) == MENU_ATTACHED_USB
;