Kodi Community Forum
Python: Call on pause and resume? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Python: Call on pause and resume? (/showthread.php?tid=120048)



Python: Call on pause and resume? - zyberzero - 2012-01-15

Hi,

I'm trying to develop an addon to XBMC. I have successfully overrided onPlaybackStarted and onPlaybackStopped, but is there any way to catch pause and resumed playback as well?

I've seen other plugins that try to call onPlaybackPaused, but I can't get them to work.

I'm using Eden (Beta 1) on Linux.

Code:
import xbmc

class MyPlayer(xbmc.Player):
    def __init__(self):
        xbmc.Player.__init__(self)

    def onPlayBackStarted(self):
        if xbmc.Player().isPlayingVideo():
            updateState("XBMCVideoPlaying", 1)    
    
    def onPlaybackStopped(self):
        xbmc.log(str(xbmc.Player().isPlayingVideo()))
    
    def onPlaybackEnded(self):
        if(VIDEO == 1):
            updateState("XBMCVideoPlaying", 0)
            
    def onPlaybackPaused(self):
        if xbmc.Player().isPlayingVideo(): #OK; we've paused a Video.
            updateState("XBMCVideoPaused", 1)

    
    def onPlaybackResumed(self):
        if xbmc.Player().isPlayingVideo(): #OK, resumed a paused video
            updateState("XBMCVideoPaused", 0)

            

xbmc.log("myAddon: Init");

player = MyPlayer()

while(not xbmc.abortRequested):
    if xbmc.Player().isPlayingVideo():
        VIDEO = 1
    else:
        VIDEO = 0
    
    xbmc.sleep(1000)


xbmc.log("Finished running")