Created
September 14, 2014 12:32
-
-
Save tjoskar/0569d7c6469c6b8511c8 to your computer and use it in GitHub Desktop.
Turn off lamps when using XBMC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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