2013-02-11, 00:48
Hi,
I've been trying to use the examples on http://www.jordanhackworth.com/home-auto...-with-xbmc in order to create a script that stops the movie if it's paused for a extended period of time (in order to limit CPU usage as some family members have a tendency to leave the movie paused forever instead of stopping it). But I can't seem to get it to work as it seems that the script only runs once (the test notification never triggers), despite it being a loop. Any pointers would be greatly appreciated. Below is what I have so far. Thanks! Jonas
I've been trying to use the examples on http://www.jordanhackworth.com/home-auto...-with-xbmc in order to create a script that stops the movie if it's paused for a extended period of time (in order to limit CPU usage as some family members have a tendency to leave the movie paused forever instead of stopping it). But I can't seem to get it to work as it seems that the script only runs once (the test notification never triggers), despite it being a loop. Any pointers would be greatly appreciated. Below is what I have so far. Thanks! Jonas
Code:
import xbmc,xbmcgui
import subprocess,os
IDLE_TIME_MIN = 15
s = 0
class MyPlayer(xbmc.Player) :
def __init__ (self):
xbmc.Player.__init__(self)
def onPlayBackStarted(self):
pass
def onPlayBackEnded(self):
pass
def onPlayBackPaused(self):
if xbmc.Player().isPlayingVideo():
if (TIMEOUT == 1):
xbmc.executebuiltin("Notification(Title, Movie will be stopped)")
#Code to stop movie goes here
def onPlayBackResumed(self):
pass
def onPlayBackStopped(self):
pass
player=MyPlayer()
while(1 and not xbmc.abortRequested):
it = xbmc.getGlobalIdleTime()
s = ((IDLE_TIME_MIN * 60) - it )
if xbmc.Player().isPlaying():
if xbmc.Player().isPlayingVideo():
if (s > 0):
TIMEOUT = 0
elif (s < 0):
TIMEOUT = 1
xbmc.sleep(10000)