[LINUX] xbmc.Player() callbacks not working

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
analogue Offline
Skilled Python Coder
Posts: 149
Joined: May 2008
Reputation: 5
Post: #1
I can't seem to get the callbacks for xbmc.Player working on the latest atlantis release or trunk. Heres a short script to reproduce. Is this a bug or am i missing something?

Code:
import xbmcgui
import xbmc
import time

xbmc.log('\n\n\nHello world\n\n\n')

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

    def onPlayBackStarted(self):
        xbmc.log('*** CALLBACK: onPlayBackStarted')
        
    def onPlayBackEnded( self ):
        xbmc.log('*** CALLBACK: onPlayBackSEnded')

    def onPlayBackStopped( self ):
        xbmc.log('*** CALLBACK: onPlayBackStopped')
        
player = MyPlayer()
player.play('/tmp/movie.mpg')
while True:
    xbmc.log('Sleeping...')
    time.sleep(1)
xbmc.log('\n\n\nGoodbye world\n\n\n')
tnx!
find quote
Nuka1195 Online
Skilled Python Coder
Posts: 3,914
Joined: Dec 2004
Reputation: 17
Post: #2
has that ever worked for you?

seems to me i needed a window or dialog, with a dummy thread running constantly for it to update.

when a song changes, try navigating in xbmc and see if that triggers the event.

edit: maybe just try and run a dummy timer thread, thats what i do in xbmc lyrics

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
(This post was last modified: 2008-10-31 17:15 by Nuka1195.)
find quote
analogue Offline
Skilled Python Coder
Posts: 149
Joined: May 2008
Reputation: 5
Post: #3
I've never used it before, so I can't say I've ever seen it working. I think a pointer to an example of code which actually uses the callbacks would be the best thing for me look at at this point. Do you have any examples?
find quote
rwparris2 Offline
Team-XBMC Python Developer
Posts: 1,341
Joined: Jan 2008
Reputation: 2
Location: US
Post: #4
onplaybackstarted & onplaybackended works for me in LastTube. The only problem I have had with it is pressing next seems to trigger onplaybackstopped Sad

Always read the XBMC online-manual, FAQ and search and search the forum before posting.
For troubleshooting and bug reporting please read how to submit a proper bug report.

If you're interested in writing addons for xbmc, read docs and how-to for plugins and scripts ||| http://code.google.com/p/xbmc-addons/
find quote
bjola Offline
Junior Member
Posts: 2
Joined: Dec 2009
Reputation: 0
Post: #5
Hi all,

I am having the same problem as the original poster: callbacks are not working at all. This is on Windows. I've downloaded the LastTube plug-in, and even there callbacks do not seem to be called (no messages in debug log).

If someone could share a minimal example of a working script or plugin with working callbacks, that would be wonderful. Thanks!
find quote
bjola Offline
Junior Member
Posts: 2
Joined: Dec 2009
Reputation: 0
Post: #6
Ok, I found my error. (I still do not know why LastTube's callbacks did not work for me though.) The error in my code was that I used time.sleep() instead of sbmc.sleep(). Somehow not using sbmc.sleep() prevents _PyXBMC_MakePendingCalls() from being called.
find quote