Kodi Community Forum
how to run a function every time i select a video - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Video Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=154)
+---- Thread: how to run a function every time i select a video (/showthread.php?tid=327525)



how to run a function every time i select a video - bojan1611 - 2018-01-23

I want to run a function every time i select a video, but kodi only run the function when i enter the addon, here is the code for addon:

cpp:
import sys
import xbmcgui
import xbmcplugin
import requests

infile=[name1,name2]
addon_handle = int(sys.argv[1])
xbmcplugin.setContent(addon_handle, 'movies')

def buildurl():
    #function that return something that change every time i select channel
 return c

def addDir(name,url,mode,iconimage):
    u = url
    li = xbmcgui.ListItem(name, iconImage='DefaultVideo.png')
    #xbmc.Player().play(item=url, listitem=li)
    ok=xbmcplugin.addDirectoryItem(handle=addon_handle, url=u, listitem=li)
    return ok

for line in infile:
    name=str(line)
    url='http://'+str(line)+buildurl()
    addDir(name,url,1,'')

xbmcplugin.endOfDirectory(addon_handle)

I just wanna know how to run the function every time i select a video?


RE: how to run a function every time i select a video - bojan1611 - 2018-01-25

Nobody?