Play the selected element first, then add the Kodi playqueue to the Plex playqueue

- Fixes #446
This commit is contained in:
croneter 2018-03-31 20:32:55 +02:00
parent e81bee0101
commit dcf2b9b4e4

View file

@ -96,13 +96,14 @@ def _playback_init(plex_id, plex_type, playqueue, pos):
if playqueue.kodi_pl.size() > 1: if playqueue.kodi_pl.size() > 1:
# Special case - we already got a filled Kodi playqueue # Special case - we already got a filled Kodi playqueue
try: try:
_init_existing_kodi_playlist(playqueue) _init_existing_kodi_playlist(playqueue, pos)
except PL.PlaylistError: except PL.PlaylistError:
LOG.error('Aborting playback_init for longer Kodi playlist') LOG.error('Aborting playback_init for longer Kodi playlist')
_ensure_resolve(abort=True) _ensure_resolve(abort=True)
return return
# Now we need to use setResolvedUrl for the item at position pos # Now we need to use setResolvedUrl for the item at position ZERO
_conclude_playback(playqueue, pos) # playqueue.py will pick up the missing items
_conclude_playback(playqueue, 0)
return return
# "Usual" case - consider trailers and parts and build both Kodi and Plex # "Usual" case - consider trailers and parts and build both Kodi and Plex
# playqueues # playqueues
@ -185,21 +186,21 @@ def _ensure_resolve(abort=False):
state.RESUME_PLAYBACK = False state.RESUME_PLAYBACK = False
def _init_existing_kodi_playlist(playqueue): def _init_existing_kodi_playlist(playqueue, pos):
""" """
Will take the playqueue's kodi_pl with MORE than 1 element and initiate Will take the playqueue's kodi_pl with MORE than 1 element and initiate
playback (without adding trailers) playback (without adding trailers)
""" """
LOG.debug('Kodi playlist size: %s', playqueue.kodi_pl.size()) LOG.debug('Kodi playlist size: %s', playqueue.kodi_pl.size())
for i, kodi_item in enumerate(js.playlist_get_items(playqueue.playlistid)): kodi_items = js.playlist_get_items(playqueue.playlistid)
if i == 0: if not kodi_items:
item = PL.init_Plex_playlist(playqueue, kodi_item=kodi_item) raise PL.PlaylistError('No Kodi items returned')
else: item = PL.init_Plex_playlist(playqueue, kodi_item=kodi_items[pos])
item = PL.add_item_to_PMS_playlist(playqueue,
i,
kodi_item=kodi_item)
item.force_transcode = state.FORCE_TRANSCODE item.force_transcode = state.FORCE_TRANSCODE
LOG.debug('Done building Plex playlist from Kodi playlist') # playqueue.py will add the rest - this will likely put the PMS under
# a LOT of strain if the following Kodi setting is enabled:
# Settings -> Player -> Videos -> Play next video automatically
LOG.debug('Done init_existing_kodi_playlist')
def _prep_playlist_stack(xml): def _prep_playlist_stack(xml):