(2016-07-12, 07:53)gedisony Wrote: Okay, I've hit a brick wall:
I'm trying to get an item on the list control to "execute" when the user clicks it but I cannot make it work like xbmcplugin.addDirectoryItem.
with xbmcplugin.addDirectoryItem, you can provide "http://...mp4" or "plugin://" links and it will resolve.
with the custom gui, I can only make it resolve "http://...mp4" links and it plays in the background
Code:
class cGUI(xbmcgui.WindowXMLDialog):
pluginhandle=int( sys.argv[1] )
def __init__(self, *args, **kwargs):
xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)
self.listing = kwargs.get("listing")
def onInit(self):
self.gui_listbox = self.getControl(55)
#url="plugin://plugin.video.reddit_viewer/?url=plugin%3A%2F%2Fplugin.video.youtube%2Fplay%2F%3Fvideo_id%3D73lsIXzBar0&mode=playVideo"
url="http://i.imgur.com/ARdeL4F.mp4"
listitem = xbmcgui.ListItem(label='try me!', label2="<", iconImage='DefaultAddon.png',path=url)
listitem.setPath(url)
self.gui_listbox.addItem(listitem)
self.gui_listbox.addItems(self.listing)
self.setFocus(self.gui_listbox)
pass
def onClick(self, controlID):
if controlID == 55:
num = self.gui_listbox.getSelectedPosition()
item = self.gui_listbox.getSelectedItem()
if num == 0:
log( " %d clicked on %d" %(self.pluginhandle, num ) )
xbmcplugin.setResolvedUrl(self.pluginhandle, True, item)
#xbmc.executebuiltin('RunPlugin(%s)' %di_url ) #doesn't work for videos(Attempt to use invalid handle -1)
Any suggestions on what else I can try?
You can't do it like that as you aren't in a plugin, you'll need to play the list item "yourself", e.g..
Code:
pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
pl.clear()
pl.add(url, item)
xbmc.Player().play(pl)
See
http://mirrors.xbmc.org/docs/python-docs...tml#Player
Actually since you also need the URL, which you don't have access to in your onClick method (I don't think you can get access to the value set using the setPath call), so you will need to add that to the listitem as a property when you create it, i.e.
Code:
listitem.setProperty('Url', url)
then to get it back
Code:
url = item.getProperty('Url')
pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
pl.clear()
pl.add(url, item)
xbmc.Player().play(pl)
Obviously just being able to play the listitem would make much more sense, but Kodi doesn't allow that, well I've never been able to work out how anyway
HTH
(great video by the way LOL)
Edit
Code above will play the video fullscreen, if you want a smaller player in your gui you can add a videowindow in your XML, i.e
Code:
<control type="videowindow">
<posx>14</posx>
<posy>11</posy>
<width>422</width>
<height>240</height>
</control>
And then call:
Code:
xbmc.Player().play(pl, windowed=True)