Kodi Community Forum
onPlayBackStarted in service addon - 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: onPlayBackStarted in service addon (/showthread.php?tid=126861)



onPlayBackStarted in service addon - nilzen - 2012-03-27

Can someone please point me in the right direction for listening to player events, onPlayBackStarted etc, in a service addon?

Code:
import xbmc

class PlayerEvents(xbmc.Player) :
  
    def onPlayBackStarted(self):
        xbmc.log("play")

player=PlayerEvents()

xbmc.log("init")

"init" gets logged but never "play", Python isn't my preferred language so I'm sure if there's a better way to subscribe to player events but I found some example code where they were listening to player event this way using the old autoexec.py


RE: onPlayBackStarted in service addon - jmarshall - 2012-03-28

IIRC you need to have a while (!xbmc.abortRequested) or thereabouts there, otherwise your script completes immediately.


RE: onPlayBackStarted in service addon - Bstrdsmkr - 2012-03-28

Yeah, you have to keep the script running by checking for a condition and then sleeping.


RE: onPlayBackStarted in service addon - Popeye - 2012-03-28

use xbmc.sleep not time.sleep..