Kodi Community Forum

Full Version: xbmcplugin.addDirectoryItem -- Another Action than play Video
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey Guys,

i want to add a list item which does not start a video but starts a function from my python code instead. Is that possible ?

Thanks,
Thorsten
(2017-03-22, 14:32)thorsten81 Wrote: [ -> ]Hey Guys,

i want to add a list item which does not start a video but starts a function from my python code instead. Is that possible ?

Thanks,
Thorsten

If you want to create a addDirectoryItem that does not start playback simply set "isFolder" to True, and setProperty('IsPlayable', 'false').

http://mirrors.xbmc.org/docs/python-docs...ectoryItem

http://kodi.wiki/view/HOW-TO_write_plugins_for_XBMC
Thread moved to add-on development
Set isFolder=False but do not touch 'isPlayable' property and you can do whatever you want within that plugin call.
(2017-03-23, 09:15)Roman_V_M Wrote: [ -> ]Set isFolder=False but do not touch 'isPlayable' property and you can do whatever you want within that plugin call.

If you don't mind me asking... what is the harm in setting isPlayable false? I understand its not needed to achieve the OPS goal, but if it were set to true by accident it would negate his intention, which is why I included it.
Ok, i have this structure now:

li = xbmcgui.ListItem("Start a function")
xbmcplugin.addDirectoryItem(handle=addon_handle, listitem=li, isFolder=False, isPlayable = False)

But how can I give the entry a function as a parameter for the event? I think, it has no command function like a button in tkinter for example.
(2017-03-23, 14:56)Lunatixz Wrote: [ -> ]
(2017-03-23, 09:15)Roman_V_M Wrote: [ -> ]Set isFolder=False but do not touch 'isPlayable' property and you can do whatever you want within that plugin call.

If you don't mind me asking... what is the harm in setting isPlayable false? I understand its not needed to achieve the OPS goal, but if it were set to true by accident it would negate his intention, which is why I included it.

Sorry, somehow I've missed your reply (bad day). I guess It does not matter.
(2017-03-23, 15:31)thorsten81 Wrote: [ -> ]Ok, i have this structure now:

li = xbmcgui.ListItem("Start a function")
xbmcplugin.addDirectoryItem(handle=addon_handle, listitem=li, isFolder=False, isPlayable = False)

But how can I give the entry a function as a parameter for the event? I think, it has no command function like a button in tkinter for example.

Observe xbmcplugin.addDirectoryItem signature. 'isPlayable' property belongs to ListItem. As for passing parameters, you need to do it the same way as with other types of plugin calls: via plugin call URL/query string.
thorsten,

liz=xbmcgui.ListItem(label="title seen by the user")
liz.setProperty('IsPlayable', 'true') #value must be a string
xbmcplugin.addDirectoryItem(pluginhandle, "plugin://plugin.video.youraddon?command=command1&arg1=something&arg2=something", listitem=liz, isFolder=False)

command, arg1, arg2, etc are your own definitions for your plugin. it can be any string.
many addons make a function called addDir to handle the addDirectoryItem part to make things easier.


IIRC
setting isPlayable to 'false' with isFolder=False
results in pluginhandle=-1 (you get invalidhandle error if you need to use a function that requires a pluginhandle)