All pastes #188297 Raw Edit

Untitled

public python v1 · immutable
·published 2006-10-01 23:58 UTC
rendered paste body
import xbmc, threadingglobal timer# idle time in minutesIDLE_TIME_MIN = 1FILENAME = 'f:\\videos\\trailers\\casino_royale-tlr1_640w.mov'## Thanks Thor918 for this class ##class MyPlayer(xbmc.Player):    def  __init__(self, *args, **kwargs):        if (kwargs.has_key('function1')):             self.function1 = kwargs['function1']        if (kwargs.has_key('function2')):             self.function2 = kwargs['function2']            xbmc.Player.__init__(self)        def onPlayBackStopped(self):        self.function2()        def onPlayBackEnded(self):        self.function2()        def onPlayBackStarted(self):        self.function1()    def stopTimer():	global timer	if ( timer ): timer.cancel()def playVideo():	xbmc.Player().play(FILENAME)	def startTimer():	global timer	if ( timer ): timer.cancel()	# get idle time	it = xbmc.getGlobalIdleTime()	#calculate sleep time in msec	s = ((IDLE_TIME_MIN * 60) - it ) * 1000	timer = threading.Timer(s, playVideo,())sPlayer = MyPlayer(function1=stopTimer, function2=startTimer)startTimer()