Detect if music or movie is playing

I just bought some ir diodes which I will connect to my Pi. I have an old audio receiver and I want to control it with my smartphone.
I am using yatse and if you choose to play musik I want the receiver to turn autmatically on and switch to the correct output channel. In this case this should happen without any further user input. I want to monitor on osmc if music has started playing and if so the commands will be send to my receiver. My first thought was to check if there are certain proccesses which I could check with ps -ef but there is nothing different if I play music or video.

Is there any option to see if kodi is playing music right now on os level?

http://kodi.wiki/view/JSON-RPC_API/Examples#What_is_playing.3F

1 Like

Thanks great!

This is my command:
curl --data-binary '{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}' -H'content-type: application/json;' http://osmc:osmc@localhost:8080/jsonrpc

I can now grep for audio or video and check with $? if the command succeeded.

Good to know.

While I assume you can achieve the same from within Kodi but most likely we are all more familiar with bash