User Tools

Site Tools


doc:appunti:software:kodi_addon

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
doc:appunti:software:kodi_addon [2023/05/26 16:38] – [How to start an external program from Kodi] niccolodoc:appunti:software:kodi_addon [2023/05/26 17:02] – [How to start an external program from Kodi] niccolo
Line 309: Line 309:
 ==== How to start an external program from Kodi ==== ==== How to start an external program from Kodi ====
  
-I tried (but failed) to start a Python graphical program from Kodi. Because there is not an X11 windowing system, I tried Pygame with the drivers **directfb**, **fbcon** or **svgalib**.+I tried (but failed) to start a Python graphical program from Kodi. Because there is not an X11 windowing system, I tried **Pygame** with the drivers **directfb**, **fbcon** or **svgalib**. No problem if Kodi is stopped, Permission denied on the display if Kodi is running. Using the Python3 OpenGL module I was able to create a graphical program only under the X11 environment (using the ''DISPLAY'' environment variable).
  
-<code python> +To execute an external program from my add-on video plugin, I used the following two methods. The first one just starts an external Python script when the code is executed:
-xbmc.executebuiltin('XBMC.RunScript(special://home/bin/my-script)') +
-</code>+
            
 <code python> <code python>
-# This works only if it is a Python script.+# This works only for a Python script.
 # Notice "special://home" is "/home/kodi/.kodi" on the Raspberry Pi. # Notice "special://home" is "/home/kodi/.kodi" on the Raspberry Pi.
 xbmc.executescript('special://home/bin/run-script.py') xbmc.executescript('special://home/bin/run-script.py')
 </code> </code>
 +
 +This second method will add a context menu item to the add-on ''ListItem'', which will launch the external program when selected:
  
 <code python> <code python>
-# Add a context menu item to the listItem object.+# Add a context menu item to the add-on xbmcgui.ListItem object
 +# This works only for a Python script.
 li.addContextMenuItems([('Photo Reframe', 'RunScript(special://home/bin/run-script.py,arg1)')]) li.addContextMenuItems([('Photo Reframe', 'RunScript(special://home/bin/run-script.py,arg1)')])
 +</code>
 +
 +A third method should be the following, but I did not tried it:
 +
 +<code python>
 +xbmc.executebuiltin('XBMC.RunScript(special://home/bin/run-script.py)')
 +</code>
 +
 +Other non-tested code to execute plugins or scripts:
 +
 +<code python>
 +xbmc.executebuiltin('RunPlugin(plugin://plugin.video.youtube/?addon_id=plugin.video.example)')
 +xbmc.executebuiltin('RunPlugin("plugin.video.something")')
 +xbmc.executebuiltin('RunAddon("script.something")')
 </code> </code>
  
Line 332: Line 347:
   * **[[https://kodi.wiki/view/External_players|Kodi External players]]**   * **[[https://kodi.wiki/view/External_players|Kodi External players]]**
   * **[[https://kodi.wiki/view/Settings/System/Display|Kodi: Settings, System, Display]]**   * **[[https://kodi.wiki/view/Settings/System/Display|Kodi: Settings, System, Display]]**
 +  * **[[https://stackoverflow.com/questions/54452592/how-to-start-another-addon-from-a-kodi-addon|How to start another addon from a kodi addon]]**
  
 ===== Web References ===== ===== Web References =====
doc/appunti/software/kodi_addon.txt · Last modified: 2023/05/26 17:05 by niccolo