Skip to content

Instantly share code, notes, and snippets.

@tjoskar
Created September 14, 2014 12:32
Show Gist options
  • Save tjoskar/0569d7c6469c6b8511c8 to your computer and use it in GitHub Desktop.
Save tjoskar/0569d7c6469c6b8511c8 to your computer and use it in GitHub Desktop.
Turn off lamps when using XBMC
import urllib
import xbmc
__HOST__ = '192.168.0.15'
__PORT__ = '8000'
class MyPlayer(xbmc.Player):
__is_playing = False
__url = 'http://' + __HOST__ + ':' + __PORT__
def __init__(self):
xbmc.Player.__init__(self)
def onPlayBackStarted(self):
if xbmc.Player().isPlayingVideo():
self.__is_playing = True
urllib.urlopen(self.__url + '/alloff')
def onPlayBackEnded(self):
self.onPlayBackStopped()
def onPlayBackStopped(self):
if self.__is_playing:
self.__is_playing = False
urllib.urlopen(self.__url + '/window/on')
urllib.urlopen(self.__url + '/onsoft')
_ = MyPlayer()
while not xbmc.abortRequested:
xbmc.sleep(1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment