How do you get a plugin to call itself and perform an action?
#1
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
Get and request your ClearLOGOs / ClearART / TV Thumbs / Season Thumbs / Music ClearLOGOs / cdART / Artist Backgrounds / CD Covers from fanart.tv
Reply
#2
What are you adding the listitem to, a plugin directoryHuh
Reply
#3
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))
Get and request your ClearLOGOs / ClearART / TV Thumbs / Season Thumbs / Music ClearLOGOs / cdART / Artist Backgrounds / CD Covers from fanart.tv
Reply
#4
So.. the control, WINDOW.getControl(311), is from some xml file or did you create it in python?
Reply
#5
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
Get and request your ClearLOGOs / ClearART / TV Thumbs / Season Thumbs / Music ClearLOGOs / cdART / Artist Backgrounds / CD Covers from fanart.tv
Reply
#6
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.fun...lt.py#L415
Reply
#7
hmm, interesting, I will look into this, many thanks
Get and request your ClearLOGOs / ClearART / TV Thumbs / Season Thumbs / Music ClearLOGOs / cdART / Artist Backgrounds / CD Covers from fanart.tv
Reply

Logout Mark Read Team Forum Stats Members Help
How do you get a plugin to call itself and perform an action?0