Fix rare case when playback would not start-up
This commit is contained in:
parent
be57db9200
commit
0d0a5948ac
1 changed files with 50 additions and 50 deletions
|
@ -57,66 +57,66 @@ def playback_triage(plex_id=None, plex_type=None, path=None, resolve=True):
|
||||||
utils.dialog('notification', utils.lang(29999), utils.lang(30017))
|
utils.dialog('notification', utils.lang(29999), utils.lang(30017))
|
||||||
_ensure_resolve(abort=True)
|
_ensure_resolve(abort=True)
|
||||||
return
|
return
|
||||||
playqueue = PQ.get_playqueue_from_type(
|
with state.LOCK_PLAYQUEUES:
|
||||||
v.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[plex_type])
|
playqueue = PQ.get_playqueue_from_type(
|
||||||
try:
|
v.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[plex_type])
|
||||||
pos = js.get_position(playqueue.playlistid)
|
|
||||||
except KeyError:
|
|
||||||
# Kodi bug - Playlist plays (not Playqueue) will ALWAYS be audio for
|
|
||||||
# add-on paths
|
|
||||||
LOG.info('No position returned from Kodi player! Assuming playlist')
|
|
||||||
playqueue = PQ.get_playqueue_from_type(v.KODI_PLAYLIST_TYPE_AUDIO)
|
|
||||||
try:
|
try:
|
||||||
pos = js.get_position(playqueue.playlistid)
|
pos = js.get_position(playqueue.playlistid)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
LOG.info('Assuming video instead of audio playlist playback')
|
# Kodi bug - Playlist plays (not Playqueue) will ALWAYS be audio for
|
||||||
playqueue = PQ.get_playqueue_from_type(v.KODI_PLAYLIST_TYPE_VIDEO)
|
# add-on paths
|
||||||
|
LOG.info('No position returned from player! Assuming playlist')
|
||||||
|
playqueue = PQ.get_playqueue_from_type(v.KODI_PLAYLIST_TYPE_AUDIO)
|
||||||
try:
|
try:
|
||||||
pos = js.get_position(playqueue.playlistid)
|
pos = js.get_position(playqueue.playlistid)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
LOG.error('Still no position - abort')
|
LOG.info('Assuming video instead of audio playlist playback')
|
||||||
# "Play error"
|
playqueue = PQ.get_playqueue_from_type(v.KODI_PLAYLIST_TYPE_VIDEO)
|
||||||
utils.dialog('notification',
|
try:
|
||||||
utils.lang(29999),
|
pos = js.get_position(playqueue.playlistid)
|
||||||
utils.lang(30128),
|
except KeyError:
|
||||||
icon='{error}')
|
LOG.error('Still no position - abort')
|
||||||
_ensure_resolve(abort=True)
|
# "Play error"
|
||||||
|
utils.dialog('notification',
|
||||||
|
utils.lang(29999),
|
||||||
|
utils.lang(30128),
|
||||||
|
icon='{error}')
|
||||||
|
_ensure_resolve(abort=True)
|
||||||
|
return
|
||||||
|
# HACK to detect playback of playlists for add-on paths
|
||||||
|
items = js.playlist_get_items(playqueue.playlistid)
|
||||||
|
try:
|
||||||
|
item = items[pos]
|
||||||
|
except IndexError:
|
||||||
|
LOG.info('Could not apply playlist hack! Probably Widget playback')
|
||||||
|
else:
|
||||||
|
if ('id' not in item and
|
||||||
|
item.get('type') == 'unknown' and item.get('title') == ''):
|
||||||
|
LOG.info('Kodi playlist play detected')
|
||||||
|
_playlist_playback(plex_id, plex_type)
|
||||||
return
|
return
|
||||||
# HACK to detect playback of playlists for add-on paths
|
|
||||||
items = js.playlist_get_items(playqueue.playlistid)
|
|
||||||
try:
|
|
||||||
item = items[pos]
|
|
||||||
except IndexError:
|
|
||||||
LOG.info('Could not apply playlist hack! Probably Widget playback')
|
|
||||||
else:
|
|
||||||
if ('id' not in item and
|
|
||||||
item.get('type') == 'unknown' and item.get('title') == ''):
|
|
||||||
LOG.info('Kodi playlist play detected')
|
|
||||||
_playlist_playback(plex_id, plex_type)
|
|
||||||
return
|
|
||||||
|
|
||||||
# Can return -1 (as in "no playlist")
|
# Can return -1 (as in "no playlist")
|
||||||
pos = pos if pos != -1 else 0
|
pos = pos if pos != -1 else 0
|
||||||
LOG.debug('playQueue position %s for %s', pos, playqueue)
|
LOG.debug('playQueue position %s for %s', pos, playqueue)
|
||||||
# Have we already initiated playback?
|
# Have we already initiated playback?
|
||||||
try:
|
try:
|
||||||
item = playqueue.items[pos]
|
item = playqueue.items[pos]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
LOG.debug('PKC playqueue yet empty, need to initialize playback')
|
LOG.debug('PKC playqueue yet empty, need to initialize playback')
|
||||||
initiate = True
|
|
||||||
else:
|
|
||||||
if item.plex_id != plex_id:
|
|
||||||
LOG.debug('Received new plex_id %s, expected %s. Init playback',
|
|
||||||
plex_id, item.plex_id)
|
|
||||||
initiate = True
|
initiate = True
|
||||||
else:
|
else:
|
||||||
initiate = False
|
if item.plex_id != plex_id:
|
||||||
with state.LOCK_PLAYQUEUES:
|
LOG.debug('Received new plex_id %s, expected %s',
|
||||||
if initiate:
|
plex_id, item.plex_id)
|
||||||
_playback_init(plex_id, plex_type, playqueue, pos)
|
initiate = True
|
||||||
else:
|
else:
|
||||||
# kick off playback on second pass
|
initiate = False
|
||||||
_conclude_playback(playqueue, pos)
|
if initiate:
|
||||||
|
_playback_init(plex_id, plex_type, playqueue, pos)
|
||||||
|
else:
|
||||||
|
# kick off playback on second pass
|
||||||
|
_conclude_playback(playqueue, pos)
|
||||||
|
|
||||||
|
|
||||||
def _playlist_playback(plex_id, plex_type):
|
def _playlist_playback(plex_id, plex_type):
|
||||||
|
|
Loading…
Reference in a new issue