General add on question ...
#1
Hi,

Working some days ago on a plug in where adapting the standard xbmc player may be a solution, I've a general question about how python code and xbmc communicate ...

Reading for example this article: http://www.jordanhackworth.com/home-auto...with-xbmc/ I don't understand how xbmc know that this code define some special method to be called later by the player. No special "xbmc" call to some player method, it seems that "magically", xbmc know that this python code have defined a class which "extend" xbmc.Player. And what happen if several scripts make the same ?

Another question, this is a service script which is kept "in memory" by xbmc, but what happen if some other plug in script, a video plugin for example, do the same? As such scripts run only "for a short period" and is run several time, what will happen Huh

Usually a video plug in interact using a method like setResolvedUrl which, as I've understood, implement some callback mecanism, but I've seen some script (source type scripts, like icefilm add on for example) which define some personalized players.

Is there any documentation on this somewhere ?
Reply
#2
I've get some response reading xbmc source code. As I understand, xbmc define some language hook which install callbacks when some class are defined, like xbmc.Player object, callbacks stored and called later when the corresponding event occurs. So I deduced that when used in some add on like a video add on, the python code will remain in memory as long as the callback exist. Not so obvious to understand ...
Reply
#3
the code in the URL you mention is using a rather old method of running an XBMC service. The autoexec.py file is no longer the preferred way of running services. It can more easily be done by writing a service addon as mentioned here: http://wiki.xbmc.org/index.php?title=How...g_services

To more accurately answer your question though - XBMC does not "magically" know what is happening in the player. The author starts his script using autoexec.py and it is written to execute indefinitely as long as XBMC is running (a service, as you suggested). He wrote a custom player class that extends the XBMC.Player python class. This class lets you define several hooks which can get called when actions are taken by the player. Since the service is always running XBMC will call these functions to execute his custom commands. More info on the python functions can be found here: http://mirrors.xbmc.org/docs/python-docs/

Also, the service addons run all the time, no matter what other plug in or script is executing. You can have more than one service running as well, they all run in parallel and can even interact with each other if needed (like the how some scripts use the Common Plugin Cache service to store data.
Reply
#4
(2012-12-19, 16:48)robweber Wrote: ...To more accurately answer your question though - XBMC does not "magically" know what is happening in the player...
Thanks for the answer, I've understood after reading xbmc source code that the "magic" (:-)) is when you create the object, at this point xbmc register callbacks. For service add ons, this is easy to understand, but I've seen the same principle used in other add on than service add on, an icefilm add on for example, a "source type" add on. As I've understood, such add on exit as soon as they have returned a directory listing or an url to be played using setResolvedUrl function, what happen if I'm defining a xbmc.Player here?
Reply

Logout Mark Read Team Forum Stats Members Help
General add on question ...0