Is it possible to have playable context menu item on folder listitem?
#1
I'm trying to make a context menu option that plays an entire folder as a playlist, but since the listitem has isFolder = True I keep receiving Invalid handle when selecting the menu item. My code where I create the listitem and context menu items for each listitem is below

Code:
for subsection in MAIN_MENU[section]:
            li = xbmcgui.ListItem(label=subsection)
            if section == 'By Animal':
                multi_context_url = get_url(action='play', section=section, animal=subsection)
                print multi_context_url
                single_context_url = get_url(action='play', section=section, animal=subsection, pick_one='true')
                li.addContextMenuItems([('Play Random Video', 'RunPlugin('+single_context_url+')'),
                                            ('Play Random Continuously', 'RunPlugin('+multi_context_url+')')])
                url = get_url(action='listing', animal=subsection)
            elif section == 'By Site':
                multi_context_url = get_url(action='play', section=section, source=subsection)
                single_context_url = get_url(action='play', section=section, source=subsection, pick_one='true')
                li.addContextMenuItems([('Play Random Video', 'RunPlugin('+single_context_url+')'),
                                        ('Play Random Continuously', 'RunPlugin('+multi_context_url+')')])
                url = get_url(action='listing', source=subsection)
            elif section == 'By Category':
                multi_context_url = get_url(action='play', section=section, category=subsection)
                single_context_url = get_url(action='play', section=section, category=subsection, pick_one='true')
                li.addContextMenuItems([('Play Random Video', 'RunPlugin('+single_context_url+')'),
                                        ('Play Random Continuously', 'RunPlugin('+multi_context_url+')')])
                url = get_url(action='listing', category=subsection)
            else: #section == 'By Channel'
                url = get_url(action='listing', channel=subsection)
            xbmcplugin.addDirectoryItem(data._handle, url, li, True)
        xbmcplugin.addSortMethod(data._handle, xbmcplugin.SORT_METHOD_NONE)
        xbmcplugin.endOfDirectory(data._handle)

The listitems/links inside the folder are collected dynamically (aren't always the same since they're scraped) if that makes any difference. I found this thread that covers the issue, but the solution of using ReplaceWindow instead of RunPlugin doesn't work for me.

Any idea what I'm doing wrong? Is it possible to accomplish what I'm wanting to do with the context menu item?
Quote:pro·gram·mer (n): An organism capable of converting caffeine into code.
Reply
#2
(2017-07-11, 01:22)CaffeinatedMike Wrote: I found this thread that covers the issue, but the solution of using ReplaceWindow instead of RunPlugin doesn't work for me.

Nor would it... you're not opening a window.

Not sure its possible to help you without including more of your code...

I don't see "def get_url" which is responsible for generating your context links.
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#3
Quote:I don't see "def get_url" which is responsible for generating your context links.

I guess it is a simple one-liner from my example plugin that combines a plugin URL and an encoded query string.

However I see a contradiction in the OP:
Quote:I'm trying to make a context menu option that plays an entire folder as a playlist, but since the listitem has isFolder = False

You can't have a VFS folder with isFolder = False. The latter is reserved for playable items or "generic" plugin paths which do not do anything plugin-specific.
Reply
#4
(2017-07-11, 23:30)Roman_V_M Wrote:
Quote:I don't see "def get_url" which is responsible for generating your context links.

I guess it is a simple one-liner from my example plugin that combines a plugin URL and an encoded query string.

However I see a contradiction in the OP:
Quote:I'm trying to make a context menu option that plays an entire folder as a playlist, but since the listitem has isFolder = False

You can't have a VFS folder with isFolder = False. The latter is reserved for playable items or "generic" plugin paths which do not do anything plugin-specific.

You are correct Roman, I'm using the code from your example plugin where get_url is simply appending the parameters onto the path. You are also correct about my error, my apologies. That was a typo, meant to be isFolder = True. However, I also neglected to mention that I was trying to create two context menu items. One for shuffling/playing the entire playlist and the other for playing a randomly selected single link from the playlist.

However, right before coming back on to see your reply I did have luck finally figuring it out. I had to use two different builtin functions for the items.

For the Shuffle/Play entire playlist I was able to use RunAddon because the function ends with the call that plays the playlist. For Play random link I had to use PlayMedia because the function ended with setResolvedUrl
Quote:pro·gram·mer (n): An organism capable of converting caffeine into code.
Reply

Logout Mark Read Team Forum Stats Members Help
Is it possible to have playable context menu item on folder listitem?0