PDA

View Full Version : Events and timers?


art0rz
2007-01-29, 01:26
Hi,

First of all, I would like to thank the developers for making such an awesome XBox dashboard, I've had lots of fun with it and have stopped using my pc as a media center.

I'm making a 'now playing' script for XBMC and mIRC, and need some advice. Right now, the script runs in an aweful while loop that gets the song info every 20 seconds and I would like it to use an event for when XBMC changes the current song. I've not dug very deep into the documentation -mainly because it's not very well documented afaik ;)- and my python skills have known better times.

If this is not possible, I would like to know how to get rid of the aweful loop, and switch to a more .. proper way of having a timer.

And one more question, could you list the getMusicInfoTag functions?

Cheers,
art0rz

art0rz
2007-01-29, 01:47
My apologies for the double post, I couldnt find the edit button.

It seems I overlooked the HttpApi page. ;) No need for a python script now. :)

Nuka1195
2007-01-29, 03:15
http://home.no.net/thor918/xbmc/xbmc.html
http://home.no.net/thor918/xbmc/xbmcgui.html

The following is what I use, thanks to Thor918. I call it with the following:

self.MyPlayer = MyPlayer( xbmc.PLAYER_CORE_MPLAYER, function = self.myPlayerChanged )



## Thanks Thor918 for this class ##
class MyPlayer( xbmc.Player ):
def __init__( self, *args, **kwargs ):
if ( kwargs.has_key( 'function' )):
self.function = kwargs['function']
xbmc.Player.__init__( self )

def onPlayBackStopped( self ):
self.function( 0 )

def onPlayBackEnded( self ):
self.function( 1 )

def onPlayBackStarted( self ):
self.function( 2 )