Playing Playlist from Context Menu ?
#1
I've got something which has me scratching my head.  I am trying to play a playlist from a context menu.  Here's the context menu code:

Context Menu:
li.addContextMenuItems([ (menuitem1, 'Container.Refresh'), (menuitem2, 'Action(ParentDir)'),  \
('Play Playlist', 'PlayMedia(%s)' % (genmulist)) ])
 

If I put a real URL in instead of genmulist it will play the URL.  In the logs I see the following with genmulist :

2023-07-01 22:03:58.621 T:19492    info <general>: Creating InputStream
2023-07-01 22:03:58.684 T:19492   error <general>: CVideoPlayer::OpenInputStream - error opening [<xbmc.PlayList object at 0x000002222279CC30>]
2023-07-01 22:03:58.684 T:19492    info <general>: CVideoPlayer::OnExit()

I think the problem may be the %s to pass a playlist.  The playlist is created by each list item getting:

genmulist.add(url=itemurl, listitem=li)

I am pretty sure the playlist itself is fine and I am just missing something very obvious.  I've confirmed the playlist works by adding:

Code:
xbmc.Player().play(genmulist)

and it starts playing.  I just want to launch this from a context menu item.


Thanks,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#2
(2023-07-02, 04:13)jbinkley60 Wrote: I've got something which has me scratching my head.  I am trying to play a playlist from a context menu.  Here's the context menu code:

Context Menu:li.addContextMenuItems([ (menuitem1, 'Container.Refresh'), (menuitem2, 'Action(ParentDir)'),  \('Play Playlist', 'PlayMedia(%s)' % (genmulist)) ])

I wrestled with this a bit more and am pretty convinced the issue is passing certain Python variable types to a context menu.  Simple types like strings, URLs (as strings), integers etc.. all work fine).  I was able to get it working with the following where muid is the playilist id:

Revised context menu:
li.addContextMenuItems([ (menuitem1, 'Container.Refresh'), (menuitem2, 'Action(ParentDir)'),  \
('Launch Playlist', 'RunScript(%s, %s, %s)' % ("plugin.video.myaddon", "playlist", muid)) ])

Then on the receiving side script:

utilitiews.py:
    elif sys.argv[1] == 'playlist':
        xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Player.Open",      \
        "params":{"item":{"playlistid":%s}},"id":1}' % (sys.argv[2]))

This can be marked solved.  it would be good to know what the limits are on what can be passed or called by a context menu. It's also quite possible I was doing something wrong.


Thanks,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply

Logout Mark Read Team Forum Stats Members Help
Playing Playlist from Context Menu ?0