Autopause after x minutes or x song count

Folks; thanks in advance for the help... I have a little project that I'm working on for my young son with some motor skill disabilities. In a nutshell, I'm building him a tiny ex-thin client linux box that will be his jukebox for playing music at night. I have also built a large button that functions basically as a huge single-key USB keyboard that (on my mac, at least) works great as a play/pause button. The goal is this - I can set the box up to run in command line with MOC running, MOC looks for the specified directory, in my case a mounted thumb drive, allowing me to add or subtract music by pulling the drive... or possibly networking it if I get ambitious.

Long story short, I want him to be able to hit the button and start the music, then go to sleep and have the songs, which up till this point have been playing in an endless (possibly random) loop to pause after a specified amount of time, like 30 minutes or an hour. Then, if he wakes up in the night, he can simply hit the giant button next to his bed and start the music playing again, for another 30 minutes or whatever.

I'm a total newb at scripting, but I can see two angles to this - some settings inside of MOC that will allow for a certain number of minutes or songs to play before pausing or else setting up a script that will keep track of a timer and then startup/shutdown MOC appropriately.

I suppose I could set up a playlist of the correct duration and have it cease at the end, but I would LOVE the flexibility to hand the player a list of 4 gigs of songs and have it just pull randomly without having to manually create lists to suit the fickle whims of a child.

At the end of it all, I want a small box that hides behind a dresser with a single button mounted to the wall and some speakers that plays music for 30 minutes at a time when you press the button. It would also be awesome if pressing the button paused mid-play run.


This is certainly doable. Assuming you can attach a script to the button, I'd do it as a background job which loops around a sleep(1) keeping track of the time. It can use MOC's -Q, -P and -U options to control the MOC server. It decides what to do based on signals received from the script(s) attached to the button(s) and the server's current state.

But this is more than entry-level scripting. I don't have the time to do it right now, but if no one has provided a solution by the time I'm able to then I will.

I don't know what happened here. We were discussing "harveyscoffee"'s requirements by e-mail quite productively and resulted in my sending him a proof of concept script... and then nothing... nothing at all.

I don't know what happened to "harveyscoffee", but I hope it wasn't anything too distressing.