Fix TypeError for Plex Companion switching audio or subtitle stream

This commit is contained in:
croneter 2021-10-19 08:36:05 +02:00
parent 0d41321d7f
commit 4f7e54591c
2 changed files with 22 additions and 13 deletions

View file

@ -376,6 +376,27 @@ class PlaylistItem(object):
and kodi_sub_stream != self.current_kodi_sub_stream)): and kodi_sub_stream != self.current_kodi_sub_stream)):
self.on_kodi_subtitle_stream_change(kodi_sub_stream, sub_enabled) self.on_kodi_subtitle_stream_change(kodi_sub_stream, sub_enabled)
def on_plex_stream_change(self, plex_data):
"""
Call this method if Plex Companion wants to change streams
"""
if 'audioStreamID' in plex_data:
plex_index = int(plex_data['audioStreamID'])
kodi_index = self.kodi_stream_index(plex_index, 'audio')
app.APP.player.setAudioStream(kodi_index)
self.current_kodi_audio_stream = kodi_index
if 'subtitleStreamID' in plex_data:
plex_index = int(plex_data['subtitleStreamID'])
if plex_index == 0:
app.APP.player.showSubtitles(False)
kodi_index = False
else:
kodi_index = self.kodi_stream_index(plex_index, 'subtitle')
if kodi_index:
app.APP.player.setSubtitleStream(kodi_index)
app.APP.player.showSubtitles(True)
self.current_kodi_sub_stream = kodi_index
def playlist_item_from_kodi(kodi_item): def playlist_item_from_kodi(kodi_item):
""" """

View file

@ -191,19 +191,7 @@ class PlexCompanion(backgroundthread.KillableThread):
playqueue = PQ.get_playqueue_from_type( playqueue = PQ.get_playqueue_from_type(
v.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[data['type']]) v.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[data['type']])
pos = js.get_position(playqueue.playlistid) pos = js.get_position(playqueue.playlistid)
if 'audioStreamID' in data: playqueue.items[pos].on_plex_stream_change(data)
index = playqueue.items[pos].kodi_stream_index(
data['audioStreamID'], 'audio')
app.APP.player.setAudioStream(index)
elif 'subtitleStreamID' in data:
if data['subtitleStreamID'] == '0':
app.APP.player.showSubtitles(False)
else:
index = playqueue.items[pos].kodi_stream_index(
data['subtitleStreamID'], 'subtitle')
app.APP.player.setSubtitleStream(index)
else:
LOG.error('Unknown setStreams command: %s', data)
@staticmethod @staticmethod
def _process_refresh(data): def _process_refresh(data):