Merge pull request #310 from Lumenol/fix_change_audio_subtitle_stream_remotely

Fix choose the audio stream and the subtitle stream remotely
This commit is contained in:
Abby 2020-06-11 01:47:43 +01:00 committed by GitHub
commit f0bb8dfc3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -389,6 +389,8 @@ class Monitor(xbmc.Monitor):
elif command == 'SetSubtitleStreamIndex':
self.player.set_audio_subs(None, args['Index'])
# Kodi needs a bit of time to update it's current status
xbmc.sleep(500)
self.player.report_playback()
elif command == 'DisplayMessage':

View File

@ -155,6 +155,10 @@ class Player(xbmc.Player):
LOG.info("-->[ play/%s ] %s", item['Id'], item)
def set_audio_subs(self, audio=None, subtitle=None):
if audio:
audio=int(audio)
if subtitle:
subtitle=int(subtitle)
''' Only for after playback started
'''
@ -169,7 +173,7 @@ class Player(xbmc.Player):
if audio and len(self.getAvailableAudioStreams()) > 1:
self.setAudioStream(audio - 1)
if subtitle == -1 or subtitle is None:
if subtitle is None or subtitle == -1:
self.showSubtitles(False)
return