summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/playback_control.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lib/playback_control.c')
-rw-r--r--apps/plugins/lib/playback_control.c114
1 files changed, 114 insertions, 0 deletions
diff --git a/apps/plugins/lib/playback_control.c b/apps/plugins/lib/playback_control.c
new file mode 100644
index 0000000000..e034ecf120
--- /dev/null
+++ b/apps/plugins/lib/playback_control.c
@@ -0,0 +1,114 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 Jonathan Gordon
11 *
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.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "plugin.h"
21
22struct plugin_api* api = 0;
23
24bool prevtrack(void)
25{
26 api->audio_prev();
27 return false;
28}
29
30bool play(void)
31{
32 if (api->audio_status() & AUDIO_STATUS_PAUSE)
33 api->audio_resume();
34 else
35 api->audio_pause();
36 return false;
37}
38
39bool stop(void)
40{
41 api->audio_stop();
42 return false;
43}
44
45bool nexttrack(void)
46{
47 api->audio_next();
48 return false;
49}
50
51static bool volume(void)
52{
53 return api->set_sound("Volume", &api->global_settings->volume,
54 SOUND_VOLUME);
55}
56
57static bool shuffle(void)
58{
59 struct opt_items names[] = {
60 {"No", NULL},
61 {"Yes", NULL}
62 };
63 return api->set_option("Shuffle", &api->global_settings->playlist_shuffle,
64 BOOL, names, 2,NULL);
65}
66
67static bool repeat_mode(void)
68{
69 bool result;
70 static const struct opt_items names[] = {
71 { "Off", NULL },
72 { "Repeat All", NULL },
73 { "Repeat One", NULL },
74 { "Repeat Shuffle", NULL },
75#ifdef AB_REPEAT_ENABLE
76 { "Repeat A-B", NULL }
77#endif
78 };
79
80 int old_repeat = api->global_settings->repeat_mode;
81
82 result = api->set_option( "Repeat Mode",
83 &api->global_settings->repeat_mode,
84 INT, names, NUM_REPEAT_MODES, NULL );
85
86 if (old_repeat != api->global_settings->repeat_mode &&
87 (api->audio_status() & AUDIO_STATUS_PLAY))
88 api->audio_flush_and_reload_tracks();
89
90 return result;
91}
92
93bool playback_control(struct plugin_api* newapi)
94{
95 int m;
96 api = newapi;
97 bool result;
98
99 static struct menu_item items[] = {
100 { "Previous Track", prevtrack },
101 { "Pause / Play", play },
102 { "Stop Playback", stop },
103 { "Next Track", nexttrack },
104 { "Change Volume", volume },
105 { "Enable/Disable Shuffle", shuffle },
106 { "change Repeat Mode", repeat_mode },
107 };
108
109 m=api->menu_init( items, sizeof(items) / sizeof(*items), NULL,
110 NULL, NULL, NULL);
111 result = api->menu_run(m);
112 api->menu_exit(m);
113 return result;
114}