Problem using setResolvedUrl
#16
Quote:With RunPlugin(...) Kodi just runs the plugin with the provided url. The plugin can do whatever it has to do, like changing settings, logging in to remote servers, wiping your hard drive, but Kodi does not expect any interaction of the plugin by calls like xbmcplugin.addDirectoryItem(...) or xbmcplugin.setResolvedUrl(...). In fact, a plugin handle of -1 suggest that it's simply impossible to interact like that.
That is a very useful hint! Thanks for your datailed explanation. At least me, did not notice that reading the wiki pages (but that can be my fault because you can't just save it all to your brain ;P). I'd never assumed that RunPlugin(...) is causing this, so really thanks, that saved me!
Quote:Well, there is an entry named 'Add-ons' in the main menu from where you can open your add-on by clicking on its icon. If you insist on having a dedicated entry in the main menu, yours is probably the way to go, but I know absolutely nothing about skinning, so I can't help you there.
Thats true, currently i am learning by doing Smile
 
Quote:That sounds good. Still, you do call PlayMedia(...) somewhere. Despite my lack of skinning knowledge, I strongly feel there should be no need to do so. If your plugin provides the right info in the ListItems it produces and passes them to Kodi correctly
Also a very good point. That is the right way to put the "puzzles" together for my understanding so far also. But as said, currently i am still learning by doing, but putting it into that clean way is the right track!
Reply
#17
Uhm, i might got bogged down in details finally, but now i got the problem that if i call PlayMedia(...) directly from Python to "spawn" main.py which, of course, runs setResolvedUrl(...) i get two busysdialgs and crash Wink

This works now: Putting PlayMedia(plugin.name/?url=url) in an Items <onclick> Value. The Item's onclick execute PlayMedia(...) and spawns the main.py, i get the handle and the main.py runs setResolvedUrl(handle, listitem,..). This works without any problems.

However, if i run PlayMedia(plugin.name/?url=url) from another.py and NOT from an Item's onclick value in an XML file, i get:
Code:
critical <general>: Logic error due to two concurrent busydialogs, this is a known issue. The application will exit.

I guess because this another.py runs PlayMedia, calls main.py which runs setResolvedUrl(url) which results in two busydialgs.
But if i use RunPlugin() instead of PlayMedia() from another.py i dont get a valid handle for the setResolvedUrl function. What function do i use to get a valid Handle from an other Python Script that does not spawn a busydialg, just gives over the URL and the Handle to my plugins main.py?

Sorry mates for bugging...
Reply
#18
Or can i set the Item's onclick value (just like in an XML with the tag <onclick>) when adding items to a panel from Python instead of using <content> in the XML file:

Code:
item = xbmcgui.ListItem(label) # Sets Label
item.setProperty("someProperty",str(someVar)) #Sets someProperty
item.setProperty("onclick",str(PlayMedia(url)) # Tried that one, doesn't seem to work. Can i set the onclick value?
self.getControl(42100).addItem(item) # 42100 is the panel control

Just like the "label", how can i set the Item's onclick value?
Reply
#19
(2024-05-14, 22:06)iceman20k Wrote: Or can i set the Item's onclick value (just like in an XML with the tag <onclick>) when adding items to a panel from Python 
You can't and you shouldn't. I get the feeling you're thinking very much in concepts for normal GUI programming, but that doesn't apply to the way Kodi's plugin system works.

The (very) basic principle of operation of a plugin is  like this:
  • It's first started by clicking the pluging's icon from main menu -> Add-ons
  • The plugin creates xmbcgui.ListItems and pushed them to Kodi by calling xbmcplugin.addDirectoryItem(...), or xbmcplugin.addDirectoryItems(...).
    • The url you set in xbmcplugin.addDirectoryItem(...) is usually in the form of plugin://plugin.video.xyz?myfield=myvalue, which has the effect that Kodi runs the plugin again when the user clicks on that item.
    • If a item is playable call setProperty('IsPlayable', 'true') on that ListItem.
    • If am items is a subfolder set parameter isFolder=True when you call addDirectoryItem(...) for that ListItem.
  • The plugin ends with calling xbmcplugin.endOfDirectory() and Kodi will display the list of items, as if it was the content of a folder.
  • The user clicks on an item Kodi will 'open' the url, which in our case means: runs the plugin again.
  • Kodi passes the path and querystring by commandline arguments, so by analysing sys.argv the plugin can decide what to return next.
  • If the clicked Item was a folder, Kodi expects the plugin to provide a new list of items, which it will then display as if it were the content of a sub directory.
  • If the clicked item was playable, Kodi expects the add-on to create a xbmcgui.ListItem(...) with parameter path set to a playable file or url, and pass that item to Kodi with a call to xbmcplugin.setResolvedUrl(...). After which Kodi will play the file.

This is of course just a basic overview, but the point is that you don't have to call RunPlugin(), PlayMedia(), etc for the normal operation of a plugin. And you don't have to handle click events. Kodi handles the click events of items and by setting things like parameter 'url' you tell Kodi what it should do when clicked.

I strongly suggest that you put your custom skin with these <onclick> items on ice for the moment and try to get the plugin running as a plugin should, by opening it from the add-ons section in the default skin. Once you get that working and find you'll still want a custom skin, you'll have at least something solid to work on. 

I guess most of us learned by trial and error. It's certainly a path that's rather steep and rough sometimes, particularly at the start, but it gets easier once you're on the way. Just take small steps at a time and enjoy small successes.
Reply

Logout Mark Read Team Forum Stats Members Help
Problem using setResolvedUrl0
This forum uses Lukasz Tkacz MyBB addons.