Fix playback from context and info menus

This commit is contained in:
Matt 2021-03-11 22:10:09 -05:00
parent 83e7031da6
commit 2fcef85029

View file

@ -61,44 +61,22 @@ class Actions(object):
def play(self, item, db_id=None, transcode=False, playlist=False): def play(self, item, db_id=None, transcode=False, playlist=False):
''' Play item based on if playback started from widget ot not. ''' Play requested item
To get everything to work together, play the first item in the stack with setResolvedUrl,
add the rest to the regular playlist.
''' '''
listitem = xbmcgui.ListItem() listitem = xbmcgui.ListItem()
LOG.info("[ play/%s ] %s", item['Id'], item['Name']) LOG.info("[ play/%s ] %s", item['Id'], item['Name'])
transcode = transcode or settings('playFromTranscode.bool') 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) play = playutils.PlayUtils(item, transcode, self.server_id, self.server, self.api_client)
source = play.select_source(play.get_sources()) source = play.select_source(play.get_sources())
play.set_external_subs(source, listitem) play.set_external_subs(source, listitem)
self.set_playlist(item, listitem, db_id, transcode) 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]) 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: if len(sys.argv) > 1:
xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, self.stack[0][1]) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, self.stack[0][1])
xbmc.Player().play(kodi_playlist, windowed=False)
def set_playlist(self, item, listitem, db_id=None, transcode=False): def set_playlist(self, item, listitem, db_id=None, transcode=False):