Speaker phat with pause button


#1

I’m looking for some guidance in a project that I want to build. I’ve followed the instructions here to build a simple pi zero / speaker phat that starts playing randomly from a folder on start up. This works okay, but it takes a minute or so to get going and then there’s a bit of sound distortion as it’s starting up. What I’d like to do therefore, is add a button to pause the playlist so that you don’t need to wait every time you start it up, just leave it powered up and ready to go. (The idea is to build it into a little box for my son with all his favourite songs loaded into it.)

I now know how to run a python script on the push of a button but need to understand how to adapt this for the music player, and physically how to attach the button.

On the coding side, if I start cvlc via crontab, can I then use python to pause it on a button press? If so, what is the python code to pause cvlc?

And on the wiring side, if the speaker phat is attached to the pi zero, there’s nowhere to attach the wires for the button. Can I solder them on the back of the pi ?


#2

You “might” find what your looking for here, Use a media keyboard with your pHat Beat, can it be done?
About half way down the page. I tried to clip and past but it wouldn’t let me for some reason?
vlc.communicate(“pause”)