Kodi Community Forum

Full Version: How to receive the callback from onPlayBackStarted ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys, I don't know if I'm doing something wrong or if this is an issue but I'm trying to "track" the Player events like onPlayBackStarted, onPlayBackPaused etc ... but I receive nothing.

Anybody knows why?

Code:
import sys
import xbmcgui
import xbmcplugin

plugin_handle = int(sys.argv[1])


class LMS(xbmc.Player):
    url = 'http://localhost/xml/test.xml'
    data = ''

    def __init__(self, *args):
        sys.stdout.write("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ prepare")

        data = self.getData()

        root = data.findall('movie')
        for node in root:
            name = '%s' % node.find('name').text
            video = '%s' % node.find('video').text
            thumb = '%s' % node.find('thumb').text
            self.addVideoItem(video, {'title': name}, thumb)

    def getData(self):
        try:
            request = urllib2.Request(self.url, headers={"Accept": "application/xml"})
            u = urllib2.urlopen(request)
            return ET.parse(u)
        except urllib2.URLError, e:
            return False

    def addVideoItem(self, url, infolabels, img=''):
        listitem = xbmcgui.ListItem(infolabels['title'], iconImage=img, thumbnailImage=img)
        listitem.setInfo('video', infolabels)
        listitem.setProperty('IsPlayable', 'true')
        xbmcplugin.addDirectoryItem(plugin_handle, url, listitem, isFolder=False)

    def onPlayBackStarted(self):
        print "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ playing videoooo"


    def onPlayBackEnded(self):
        print "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ playback ended"

    def onPlayBackStopped(self):
        print "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ playback stopped"

    def onPlayBackPaused(self):
        print "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ playback paused"


lms = LMS()

xbmcplugin.endOfDirectory(plugin_handle)


Thanks,
Wink
Your plugin runs once then exits. (Maybe you want a script/addon instead? Best to describe exactly what it is you are looking to do.)

In any case, lms is created and then immediately deleted from memory when the script ends.

You need to keep your script alive with a "while" loop.

Have a look at the code for XBMC service addons for lots of examples of how to achieve this. More info on your goals will help people make useful suggests.
Also, if LMS is anything to do with Logitech Media Server you should also have a look at the XSqueeze addon. If it's not, then you can ignore me!
thanks guys , Karnagious I did not know about having to be in a while, makes sense Smile
thanks again ...

and Paraguayo no is not Logitech heheheeh is Leesh Media Server that means nothing, just a name hheheehehhehehee