--- misc/xbmc/plugin.video.todic/default.py 2016/11/18 21:12:47 3141 +++ misc/xbmc/plugin.video.todic/default.py 2016/11/21 22:18:33 3142 @@ -3,7 +3,7 @@ ''' Todic plugin for XBMC - Version 0.0.15 + Version 0.0.17 ''' import sys @@ -20,6 +20,7 @@ # import pprint from xml.dom.minidom import parseString +from time import time __addon__ = xbmcaddon.Addon(id='plugin.video.todic') __key__ = __addon__.getSetting('xbmckey').lower() @@ -99,6 +100,8 @@ xbmc.Player.__init__(self, xbmc.PLAYER_CORE_MPLAYER) self.stopped = False self.started = False + self.playingPosition = 0.0 + self.lastReport = 0 print "[TodicPlayer] init" # @catchall @@ -107,20 +110,36 @@ print "[TodicPlayer] : started" # super.onPlayBackStarted() + #When user presses stop, we report back the the position registered in the last call to self.tick() def onPlayBackStopped(self): self.stopped = True print "[TodicPlayer] : stopped" + url = __backend__ + "&action=playbacktime&subaction=stopped&time=" + str( self.playingPosition ) + open_url(url) + def onPlayBackEnded(self): self.stopped = True print "[TodicPlayer] : ended" + url = __backend__ + "&action=playbacktime&subaction=ended&time=" + open_url(url) - def callbackLoop(self): - print "[Todic] startLoop" - while (self.stopped == False): - if (self.started == True): - print "[todic] " + str(self.getTime()) - xbmc.sleep(5000) + def tick(self): + if ( self.isPlaying() ): + self.playingPosition = self.getTime() + now = time() + #print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) + if ( (now - self.lastReport) > 60.0): + self.reportPlaytime() + self.lastReport = now + + + + def reportPlaytime(self): + url = __backend__ + "&action=playbacktime&subaction=playing&time=" + str( self.playingPosition ) + open_url(url) + print "[Todic] reportPlaytime:" + url + def getText2(nodelist): @@ -300,6 +319,13 @@ else: player.disableSubtitles() + #Holder python kørernde indtil at det bliver bedt om at stoppe + while (not xbmc.abortRequested): + player.tick() + xbmc.sleep(100) + + + # player.callbackLoop()