Fix Kodi hanging if media stream selection is aborted

This commit is contained in:
croneter 2018-09-02 19:40:56 +02:00
parent 4b3f641f25
commit e14994cf74
3 changed files with 21 additions and 9 deletions

View file

@ -413,6 +413,11 @@ def _conclude_playback(playqueue, pos):
else: else:
api = None api = None
playurl = item.file playurl = item.file
if not playurl:
LOG.info('Did not get a playurl, aborting playback silently')
state.RESUME_PLAYBACK = False
pickler.pickle_me(result)
return
listitem.setPath(utils.try_encode(playurl)) listitem.setPath(utils.try_encode(playurl))
if item.playmethod == 'DirectStream': if item.playmethod == 'DirectStream':
listitem.setSubtitles(api.cache_external_subs()) listitem.setSubtitles(api.cache_external_subs())

View file

@ -24,12 +24,11 @@ class PlayUtils():
def getPlayUrl(self): def getPlayUrl(self):
""" """
Returns the playurl for the part Returns the playurl [unicode] for the part or returns None.
(movie might consist of several files) (movie might consist of several files)
playurl is in unicode!
""" """
self.api.mediastream_number() if self.api.mediastream_number() is None:
return
playurl = self.isDirectPlay() playurl = self.isDirectPlay()
if playurl is not None: if playurl is not None:
LOG.info("File is direct playing.") LOG.info("File is direct playing.")
@ -232,8 +231,9 @@ class PlayUtils():
stream by a PUT request to the PMS stream by a PUT request to the PMS
""" """
# Set media and part where we're at # Set media and part where we're at
if self.api.mediastream is None: if (self.api.mediastream is None and
self.api.mediastream_number() self.api.mediastream_number() is None):
return
try: try:
mediastreams = self.api.plex_media_streams() mediastreams = self.api.plex_media_streams()
except (TypeError, IndexError): except (TypeError, IndexError):

View file

@ -203,7 +203,8 @@ class API(object):
files are present for the same PMS item files are present for the same PMS item
""" """
if self.mediastream is None and force_first_media is False: if self.mediastream is None and force_first_media is False:
self.mediastream_number() if self.mediastream_number() is None:
return
try: try:
if force_first_media is False: if force_first_media is False:
ans = self.item[self.mediastream][self.part].attrib['file'] ans = self.item[self.mediastream][self.part].attrib['file']
@ -1294,6 +1295,9 @@ class API(object):
Returns the Media stream as an int (mostly 0). Will let the user choose Returns the Media stream as an int (mostly 0). Will let the user choose
if several media streams are present for a PMS item (if settings are if several media streams are present for a PMS item (if settings are
set accordingly) set accordingly)
Returns None if the user aborted selection (leaving self.mediastream at
its default of None)
""" """
# How many streams do we have? # How many streams do we have?
count = 0 count = 0
@ -1345,6 +1349,9 @@ class API(object):
option = utils.try_encode(option.strip()) option = utils.try_encode(option.strip())
dialoglist.append(option) dialoglist.append(option)
media = utils.dialog('select', 'Select stream', dialoglist) media = utils.dialog('select', 'Select stream', dialoglist)
if media == -1:
LOG.info('User cancelled media stream selection')
return
else: else:
media = 0 media = 0
self.mediastream = media self.mediastream = media
@ -1371,8 +1378,8 @@ class API(object):
TODO: mediaIndex TODO: mediaIndex
""" """
if self.mediastream is None: if self.mediastream is None and self.mediastream_number() is None:
self.mediastream_number() return
if quality is None: if quality is None:
quality = {} quality = {}
xargs = clientinfo.getXArgsDeviceInfo() xargs = clientinfo.getXArgsDeviceInfo()