Is anyone using hardware buttons to control play/pause through the GPIO pins?

I have built my Pi Zero running Pi MusicBox into an antique radio and can control the volume by using a digital rotary encoder (sending volume commands to Alsamixer). This is working fine.

Now I want to use the push/click function of the rotary encoder to play/pause Pi Musicbox. There are 2 separate pins on the rotary encoder just for the push/click function but I don’t know what software changes I need to make in Pi MusicBox or Mopidy to make this work.

Has anyone connected hardware push switches to the GPIO pins to control play/pause or maybe previous/next functions?

You don’t need to modify Mopidy to make that happen. Mopidy lets you control it either through the MPD protocol using e.g. the python-mpd client library in your GPIO-reading application or through HTTP or WebSocket. Check out the Mopidy docs for the details!

Thanks for answering. I guess that a gpio reading application is what I actually need. I found the Mopidy-TtsGpio add-on which seems to do what I need (and more):

I’ll try that.

I too have built a vintage radio retrofitted with a Raspberry Pi. There are 2 knobs on the radio. One is wired directly to the amplifier to control the volume, and I would like to use the other knob to select pre-defined audio sources like Spotify playlists, online radio (NPR) and podcasts. I believe this would be accomplished by using a rotary encoder and wiring this to GPIO on the Raspberry Pi. I could use some help with the software/programming to make this happen? Thank you!

So far I was only able to use a rotary encoder as digital volume controller. For other functions I’m still trying. Also check out this thread: Control With buttons or screen?

I’m in the middle of a project that uses GPIO to start specific playlists when a pushbutton is pressed. I have a python script running a loop that looks for GPIO inputs and then sends a few commands via os.system to mpc. I have it running on boot by adding a line to Cron, as detailed here:

Here’s my current code: onyeabor and katamari are 2 named playlists i have created. I wish there was a good way to create and manipulate playlists in one of the web extensions, but that doesn’t seem to exist anywhere i’ve seen yet.

I’m new to this whole thing, but i’m planning to use a Pi and Amp+ to supply a ceiling speaker in my new bathroom. I’m thinking that (on)-off spring-loaded light switch could do four things. Shot press would be on/off or play/pause, while long press would be vol+/vol-, kinda like an electronic dimmer. I guess i’ll have to learn some python scripting to pull this off… (unless it already exists?)