How to detect Kodi current state?

I want to pause Kodi when an incoming call comes and resume playback when call ends. However, I only want to detect the current state of Kodi i.e. whether it is playing something or not. I dont see any way to figure out the binding.

Here is my rule

rule "Incoming call"
when
    Item Incoming_Call received command
then
if (receivedCommand==ON) {
        sendCommand(KodiMediacenter_Control, PAUSE)
}
else {
        sendCommand(KodiMediacenter_Control, PLAY)
}
end

The following worked.

rule "Incoming call"
when
Item Incoming_Call changed
then
if (Incoming_Call.state == ON) {
        if (KodiMediacenter_Control.state == PLAY){
                sendCommand(KodiMediacenter_Control, PAUSE)
        }
}
else if (Incoming_Call.state == OFF) {
        if (KodiMediacenter_Control.state == PAUSE){

                sendCommand(KodiMediacenter_Control, PLAY)
        }
}

end

How is KodiMediacenter_Control defined, and which binding version are you using ?
I saw a couple of older threads when reading up on this, and state detection didn’t seem to work reliably back then.

I just used paper ui to create a new item from the control thing of kodi. The binding is the kodi binding in OH2.

The KodiMediacenter_Control item should have the item type Player like this:

Player KodiMediacenter_Control "Kodi control" { 
    channel="kodi:kodi:myKodi:control"
}

Point is that the state of a Player item can only be PLAY or PAUSE. You cannot see if the state is something like STOP. If you need this you have to add an extra Switch item like this:

Switch KodiMediacenter_Stop "Kodi stop" {
    channel="kodi:kodi:myKodi:stop"
}