summaryrefslogtreecommitdiff
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
parentb76e4ec5f27086b8c3b08ef4b2c90d94d93ca83b (diff)
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
-rw-r--r--apps/plugin.c3
-rw-r--r--apps/plugin.h2
-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
-rw-r--r--apps/sound_menu.h1
6 files changed, 144 insertions, 1 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index 51e071020a..f78644f73b 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -43,6 +43,7 @@
#include "backlight.h"
#include "ata.h"
#include "talk.h"
+#include "sound_menu.h"
#include "mp3data.h"
#include "powermgmt.h"
#include "system.h"
@@ -401,7 +402,7 @@ static const struct plugin_api rockbox_api = {
/* new stuff at the end, sort into place next time
the API gets incompatible */
-
+ set_sound,
};
int plugin_load(const char* plugin, void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index 99dd3dc6ea..f046dee50e 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -470,6 +470,8 @@ struct plugin_api {
/* new stuff at the end, sort into place next time
the API gets incompatible */
+ bool (*set_sound)(const unsigned char * string,
+ int* variable, int setting);
};
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 @@
configfile.c
+playback_control.c
#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && (CONFIG_LCD != LCD_IPOD2BPP)
gray_core.c
gray_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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 Jonathan Gordon
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "plugin.h"
+
+struct plugin_api* api = 0;
+
+bool prevtrack(void)
+{
+ api->audio_prev();
+ return false;
+}
+
+bool play(void)
+{
+ if (api->audio_status() & AUDIO_STATUS_PAUSE)
+ api->audio_resume();
+ else
+ api->audio_pause();
+ return false;
+}
+
+bool stop(void)
+{
+ api->audio_stop();
+ return false;
+}
+
+bool nexttrack(void)
+{
+ api->audio_next();
+ return false;
+}
+
+static bool volume(void)
+{
+ return api->set_sound("Volume", &api->global_settings->volume,
+ SOUND_VOLUME);
+}
+
+static bool shuffle(void)
+{
+ struct opt_items names[] = {
+ {"No", NULL},
+ {"Yes", NULL}
+ };
+ return api->set_option("Shuffle", &api->global_settings->playlist_shuffle,
+ BOOL, names, 2,NULL);
+}
+
+static bool repeat_mode(void)
+{
+ bool result;
+ static const struct opt_items names[] = {
+ { "Off", NULL },
+ { "Repeat All", NULL },
+ { "Repeat One", NULL },
+ { "Repeat Shuffle", NULL },
+#ifdef AB_REPEAT_ENABLE
+ { "Repeat A-B", NULL }
+#endif
+ };
+
+ int old_repeat = api->global_settings->repeat_mode;
+
+ result = api->set_option( "Repeat Mode",
+ &api->global_settings->repeat_mode,
+ INT, names, NUM_REPEAT_MODES, NULL );
+
+ if (old_repeat != api->global_settings->repeat_mode &&
+ (api->audio_status() & AUDIO_STATUS_PLAY))
+ api->audio_flush_and_reload_tracks();
+
+ return result;
+}
+
+bool playback_control(struct plugin_api* newapi)
+{
+ int m;
+ api = newapi;
+ bool result;
+
+ static struct menu_item items[] = {
+ { "Previous Track", prevtrack },
+ { "Pause / Play", play },
+ { "Stop Playback", stop },
+ { "Next Track", nexttrack },
+ { "Change Volume", volume },
+ { "Enable/Disable Shuffle", shuffle },
+ { "change Repeat Mode", repeat_mode },
+ };
+
+ m=api->menu_init( items, sizeof(items) / sizeof(*items), NULL,
+ NULL, NULL, NULL);
+ result = api->menu_run(m);
+ api->menu_exit(m);
+ return result;
+}
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 Jonathan Gordon
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef __PLAYBACK_CONTROL_H__
+#define __PLAYBACK_CONTROL_H__
+
+bool playback_control(struct plugin_api* api);
+
+#endif /* __PLAYBACK_CONTROL_H__ */
diff --git a/apps/sound_menu.h b/apps/sound_menu.h
index 4d295b0a70..4e85b9c03c 100644
--- a/apps/sound_menu.h
+++ b/apps/sound_menu.h
@@ -24,5 +24,6 @@
bool sound_menu(void);
bool recording_menu(bool no_source);
bool rectrigger(void);
+bool set_sound(const unsigned char * string, int* variable, int setting);
#endif