summaryrefslogtreecommitdiff
path: root/apps/plugins/lib
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2006-03-26 22:33:25 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2006-03-26 22:33:25 +0000
commit6f4d721d23946632d2a428884ee990e61f43434e (patch)
treec718808a35ab00d7e8b189d4e52690621dfbcbcb /apps/plugins/lib
parentb76e4ec5f27086b8c3b08ef4b2c90d94d93ca83b (diff)
downloadrockbox-6f4d721d23946632d2a428884ee990e61f43434e.tar.gz
rockbox-6f4d721d23946632d2a428884ee990e61f43434e.zip
Basic plugin playback control menu by Jonathan Gordon (Patch #4874)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9269 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib')
-rw-r--r--apps/plugins/lib/SOURCES1
-rw-r--r--apps/plugins/lib/playback_control.c114
-rw-r--r--apps/plugins/lib/playback_control.h24
3 files changed, 139 insertions, 0 deletions
diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES
index f0930269f7..81cdc8c944 100644
--- a/apps/plugins/lib/SOURCES
+++ b/apps/plugins/lib/SOURCES
@@ -1,4 +1,5 @@
1configfile.c 1configfile.c
2playback_control.c
2#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && (CONFIG_LCD != LCD_IPOD2BPP) 3#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && (CONFIG_LCD != LCD_IPOD2BPP)
3gray_core.c 4gray_core.c
4gray_draw.c 5gray_draw.c
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}
diff --git a/apps/plugins/lib/playback_control.h b/apps/plugins/lib/playback_control.h
new file mode 100644
index 0000000000..a259fc9194
--- /dev/null
+++ b/apps/plugins/lib/playback_control.h
@@ -0,0 +1,24 @@
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#ifndef __PLAYBACK_CONTROL_H__
20#define __PLAYBACK_CONTROL_H__
21
22bool playback_control(struct plugin_api* api);
23
24#endif /* __PLAYBACK_CONTROL_H__ */