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:
api = None
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))
if item.playmethod == 'DirectStream':
listitem.setSubtitles(api.cache_external_subs())

View file

@ -24,12 +24,11 @@ class PlayUtils():
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)
playurl is in unicode!
"""
self.api.mediastream_number()
if self.api.mediastream_number() is None:
return
playurl = self.isDirectPlay()
if playurl is not None:
LOG.info("File is direct playing.")
@ -232,8 +231,9 @@ class PlayUtils():
stream by a PUT request to the PMS
"""
# Set media and part where we're at
if self.api.mediastream is None:
self.api.mediastream_number()
if (self.api.mediastream is None and
self.api.mediastream_number() is None):
return
try:
mediastreams = self.api.plex_media_streams()
except (TypeError, IndexError):

View file

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