v14 Run script from ListItem
#1
Hi!

I want to write a very simple addon to change the audio output via the menu. I already do this with keys from the remote control but I also want to have menu items to change it. Then I will be able to change the audio output via Yatse as well.

My plan is it to set up some other simple scripts as well to du simple tasks.

I read some tutorials and set up a simple script for starters. My question is now how I can use list items to run a python script? It seems that all the listItem classes are only for media content with an URL. How can I do a XBMC.runScript() on a listItem. I got it to work on a contextMenuItem but not with a listItem.

PHP Code:
import sys
import xbmc
import xbmcgui
import xbmcplugin

addon_handle 
int(sys.argv[1])

xbmcplugin.setContent(addon_handle'files')

url 'http://www.orf.at'
li xbmcgui.ListItem('TEST1'iconImage='DefaultVideo.png')                        
li.addContextMenuItems([('test6''XBMC.runScript(/storage/.kodi/addons/plugin.program.smartcommand/resources/runSetHDMI.py)')])
                                                                      
xbmcplugin.addDirectoryItem(handle=addon_handleurl=urllistitem=li)
                                       
xbmcplugin.endOfDirectory(addon_handle

That's my code for now.

Thanks for your help in advance!
Reply
#2
Hi,

I'm currently trying to do the same thing (actually the exact same thing ^^).
The only way to figure it out I found is to create another plugin (with everything needed to be launch) ad then replace the url of the listitem with the plugin adress of the second one that I created (i.e. plugin://plugin.video.helloworld2) and in the python program of the second one, I do what I want to do...

But that's not "good code"...
So I'm currently looking for another way to do this (like call another python program which is IN the current plugin directory).

If you guys have any clue, that'd be cool :-).

Thanks a lot !
Reply
#3
Try the plugin Advanced Launcher. It does exactly what I was looking for when I started this post.
Reply
#4
Wouldn't something like 'RunScript(plugin://plugin.program.smartcommand, arg1, arg2)' work?
Reply

Logout Mark Read Team Forum Stats Members Help
Run script from ListItem0