Kodi Community Forum
How do you get a plugin to call itself and perform an action? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: How do you get a plugin to call itself and perform an action? (/showthread.php?tid=176207)



How do you get a plugin to call itself and perform an action? - Kode - 2013-10-21

Anybody have any idea why the following doesnt work?

If it's in the skin

<onclick>PlayMedia(plugin://plugin.video.plexbmc?url=http://192.168.0.20:32400/library/metadata/21995&mode=11&t=7260639398)</onclick>

works, but now I'm trying to use xbmcgui.listitem with..

Code:
def add_listitem(item, thumb, path_to_play):
    listitem = xbmcgui.ListItem('%s %s - %s' %(item.get('title','Unknown').encode('UTF-8'),item.get('year','Unknown').encode('UTF-8'), item.get('rating','Unknown').encode('UTF-8')), thumbnailImage=thumb, path=path_to_play)
    return listitem

where path_to_play is also PlayMedia(plugin://plugin.video.plexbmc?url=http://192.168.0.20:32400/library/metadata/21995&mode=11&t=7260639398) but this doesn't work

Ay ideas?

*edit*
From what I have read, you can't pass PlayMedia as part of the path, and would have to call the plugin itself to initiate the playmedia, ive tried the following:

Changing the path to plugin://plugin.video.plexbmc?playtype=video&url=http://192.168.0.20:32400/library/metadata/21995&mode=11&t=7260639398

and then in the plugin

Code:
try:
    params=get_params(sys.argv[2])
except:
    params={}

playtype_url=params.get('playtype',None)

if playtype_url:
    printDebug("hit playtype: %s" % playtype_url )
    url=params.get('url',None)
    mode=params.get('mode',None)
    t=params.get('t',None)
    pluginPlay(playtype_url, url, mode, t)

def pluginPlay(playtype, url, mode, t):
    printDebug("hit pluginPlay: %s %s %s %s" %(playtype, url, mode, t) )
    if(playtype == "video"):
        #PlayMedia(plugin://plugin.video.plexbmc?url=%s&mode=%s&t=%s%s)" % ( getLinkURL('http://'+server_address,media,server_address), _MODE_PLAYSHELF, randomNumber, aToken)
        ActivateWindow(Weather)

but I'm obviously doing it in the wrong place and it doesnt work, it doesn't even hit the first printDebug


RE: How do you get a plugin to call itself and perform an action? - divingmule - 2013-10-21

What are you adding the listitem to, a plugin directoryHuh


RE: How do you get a plugin to call itself and perform an action? - Kode - 2013-10-21

to a control, so:

Code:
recent_movies = WINDOW.getControl(311)
for index in sorted(added_list, reverse=direction):
       media=added_list[index][0]
        server_address=added_list[index][1]
        aToken=added_list[index][2]
        qToken=added_list[index][3]
        if media.get('type',None) == "movie":
            m_url="plugin://plugin.video.plexbmc?playtype=video&url=%s&mode=%s&t=%s%s" % ( getLinkURL('http://'+server_address,media,server_address), _MODE_PLAYSHELF, randomNumber, aToken)
            m_thumb=getThumb(media,server_address)
            recent_movies.addItem(add_listitem(media, m_thumb, m_url))



RE: How do you get a plugin to call itself and perform an action? - divingmule - 2013-10-21

So.. the control, WINDOW.getControl(311), is from some xml file or did you create it in python?


RE: How do you get a plugin to call itself and perform an action? - Kode - 2013-10-21

specifically in this instance it's in the Amber skin include_plexbmc.xml

*edit*
The actual listing works fine, I can see all the thumbnails and scroll through them, just clicking on one does nothing


RE: How do you get a plugin to call itself and perform an action? - divingmule - 2013-10-21

So.. you're running this from a python window class? I'm thinking you need to define onClick.

This catches and returns the control id when the listitem is selected. Then you would have to do something like xbmc.Player().play( control.getSelectedItem())

Here is onClick example - https://github.com/divingmule/script.funnyordie/blob/master/default.py#L415


RE: How do you get a plugin to call itself and perform an action? - Kode - 2013-10-21

hmm, interesting, I will look into this, many thanks