Detect from CLI if OSMC is playing something

Hey guys,

I have some buttons connected to the GPIOs of a Raspberry Pi which I wanna choose to play a sound.
The raspberry is connected to a touchscreen on which OSMC is running.
I wrote a python script for the Buttons which looks like the following:

import os
from time import sleep
import RPi.GPIO as GPIO
from sys import exit

GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN)

def playSound(file):
    os.system('xbmc-send --action="PlayerControl(Play)"')
    sleep(0.1)
    os.system('mpg123 -q ' + file)
    print(file)
    os.system('xbmc-send --action="PlayerControl(Play)"')

while True:
    try:
        if (GPIO.input(23) == True):
            playSound('buzzer.mp3')

        sleep(0.2)
    except KeyboardInterrupt:
        exit()

The script works currently as the following:
It pauses the current playing song and starts the soundfile. After that, it will resume the song from before.
The problem is not that if there is no Song playing before, it wont work (as “Play” is used for pausing and resuming).

Is there a way to detect if there is currently a song playing?

Thanks in advance.

Best regards,
Danny

Did you check the “What is playing” example?

http://kodi.wiki/view/JSON-RPC_API/Examples

Yeah I did check this out but this will just return the details to the song which is currently active on the appropriate player. So this doesn’t tell me any about if the song is paused are really playing.

So if you had been there I wonder why you didn’t continue to search there. What I found is that {"jsonrpc": "2.0", "method": "Player.GetProperties", "params": {"playerid": 0, "properties": ["speed"]}, "id": 1} tells you that if speed=0 the item is paused.

Ah, now I see. Sorry I didn’t see that before. Thank you @fzinken for that. This solves my issue.