My Radio Has Only One Button: A designated Raspi-based WFMU player

I use my Raspberry Pi to listen to the radio (all day, every day). After trying something complicated for a while, I settled on a lightweight combo of ssh, a screen session and mplayer. Which started to annoy me. And I was in the mood to procrastinate so I spend half a day making this project, putting the GPIO to good use!

  • Push that button to start playing the WFMU stream!
  • Optional: push the button again to stop (not recommended)
  • The LED indicates keypresses and blinks when playing the stream

Technical details

    • This is the very first Raspberry, “1 Model A”
    • I run this on an ancient Raspbian, Python 2.7 w/ RPi.GPIO, ancient mplayer.
    • Started out as a 5-sloc bash script, grew into 100 lines of python.
    • Uses a pretty dumb polling loop, which detects keypresses once a second to save, like, a milliwatt. Using GPIO events would be wiser.
    • This old Raspi needs (?) root privileges for GPIO access, so there’s some juggling to run mplayer with user rights only.
    • Put in /etc/rc.local to start on boot, e.g. like this:
      screen -S wfmugpio -m -d /home/pi/wfmugpio/wfmugpio.py
      so you can reattach to that screen and debug or kill the script, change volume, read the playlist…