2006-03-26 22:33:25 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Jonathan Gordon
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2006-03-26 22:33:25 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "plugin.h"
|
2008-05-04 13:21:07 +00:00
|
|
|
#include "playback_control.h"
|
2006-03-26 22:33:25 +00:00
|
|
|
|
2008-04-23 11:07:40 +00:00
|
|
|
struct viewport *parentvp = NULL;
|
2006-03-26 22:33:25 +00:00
|
|
|
|
2008-05-04 13:21:07 +00:00
|
|
|
static bool prevtrack(void)
|
2006-03-26 22:33:25 +00:00
|
|
|
{
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->audio_prev();
|
2006-03-26 22:33:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-05-04 13:21:07 +00:00
|
|
|
static bool play(void)
|
2006-03-26 22:33:25 +00:00
|
|
|
{
|
2009-01-16 10:34:40 +00:00
|
|
|
int audio_status = rb->audio_status();
|
|
|
|
if (!audio_status && rb->global_status->resume_index != -1)
|
2007-03-12 13:41:52 +00:00
|
|
|
{
|
2009-01-16 10:34:40 +00:00
|
|
|
if (rb->playlist_resume() != -1)
|
2007-03-12 13:41:52 +00:00
|
|
|
{
|
2012-12-09 20:04:17 +00:00
|
|
|
rb->playlist_resume_track(rb->global_status->resume_index,
|
|
|
|
rb->global_status->resume_crc32,
|
2013-07-14 11:59:39 +00:00
|
|
|
rb->global_status->resume_elapsed,
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->global_status->resume_offset);
|
2007-03-12 13:41:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (audio_status & AUDIO_STATUS_PAUSE)
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->audio_resume();
|
2006-03-26 22:33:25 +00:00
|
|
|
else
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->audio_pause();
|
2006-03-26 22:33:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-05-04 13:21:07 +00:00
|
|
|
static bool stop(void)
|
2006-03-26 22:33:25 +00:00
|
|
|
{
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->audio_stop();
|
2006-03-26 22:33:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-05-04 13:21:07 +00:00
|
|
|
static bool nexttrack(void)
|
2006-03-26 22:33:25 +00:00
|
|
|
{
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->audio_next();
|
2006-03-26 22:33:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool volume(void)
|
|
|
|
{
|
2007-07-11 05:41:23 +00:00
|
|
|
const struct settings_list* vol =
|
2022-11-30 14:50:18 +00:00
|
|
|
rb->find_setting(&rb->global_settings->volume);
|
2009-01-16 10:34:40 +00:00
|
|
|
return rb->option_screen((struct settings_list*)vol, parentvp, false, "Volume");
|
2006-03-26 22:33:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool shuffle(void)
|
|
|
|
{
|
2007-07-11 05:41:23 +00:00
|
|
|
const struct settings_list* shuffle =
|
2022-11-30 14:50:18 +00:00
|
|
|
rb->find_setting(&rb->global_settings->playlist_shuffle);
|
2009-01-16 10:34:40 +00:00
|
|
|
return rb->option_screen((struct settings_list*)shuffle, parentvp, false, "Shuffle");
|
2006-03-26 22:33:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool repeat_mode(void)
|
|
|
|
{
|
2007-07-11 05:41:23 +00:00
|
|
|
const struct settings_list* repeat =
|
2022-11-30 14:50:18 +00:00
|
|
|
rb->find_setting(&rb->global_settings->repeat_mode);
|
2009-01-16 10:34:40 +00:00
|
|
|
int old_repeat = rb->global_settings->repeat_mode;
|
2007-07-11 05:41:23 +00:00
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->option_screen((struct settings_list*)repeat, parentvp, false, "Repeat");
|
2007-07-11 05:41:23 +00:00
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
if (old_repeat != rb->global_settings->repeat_mode &&
|
|
|
|
(rb->audio_status() & AUDIO_STATUS_PLAY))
|
|
|
|
rb->audio_flush_and_reload_tracks();
|
2007-07-11 05:41:23 +00:00
|
|
|
|
|
|
|
return false;
|
2006-03-26 22:33:25 +00:00
|
|
|
}
|
2019-02-04 01:12:50 +00:00
|
|
|
MENUITEM_FUNCTION(prevtrack_item, 0, ID2P(LANG_PREVTRACK),
|
2022-12-17 08:27:21 +00:00
|
|
|
prevtrack, NULL, Icon_NOICON);
|
2019-02-04 01:12:50 +00:00
|
|
|
MENUITEM_FUNCTION(playpause_item, 0, ID2P(LANG_PLAYPAUSE),
|
2022-12-17 08:27:21 +00:00
|
|
|
play, NULL, Icon_NOICON);
|
2019-02-04 01:12:50 +00:00
|
|
|
MENUITEM_FUNCTION(stop_item, 0, ID2P(LANG_STOP_PLAYBACK),
|
2022-12-17 08:27:21 +00:00
|
|
|
stop, NULL, Icon_NOICON);
|
2019-02-04 01:12:50 +00:00
|
|
|
MENUITEM_FUNCTION(nexttrack_item, 0, ID2P(LANG_NEXTTRACK),
|
2022-12-17 08:27:21 +00:00
|
|
|
nexttrack, NULL, Icon_NOICON);
|
2019-02-04 01:12:50 +00:00
|
|
|
MENUITEM_FUNCTION(volume_item, 0, ID2P(LANG_CHANGE_VOLUME),
|
2022-12-17 08:27:21 +00:00
|
|
|
volume, NULL, Icon_NOICON);
|
2019-02-04 01:12:50 +00:00
|
|
|
MENUITEM_FUNCTION(shuffle_item, 0, ID2P(LANG_CHANGE_SHUFFLE_MODE),
|
2022-12-17 08:27:21 +00:00
|
|
|
shuffle, NULL, Icon_NOICON);
|
2019-02-04 01:12:50 +00:00
|
|
|
MENUITEM_FUNCTION(repeat_mode_item, 0, ID2P(LANG_CHANGE_REPEAT_MODE),
|
2022-12-17 08:27:21 +00:00
|
|
|
repeat_mode, NULL, Icon_NOICON);
|
2019-02-04 01:12:50 +00:00
|
|
|
MAKE_MENU(playback_control_menu, ID2P(LANG_PLAYBACK_CONTROL), NULL, Icon_NOICON,
|
2007-03-26 09:14:16 +00:00
|
|
|
&prevtrack_item, &playpause_item, &stop_item, &nexttrack_item,
|
|
|
|
&volume_item, &shuffle_item, &repeat_mode_item);
|
2006-03-26 22:33:25 +00:00
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
void playback_control_init(struct viewport parent[NB_SCREENS])
|
2006-03-26 22:33:25 +00:00
|
|
|
{
|
2008-04-23 11:07:40 +00:00
|
|
|
parentvp = parent;
|
2007-03-26 09:14:16 +00:00
|
|
|
}
|
2006-03-26 22:33:25 +00:00
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
bool playback_control(struct viewport parent[NB_SCREENS])
|
2007-03-26 09:14:16 +00:00
|
|
|
{
|
2008-04-23 11:07:40 +00:00
|
|
|
parentvp = parent;
|
2009-01-16 10:34:40 +00:00
|
|
|
return rb->do_menu(&playback_control_menu, NULL, parent, false) == MENU_ATTACHED_USB;
|
2006-03-26 22:33:25 +00:00
|
|
|
}
|