Merge pull request #484 from mcarlton00/context-menu

Fix playback from context and info menus
This commit is contained in:
mcarlton00 2021-04-19 19:40:26 -04:00 committed by GitHub
commit 77dbe45a4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 39 deletions

View File

@ -61,44 +61,22 @@ class Actions(object):
def play(self, item, db_id=None, transcode=False, playlist=False):
''' Play item based on if playback started from widget ot not.
To get everything to work together, play the first item in the stack with setResolvedUrl,
add the rest to the regular playlist.
''' Play requested item
'''
listitem = xbmcgui.ListItem()
LOG.info("[ play/%s ] %s", item['Id'], item['Name'])
transcode = transcode or settings('playFromTranscode.bool')
kodi_playlist = self.get_playlist(item)
play = playutils.PlayUtils(item, transcode, self.server_id, self.server, self.api_client)
source = play.select_source(play.get_sources())
play.set_external_subs(source, listitem)
self.set_playlist(item, listitem, db_id, transcode)
index = max(kodi_playlist.getposition(), 0) + 1 # Can return -1
force_play = False
self.stack[0][1].setPath(self.stack[0][0])
try:
if not playlist and self.detect_widgets(item):
LOG.info(" [ play/widget ]")
raise IndexError
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, self.stack[0][1])
self.stack.pop(0)
except IndexError:
force_play = True
for stack in self.stack:
kodi_playlist.add(url=stack[0], listitem=stack[1], index=index)
index += 1
if force_play:
if len(sys.argv) > 1:
xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, self.stack[0][1])
xbmc.Player().play(kodi_playlist, windowed=False)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, self.stack[0][1])
def set_playlist(self, item, listitem, db_id=None, transcode=False):
@ -714,21 +692,6 @@ class Actions(object):
return True
def detect_widgets(self, item):
kodi_version = xbmc.getInfoLabel('System.BuildVersion')
if kodi_version and "Git:" in kodi_version and kodi_version.split('Git:')[1].split("-")[0] in ('20171119', 'a9a7a20'):
LOG.info("Build does not require workaround for widgets?")
return False
if (not xbmc.getCondVisibility('Window.IsMedia') and ((item['Type'] == 'Audio' and not xbmc.getCondVisibility('Integer.IsGreater(Playlist.Length(music),1)')) or not xbmc.getCondVisibility('Integer.IsGreater(Playlist.Length(video),1)'))):
return True
return False
class PlaylistWorker(threading.Thread):