ashuffle
ashuffle copied to clipboard
Automatically reconnect to MPD without exiting
Is there a way for ashuffle to just attempt to reconnect without exiting? Probably more of a niche requirement, but if mpd is adjusted and restarted, of course ashuffle will exit, taking with it the in-memory lists to prevent playing the same song too soon.
Presently, I run it like this to help make sure it stays running if I happen to restart mpd:
while :; do ./ashuffle --tweak window-size=50 --queue-buffer 1; sleep 1; done
Absolutely love this idea and execution. The ability to still enqueue whatever you want with any other mpd client and fall back on a nice shuffle without managing playlists is AWESOME. Thank you for this! :+1: :+1:
This seems like a great idea. Having ashuffle
exit on all server failures was an easy choice when this was a little script, but it's probably time we properly handle reconnects.
... taking with it the in-memory lists to prevent playing the same song too soon.
This is actually something we don't even handle today on database reloads, but it would be a nice thing to add. I guess with the default 7 song window, some repeats are expected, but with a 50 song window like you're using here, you'd notice if the window was dropped. Keeping this around is a bit tricky, since we don't know if there's a been a database update since the last connection, we should probably refresh the shuffle chain, so we'll have to have a way to unify the loaded items with the existing items.
MPD also exports a db_update
time in the stats
command, so we can probably add an optimization to skip the reload most of the time. Or maybe only drop the window when the songs need to be updated. That will probably work in 90% of the cases and be a lot easier to get an initial implementation for.
Thank you for this!
Absolutely. glad you find it useful!
Ah I'm glad the idea isn't too frivolous! I misunderstood the repeat-window, I've actually done tons of mpd db reloads due to a vast amount of sorting/renaming as of late, and ashuffle is shuffley enough I hadn't noticed the window disappearing :grin: Longer listen sessions while out on the road did reveal the default value of '7' was a bit lean, hence the bump to 50.
The other unmentioned reason I had for auto reconnecting to mpd, would be so I can treat it like a daemon and fire it up on system startup. I built a copy of ashuffle on OpenBSD and now have the intention of making it a package for other users, complete with an /etc/rc.d/ashuffle
script for starting at bootup.
This has finally been added in release v3.14.1