how to: push buttons for web radio stations


i’m building a standalone music player powered by volumio running on the raspi zero. The device should be controllable without smartphone or PC, so it has to be possible to change volume, press play/pause, prev/next song and playing the favourite radio station or playlist by pressing push buttons or turning rotary encoders. The rotarty encoder plugin will be used to change volume, toggle play/pause (short press) and shutdown the pi (long press). It seams that there was no solution to play my favorite radio stations by pressing a button. I used the official GPIO buttons plugin to implement this feature:

  1. play your favourite radio, connect to your Pi via ssh an type
volumio status
  1. copy albumart path and the uri path to a text file on your PC

  2. Edit the GPIO buttons plugin file “/data/plugins/system_controller/gpio-buttons/index.js”

sudo nano /data/plugins/system_controller/gpio-buttons/index.js
  1. As i use the rotary encoder as described above, we can edit the code for volume change, play/pause and shutdown. So i can play four different radio station by clicking the buttons. As an example, i used the volume down function:
//Volume down
GPIOButtons.prototype.volumeDown = function() {
  //'GPIO-Buttons: Vol- button pressed\n');
  socket.emit('addPlay', {'service':'webradio','title':'RADIO BOB!','uri':'','albumart':'http://cdn.../logoq.png'});
  1. Go to the GPIO buttons plugin settings in the UI and select the GPIO according to the function you just changed

Note: you can also use http://volumio.local/dev/ to extract the uri and the albumart path

References/used links:

I hope this helps some of you :smiley:



Thanks for sharing.