Build doom on clipv2 and clip+
[kugel-rb.git] / apps / plugins / lib / playback_control.c
blob7c282306423ed0f4b741c42fa8a9a883a93a4aab
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 Jonathan Gordon
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "plugin.h"
23 #include "playback_control.h"
25 struct viewport *parentvp = NULL;
27 static bool prevtrack(void)
29 rb->audio_prev();
30 return false;
33 static bool play(void)
35 int audio_status = rb->audio_status();
36 if (!audio_status && rb->global_status->resume_index != -1)
38 if (rb->playlist_resume() != -1)
40 rb->playlist_start(rb->global_status->resume_index,
41 rb->global_status->resume_offset);
44 else if (audio_status & AUDIO_STATUS_PAUSE)
45 rb->audio_resume();
46 else
47 rb->audio_pause();
48 return false;
51 static bool stop(void)
53 rb->audio_stop();
54 return false;
57 static bool nexttrack(void)
59 rb->audio_next();
60 return false;
63 static bool volume(void)
65 const struct settings_list* vol =
66 rb->find_setting(&rb->global_settings->volume, NULL);
67 return rb->option_screen((struct settings_list*)vol, parentvp, false, "Volume");
70 static bool shuffle(void)
72 const struct settings_list* shuffle =
73 rb->find_setting(&rb->global_settings->playlist_shuffle, NULL);
74 return rb->option_screen((struct settings_list*)shuffle, parentvp, false, "Shuffle");
77 static bool repeat_mode(void)
79 const struct settings_list* repeat =
80 rb->find_setting(&rb->global_settings->repeat_mode, NULL);
81 int old_repeat = rb->global_settings->repeat_mode;
83 rb->option_screen((struct settings_list*)repeat, parentvp, false, "Repeat");
85 if (old_repeat != rb->global_settings->repeat_mode &&
86 (rb->audio_status() & AUDIO_STATUS_PLAY))
87 rb->audio_flush_and_reload_tracks();
89 return false;
91 MENUITEM_FUNCTION(prevtrack_item, 0, "Previous Track",
92 prevtrack, NULL, NULL, Icon_NOICON);
93 MENUITEM_FUNCTION(playpause_item, 0, "Pause / Play",
94 play, NULL, NULL, Icon_NOICON);
95 MENUITEM_FUNCTION(stop_item, 0, "Stop Playback",
96 stop, NULL, NULL, Icon_NOICON);
97 MENUITEM_FUNCTION(nexttrack_item, 0, "Next Track",
98 nexttrack, NULL, NULL, Icon_NOICON);
99 MENUITEM_FUNCTION(volume_item, 0, "Change Volume",
100 volume, NULL, NULL, Icon_NOICON);
101 MENUITEM_FUNCTION(shuffle_item, 0, "Enable/Disable Shuffle",
102 shuffle, NULL, NULL, Icon_NOICON);
103 MENUITEM_FUNCTION(repeat_mode_item, 0, "Change Repeat Mode",
104 repeat_mode, NULL, NULL, Icon_NOICON);
105 MAKE_MENU(playback_control_menu, "Playback Control", NULL, Icon_NOICON,
106 &prevtrack_item, &playpause_item, &stop_item, &nexttrack_item,
107 &volume_item, &shuffle_item, &repeat_mode_item);
109 void playback_control_init(struct viewport parent[NB_SCREENS])
111 parentvp = parent;
114 bool playback_control(struct viewport parent[NB_SCREENS])
116 parentvp = parent;
117 return rb->do_menu(&playback_control_menu, NULL, parent, false) == MENU_ATTACHED_USB;