Shell command on start playback (volumio & volspotconnect)

Hello,
I already have a script that sends a serial command to my audio receiver from my Pi GPIO pins and I would like to launch that script everytime playback is started or resumed from Volumio/Volspotconnect.

In which file should I put the command line so it’s fired when playback starts?

Thanks!

So many options here:

  1. Write a deamon that listens to the socket events:
    1a. nodejs snippet:
const io=require('socket.io-client');
const socket= io.connect('http://localhost:3000');
//Listen for any state change
socket.on('pushState', function (data) {
              console.log(data);
        });

1b. Pyhton snippet:

from socketIO_client import SocketIO, LoggingNamespace
socketIO = SocketIO('localhost', 3000, LoggingNamespace)

def state_change(state):
		print('state', state)

socketIO.on('pushState', state_change)
  1. Shortcut all this and directly hack into volspotconnect’s index.js and call your script directly from there — but that of course will not trigger from other sources.

  2. Or, look at the (https://github.com/volumio/volumio-plugins/tree/master/plugins/miscellanea/ampswitch)]AmpSwitch plugin, and instead of toggling GPIO’s call your script.

Thanks! I’ll use the Ampswitch method !