Fix Kodi crashing when casting from Plex Web

This commit is contained in:
croneter 2019-10-30 17:53:40 +01:00
parent 2481606cd7
commit 8830cf22db

View file

@ -59,10 +59,8 @@ def update_playqueue_from_PMS(playqueue,
# reconnects and Kodi is already playing something - silly, really # reconnects and Kodi is already playing something - silly, really
# For all other cases, a new playqueue is generated by Plex # For all other cases, a new playqueue is generated by Plex
LOG.debug('Update for existing playqueue detected') LOG.debug('Update for existing playqueue detected')
new = False return
else: playqueue.clear()
new = True
playqueue.clear()
# Get new metadata for the playqueue first # Get new metadata for the playqueue first
try: try:
PL.get_playlist_details_from_xml(playqueue, xml) PL.get_playlist_details_from_xml(playqueue, xml)
@ -71,33 +69,10 @@ def update_playqueue_from_PMS(playqueue,
return return
playqueue.repeat = 0 if not repeat else int(repeat) playqueue.repeat = 0 if not repeat else int(repeat)
playqueue.plex_transient_token = transient_token playqueue.plex_transient_token = transient_token
if new: playback.play_xml(playqueue,
playback.play_xml(playqueue, xml,
xml, offset=offset,
offset=offset, start_plex_id=start_plex_id)
start_plex_id=start_plex_id)
return
# Updates to playqueues could potentially become a bit more ugly...
if app.APP.is_playing:
try:
playerid = js.get_player_ids()[0]
except IndexError:
LOG.error('Unexpectately could not get Kodi player id')
return
if app.PLAYSTATE.player_states[playerid]['plex_id'] == start_plex_id:
# Nothing to do - let's not seek to avoid jumps in playback
return
pos = playqueue.position_from_plex_id(start_plex_id)
LOG.debug('Skipping to position %s for %s', pos, playqueue)
js.skipto(pos)
if offset:
js.seek_to(offset)
return
# Need to initiate playback again using our existing playqueue
app.APP.player.play(playqueue.kodi_pl,
None,
False,
playqueue.position_from_plex_id(start_plex_id))
class PlexCompanion(backgroundthread.KillableThread): class PlexCompanion(backgroundthread.KillableThread):