mirror of
https://github.com/SuperBFG7/ympd
synced 2024-09-28 06:18:13 +00:00
Feat: add AutoPlay setting
Feat: configurable backgroundcolor
This commit is contained in:
parent
377be765c3
commit
535595c7f8
@ -64,6 +64,7 @@ post_upgrade() {
|
||||
[ -f /var/lib/mympd/state/jukeboxMode ] || echo -n "0" > /var/lib/mympd/state/jukeboxMode
|
||||
[ -f /var/lib/mympd/state/jukeboxPlaylist ] || echo -n "Database" > /var/lib/mympd/state/jukeboxPlaylist
|
||||
[ -f /var/lib/mympd/state/jukeboxQueueLength ] || echo -n "1" > /var/lib/mympd/state/jukeboxQueueLength
|
||||
[ -f /var/lib/mympd/state/autoPlay ] || echo -n "false" > /var/lib/mympd/state/autoPlay
|
||||
[ -f /var/lib/mympd/state/notificationPage ] || echo -n "true" > /var/lib/mympd/state/notificationPage
|
||||
[ -f /var/lib/mympd/state/notificationWeb ] || echo -n "false" > /var/lib/mympd/state/notificationWeb
|
||||
[ -f /var/lib/mympd/state/colsBrowseDatabase ] || echo -n '["Track","Title","Duration"]' > /var/lib/mympd/state/colsBrowseDatabase
|
||||
|
@ -79,6 +79,7 @@ done
|
||||
[ -f /var/lib/mympd/state/jukeboxMode ] || echo -n "0" > /var/lib/mympd/state/jukeboxMode
|
||||
[ -f /var/lib/mympd/state/jukeboxPlaylist ] || echo -n "Database" > /var/lib/mympd/state/jukeboxPlaylist
|
||||
[ -f /var/lib/mympd/state/jukeboxQueueLength ] || echo -n "1" > /var/lib/mympd/state/jukeboxQueueLength
|
||||
[ -f /var/lib/mympd/state/autoPlay ] || echo -n "false" > /var/lib/mympd/state/autoPlay
|
||||
[ -f /var/lib/mympd/state/notificationPage ] || echo -n "true" > /var/lib/mympd/state/notificationPage
|
||||
[ -f /var/lib/mympd/state/notificationWeb ] || echo -n "false" > /var/lib/mympd/state/notificationWeb
|
||||
[ -f /var/lib/mympd/state/colsBrowseDatabase ] || echo -n '["Track","Title","Duration"]' > /var/lib/mympd/state/colsBrowseDatabase
|
||||
|
@ -72,3 +72,7 @@ max_elements_per_page = 100
|
||||
|
||||
#Number of songs to keep in last played list
|
||||
last_played_count = 20
|
||||
|
||||
|
||||
[theme]
|
||||
backgroundcolor: #888
|
||||
|
1
debian/postinst
vendored
1
debian/postinst
vendored
@ -59,6 +59,7 @@ fi
|
||||
[ -f /var/lib/mympd/state/jukeboxMode ] || echo -n "0" > /var/lib/mympd/state/jukeboxMode
|
||||
[ -f /var/lib/mympd/state/jukeboxPlaylist ] || echo -n "Database" > /var/lib/mympd/state/jukeboxPlaylist
|
||||
[ -f /var/lib/mympd/state/jukeboxQueueLength ] || echo -n "1" > /var/lib/mympd/state/jukeboxQueueLength
|
||||
[ -f /var/lib/mympd/state/autoPlay ] || echo -n "false" > /var/lib/mympd/state/autoPlay
|
||||
[ -f /var/lib/mympd/state/notificationPage ] || echo -n "true" > /var/lib/mympd/state/notificationPage
|
||||
[ -f /var/lib/mympd/state/notificationWeb ] || echo -n "false" > /var/lib/mympd/state/notificationWeb
|
||||
[ -f /var/lib/mympd/state/colsBrowseDatabase ] || echo -n '["Track","Title","Duration"]' > /var/lib/mympd/state/colsBrowseDatabase
|
||||
|
@ -1,5 +1,6 @@
|
||||
:root {
|
||||
--mympd-coverimagesize: 240px;
|
||||
--mympd-bacgkroundcolor: #888;
|
||||
}
|
||||
|
||||
html {
|
||||
@ -11,6 +12,7 @@ body {
|
||||
padding-top: 4rem;
|
||||
padding-bottom: 4rem;
|
||||
background-color: #888;
|
||||
background-color: var(--mympd-backgroundcolor);
|
||||
}
|
||||
|
||||
main {
|
||||
|
@ -903,6 +903,13 @@
|
||||
<div class="invalid-feedback">Must be a number.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6" data-toggle="buttons">
|
||||
<button data-href='{"cmd": "toggleBtn", "options": ["btnAutoPlay"]}' id="btnAutoPlay" type="button" class="btn btn-secondary btn-block" title="Start playing after first song is added to the queue">
|
||||
AutoPlay
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<h4>Jukebox</h4>
|
||||
<div class="row">
|
||||
|
@ -281,7 +281,7 @@ function appRoute() {
|
||||
var breadcrumbItemsLen = breadcrumbItems.length;
|
||||
for (var i = 0; i < breadcrumbItemsLen; i++) {
|
||||
breadcrumbItems[i].addEventListener('click', function() {
|
||||
appGoto('Browse', 'Filesystem', undefined, '0/' + app.current.filter + '/' + this.getAttribute('data-uri'));
|
||||
appGoto('Browse', 'Filesystem', undefined, '0/' + app.current.filter + '/' + app.current.sort + '/' + this.getAttribute('data-uri'));
|
||||
}, false);
|
||||
}
|
||||
doSetFilterLetter('BrowseFilesystemFilter');
|
||||
@ -576,7 +576,7 @@ function appInit() {
|
||||
if (event.target.nodeName == 'TD') {
|
||||
switch(event.target.parentNode.getAttribute('data-type')) {
|
||||
case 'dir':
|
||||
appGoto('Browse', 'Filesystem', undefined, '0/' + app.current.filter +'/' + decodeURI(event.target.parentNode.getAttribute("data-uri")));
|
||||
appGoto('Browse', 'Filesystem', undefined, '0/' + app.current.filter + app.current.sort + '/' +'/' + decodeURI(event.target.parentNode.getAttribute("data-uri")));
|
||||
break;
|
||||
case 'song':
|
||||
appendQueue('song', decodeURI(event.target.parentNode.getAttribute("data-uri")), event.target.parentNode.getAttribute("data-name"));
|
||||
@ -611,7 +611,7 @@ function appInit() {
|
||||
|
||||
document.getElementById('BrowseDatabaseTagList').addEventListener('click', function(event) {
|
||||
if (event.target.nodeName == 'TD') {
|
||||
appGoto('Browse', 'Database', app.current.view, '0/-/' + event.target.parentNode.getAttribute('data-uri'));
|
||||
appGoto('Browse', 'Database', app.current.view, '0/-/-/' + event.target.parentNode.getAttribute('data-uri'));
|
||||
}
|
||||
}, false);
|
||||
|
||||
@ -671,12 +671,12 @@ function appInit() {
|
||||
if (event.key == 'Escape')
|
||||
this.blur();
|
||||
else
|
||||
appGoto(app.current.app, app.current.tab, app.current.view, '0/' + app.current.filter + '/' + this.value);
|
||||
appGoto(app.current.app, app.current.tab, app.current.view, '0/' + app.current.filter + app.current.sort + '/' + '/' + this.value);
|
||||
}, false);
|
||||
|
||||
document.getElementById('searchqueuetags').addEventListener('click', function(event) {
|
||||
if (event.target.nodeName == 'BUTTON')
|
||||
appGoto(app.current.app, app.current.tab, app.current.view, app.current.page + '/' + event.target.getAttribute('data-tag') + '/' + app.current.search);
|
||||
appGoto(app.current.app, app.current.tab, app.current.view, app.current.page + '/' + event.target.getAttribute('data-tag') + app.current.sort + '/' + '/' + app.current.search);
|
||||
}, false);
|
||||
|
||||
var dropdowns = ['QueueCurrentColsDropdown', 'BrowseFilesystemColsDropdown', 'SearchColsDropdown', 'BrowsePlaylistsDetailColsDropdown',
|
||||
@ -780,7 +780,7 @@ function appInit() {
|
||||
|
||||
document.getElementById('BrowseDatabaseByTagDropdown').addEventListener('click', function(event) {
|
||||
if (event.target.nodeName == 'BUTTON')
|
||||
appGoto(app.current.app, app.current.tab, event.target.getAttribute('data-tag') , '0/' + app.current.filter + '/' + app.current.search);
|
||||
appGoto(app.current.app, app.current.tab, event.target.getAttribute('data-tag') , '0/' + app.current.filter + app.current.sort + '/' + '/' + app.current.search);
|
||||
}, false);
|
||||
|
||||
document.getElementsByTagName('body')[0].addEventListener('click', function(event) {
|
||||
@ -1211,6 +1211,7 @@ function parseSettings() {
|
||||
toggleBtn('btnConsume', settings.consume);
|
||||
toggleBtn('btnSingle', settings.single);
|
||||
toggleBtn('btnRepeat', settings.repeat);
|
||||
toggleBtn('btnAutoPlay', settings.autoPlay);
|
||||
|
||||
if (settings.crossfade != undefined) {
|
||||
document.getElementById('inputCrossfade').removeAttribute('disabled');
|
||||
@ -1261,6 +1262,7 @@ function parseSettings() {
|
||||
var features = ["featStickers", "featSmartpls", "featPlaylists", "featTags", "featLocalplayer", "featSyscmds", "featCoverimage", "featAdvsearch"];
|
||||
|
||||
document.documentElement.style.setProperty('--mympd-coverimagesize', settings.coverimagesize + "px");
|
||||
document.documentElement.style.setProperty('--mympd-backgroundcolor', settings.backgroundcolor);
|
||||
|
||||
for (var j = 0; j < features.length; j++) {
|
||||
var Els = document.getElementsByClassName(features[j]);
|
||||
@ -2967,7 +2969,8 @@ function confirmSettings() {
|
||||
"notificationPage": (document.getElementById('btnnotifyPage').classList.contains('active') ? true : false),
|
||||
"jukeboxMode": selectJukeboxMode.options[selectJukeboxMode.selectedIndex].value,
|
||||
"jukeboxPlaylist": selectJukeboxPlaylist.options[selectJukeboxPlaylist.selectedIndex].value,
|
||||
"jukeboxQueueLength": document.getElementById('inputJukeboxQueueLength').value
|
||||
"jukeboxQueueLength": document.getElementById('inputJukeboxQueueLength').value,
|
||||
"autoPlay": (document.getElementById('btnAutoPlay').classList.contains('active') ? true : false)
|
||||
}}, getSettings);
|
||||
modalSettings.hide();
|
||||
} else
|
||||
|
@ -184,6 +184,7 @@ typedef struct t_config {
|
||||
const char *streamurl;
|
||||
unsigned long last_played_count;
|
||||
long loglevel;
|
||||
const char *backgroundcolor;
|
||||
} t_config;
|
||||
|
||||
//global functions
|
||||
|
@ -134,6 +134,8 @@ static int inihandler(void *user, const char *section, const char *name, const c
|
||||
p_config->last_played_count = strtol(value, &crap, 10);
|
||||
else if (MATCH("mympd", "loglevel"))
|
||||
p_config->loglevel = strtol(value, &crap, 10);
|
||||
else if (MATCH("theme", "backgroundcolor"))
|
||||
p_config->backgroundcolor = strdup(value);
|
||||
else {
|
||||
printf("Unkown config option: %s - %s\n", section, name);
|
||||
return 0; /* unknown section/name, error */
|
||||
@ -182,6 +184,7 @@ int main(int argc, char **argv) {
|
||||
config.syscmds = false;
|
||||
config.localplayer = true;
|
||||
config.loglevel = 1;
|
||||
config.backgroundcolor = "#888";
|
||||
|
||||
if (argc == 2) {
|
||||
printf("Starting myMPD %s\n", MYMPD_VERSION);
|
||||
|
@ -107,6 +107,7 @@ typedef struct t_mpd_state {
|
||||
enum jukebox_modes jukeboxMode;
|
||||
const char *jukeboxPlaylist;
|
||||
int jukeboxQueueLength;
|
||||
bool autoPlay;
|
||||
|
||||
//taglists
|
||||
struct list mpd_tags;
|
||||
@ -255,6 +256,7 @@ static void mpd_client_api(t_config *config, t_mpd_state *mpd_state, void *arg_r
|
||||
je = json_scanf(request->data, request->length, "{data: {jukeboxMode: %d}}", &mpd_state->jukeboxMode);
|
||||
je = json_scanf(request->data, request->length, "{data: {jukeboxPlaylist: %Q}}", &mpd_state->jukeboxPlaylist);
|
||||
je = json_scanf(request->data, request->length, "{data: {jukeboxQueueLength: %d}}", &mpd_state->jukeboxQueueLength);
|
||||
je = json_scanf(request->data, request->length, "{data: {autoPlay: %B}}", &mpd_state->autoPlay);
|
||||
//set mpd options
|
||||
je = json_scanf(request->data, request->length, "{data: {random: %u}}", &uint_buf1);
|
||||
if (je == 1) {
|
||||
@ -929,8 +931,14 @@ static void mpd_client_parse_idle(t_config *config, t_mpd_state *mpd_state, int
|
||||
break;
|
||||
case MPD_IDLE_QUEUE:
|
||||
len = snprintf(buffer, MAX_SIZE, "{\"type\": \"update_queue\"}");
|
||||
//jukebox enabled
|
||||
if (mpd_state->jukeboxMode != JUKEBOX_OFF)
|
||||
mpd_client_jukebox(config, mpd_state);
|
||||
//autoPlay enabled
|
||||
if (mpd_state->autoPlay == true) {
|
||||
LOG_VERBOSE() printf("AutoPlay enabled, start playing");
|
||||
mpd_run_play(mpd_state->conn);
|
||||
}
|
||||
break;
|
||||
case MPD_IDLE_PLAYER:
|
||||
len = mpd_client_put_state(mpd_state, buffer);
|
||||
|
@ -50,6 +50,8 @@ typedef struct t_mympd_state {
|
||||
char *jukeboxPlaylist;
|
||||
int jukeboxQueueLength;
|
||||
|
||||
bool autoPlay;
|
||||
|
||||
//columns
|
||||
char *colsQueueCurrent;
|
||||
char *colsSearch;
|
||||
@ -187,6 +189,11 @@ static void mympd_api(t_config *config, t_mympd_state *mympd_state, t_work_reque
|
||||
if (!state_file_write(config, "notificationPage", (mympd_state->notificationPage == true ? "true" : "false")))
|
||||
len = snprintf(buffer, MAX_SIZE, "{\"type\": \"error\", \"data\": \"Can't set state notificationPage.\"}");
|
||||
}
|
||||
je = json_scanf(request->data, request->length, "{data: {autoPlay: %B}}", &mympd_state->autoPlay);
|
||||
if (je == 1) {
|
||||
if (!state_file_write(config, "autoPlay", (mympd_state->autoPlay == true ? "true" : "false")))
|
||||
len = snprintf(buffer, MAX_SIZE, "{\"type\": \"error\", \"data\": \"Can't set state autoPlay.\"}");
|
||||
}
|
||||
je = json_scanf(request->data, request->length, "{data: {jukeboxMode: %d}}", &mympd_state->jukeboxMode);
|
||||
if (je == 1) {
|
||||
snprintf(p_char, 4, "%d", mympd_state->jukeboxMode);
|
||||
@ -335,6 +342,17 @@ static void mympd_api_read_statefiles(t_config *config, t_mympd_state *mympd_sta
|
||||
state_file_write(config, "notificationPage", "true");
|
||||
}
|
||||
|
||||
if (state_file_read(config, "autoPlay", value)) {
|
||||
if (strcmp(value, "true") == 0)
|
||||
mympd_state->autoPlay = true;
|
||||
else
|
||||
mympd_state->autoPlay = false;
|
||||
}
|
||||
else {
|
||||
mympd_state->autoPlay = false;
|
||||
state_file_write(config, "autoPlay", "false");
|
||||
}
|
||||
|
||||
if (state_file_read(config, "jukeboxMode", value))
|
||||
mympd_state->jukeboxMode = strtol(value, &crap, 10);
|
||||
else {
|
||||
@ -413,7 +431,8 @@ static int mympd_api_put_settings(t_config *config, t_mympd_state *mympd_state,
|
||||
|
||||
len = json_printf(&out, "{type: mympdSettings, data: {mpdhost: %Q, mpdport: %d, passwort_set: %B, featSyscmds: %B, "
|
||||
"featLocalplayer: %B, streamport: %d, streamurl: %Q, featCoverimage: %B, coverimagename: %Q, coverimagesize: %d, featMixramp: %B, "
|
||||
"maxElementsPerPage: %d, notificationWeb: %B, notificationPage: %B, jukeboxMode: %d, jukeboxPlaylist: %Q, jukeboxQueueLength: %d",
|
||||
"maxElementsPerPage: %d, notificationWeb: %B, notificationPage: %B, jukeboxMode: %d, jukeboxPlaylist: %Q, jukeboxQueueLength: %d, "
|
||||
"autoPlay: %B, backgroundcolor: %Q",
|
||||
config->mpdhost,
|
||||
config->mpdport,
|
||||
config->mpdpass ? "true" : "false",
|
||||
@ -430,7 +449,9 @@ static int mympd_api_put_settings(t_config *config, t_mympd_state *mympd_state,
|
||||
mympd_state->notificationPage,
|
||||
mympd_state->jukeboxMode,
|
||||
mympd_state->jukeboxPlaylist,
|
||||
mympd_state->jukeboxQueueLength
|
||||
mympd_state->jukeboxQueueLength,
|
||||
mympd_state->autoPlay,
|
||||
config->backgroundcolor
|
||||
);
|
||||
|
||||
if (config->syscmds == true) {
|
||||
|
Loading…
Reference in New Issue
Block a user