I use mpg123 to play a list of songs while I work. The host that actually runs mpg123 and plays the music is a local, headless system, but I can connect to it over SSH. I start mpg123 on this host in cron; it plays the audio tracks from my "playlist" in a continuous loop. However there are times when I need to pause the music (incoming phone calls, visitors, etc).
man mpg123 says that by pressing the s key once I can pause the playing, and press it again to re-start. If I start mpg123 in a terminal, and leave it running, this works fine. I've also learned that it's possible to send a "pause" signal (s) to mpg123 when it is being played in a screen session:
$ screen -S mpg123 # to start the screen session $ /usr/bin/mpg123 --loop -1 /home/pi/rainstorm.mp3 # for example 'ctrl+a, d' # quit screen ... $ screen -S mpg123 -X stuff "s" # pauses play I found a question similar to mine here on SO, but the answer seems to miss the mark - at least I didn't understand it!
I've not been able to find a method that allows me to send a "pause" (s) command to mpg123 if it was started under cron. I'd prefer a more direct route than screen to send this command to mpg123, plus I'm not sure if this could even be set up using cron.
Can someone please advise on an approach? I'd prefer a "bash solution" to one that requires (for example) a C program - but happy to take whatever I can get!