Hej!
Jag kör XBMC.
Har Switch King och Tellsticken i en annan server.
XBMC drar SwitchKing.Console.CmdLine när man startar en film och släcker ljuset i "salongen".
När man pausar eller stoppar så återgår ljuset igen.
Det hela bygger på "%appdata%/XBMC/userdata/autoexec.py
Skapa filen om den inte finns med följande innehåll:
xbmc.executescript('C:\\xbmcscripts\\ljus.py')
Skapa katalogen c:\xbmcscripts och lägg in ljus.py där med följande innehåll:
# ljus.py
import xbmc,xbmcgui
import subprocess,os
class MyPlayer(xbmc.Player) :
def __init__ (self):
xbmc.Player.__init__(self)
def onPlayBackStarted(self):
if xbmc.Player().isPlayingVideo():
os.spawnl(os.P_DETACH, "C:/Windows/system32/cscript.exe", '//B', '"C:\\xbmcscripts\\off.vbs"')
def onPlayBackEnded(self):
if (VIDEO == 1):
os.spawnl(os.P_DETACH, "C:/Windows/system32/cscript.exe", '//B', '"C:\\xbmcscripts\\on.vbs"')
def onPlayBackStopped(self):
if (VIDEO == 1):
os.spawnl(os.P_DETACH, "C:/Windows/system32/cscript.exe", '//B', '"C:\\xbmcscripts\\on.vbs"')
def onPlayBackPaused(self):
if xbmc.Player().isPlayingVideo():
os.spawnl(os.P_DETACH, "C:/Windows/system32/cscript.exe", '//B', '"C:\\xbmcscripts\\on.vbs"')
def onPlayBackResumed(self):
if xbmc.Player().isPlayingVideo():
os.spawnl(os.P_DETACH, "C:/Windows/system32/cscript.exe", '//B', '"C:\\xbmcscripts\\off.vbs"')
player=MyPlayer()
while(1):
if xbmc.Player().isPlayingVideo():
VIDEO = 1
else:
VIDEO = 0
xbmc.sleep(3000)
Skapa sedan off.vbs
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run("c:\xbmcscripts\SwitchKing.Console.CmdLine\CmdLine.exe turnoff 8"), 0
Set WshShell = Nothing
Och on.vbs
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run("c:\xbmcscripts\SwitchKing.Console.CmdLine\CmdLine.exe turnon 8"), 0
Set WshShell = Nothing
"turnon" kan bytas mot "asscheduled" om man vill att det skall gå på schema istället när man pausar eller stoppar...
Se till att ha SwitchKing.Console.CmdLine på plats i:
c:\xbmcscripts\SwitchKing.Console.CmdLine\
Måste lämna lite cred till följande tråd på Telldus.se forumet och dess skapare...
Därifrån tog jag grunderna och modifierade en del.
http://www.telldus.se/forum/viewtopic.p ... 8&start=15
/dj