pythonadd-onxbmckodi

How to call method from another kodi/xbmc addon


I am trying to make an addon which calls another script addon. Now what I want to know is how can I access methods of the second addon from the first one. If yes please someone provide me with the syntax.


Solution

  • It's very easy....

    Add the addon id of the addon whoes function you ant ot call and add these

    For example: To call function from add-on #1 in add-on #2

    Add-on #1: Write extension point as xbmc.python.module and provide add-on's library path as below.

    <extension point="xbmc.python.module" library="resources" />
    

    Add-on #2: Write add-on #1 add-on id, in requires tag import as below mention.

    <requires>
    <import addon="add-on #1 id" version="2.7.0"/>
    <requires>
    

    Now got to the addon whoes function you want to call and add the .py files to resources directory in your addon.

    Now,

    from resources import foo
    
    foo()
    

    and it is done