Kodi Community Forum

Full Version: Looking for a command to detect playback
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I use SABnzbd on the same Karmic box as I run XBMC and I'm looking to pause SABnzbd's downloading whenever XBMC is playing media to avoid choppy playback during post processing of a download.

I know how to send a command to SABnzbd to pause and resume downloading but I'm looking for a bash or python command I can use to detect whether XBMC is currently playing media or not. Any ideas?

Rob
You could check the Web API, there is a GetCurrentlyPlaying() command. Looks like it will return Filename:[Nothing Playing] if nothing is playing, and media info if something is playing. Worth checking out.

http://wiki.xbmc.org/?title=Web_Server_HTTP_API

The command you want is at the top of the Command Reference Table.
that is perfect. Thank you much
tret Wrote:...
I'm looking for a .. or python command I can use to detect whether XBMC is currently playing media or not

Code:
#!/usr/bin/python

import sys
import re
import httplib

# webservice host/port
HOST = 'localhost'
PORT = 8081

# nothing playing regex
NO_PLAY = re.compile('Filename:\[Nothing Playing\]')

h = httplib.HTTP(HOST, PORT)
h.putrequest("GET", "/xbmcCmds/xbmcHttp?command=GetCurrentlyPlaying()")
h.endheaders()
stat, statm, head = h.getreply()

if not re.search(NO_PLAY, h.getfile().read()):
    print "File playing"
    sys.exit(1)

print "Nothing playing"
sys.exit(0)