diff --git a/resources/lib/playback.py b/resources/lib/playback.py index 4619bcf5..b29e4364 100644 --- a/resources/lib/playback.py +++ b/resources/lib/playback.py @@ -36,6 +36,9 @@ def playback_triage(plex_id=None, plex_type=None, path=None, resolve=True): Hit this function for addon path playback, Plex trailers, etc. Will setup playback first, then on second call complete playback. + path: either the complete plugin://plugin.video.plexkodiconnect path + OR just the query '?plex_id=458160&mode=play&plex_type=movie' + Will set Playback_Successful() with potentially a PKC_ListItem() attached (to be consumed by setResolvedURL in default.py) @@ -65,7 +68,7 @@ def playback_triage(plex_id=None, plex_type=None, path=None, resolve=True): LOG.debug('playQueue position: %s for %s', pos, playqueue) # Have we already initiated playback? try: - playqueue.items[pos] + item = playqueue.items[pos] except IndexError: # Release our default.py before starting our own Kodi player instance if resolve is True: @@ -75,8 +78,20 @@ def playback_triage(plex_id=None, plex_type=None, path=None, resolve=True): pickle_me(result) playback_init(plex_id, plex_type, playqueue) else: - # kick off playback on second pass - conclude_playback(playqueue, pos) + if item.playback_init is False: + # Hack: we need to use setResolvedUrl twice. Otherwise, Kodi + # overwrites the path in the Kodi database (addon-path) with the + # result of the first setResolvedUrl + item.playback_init = True + if not path.startswith('plugin://'): + path = 'plugin://%s%s' % (v.ADDON_ID, path) + LOG.debug('Initializing playback for one item using path %s', path) + result = Playback_Successful() + result.listitem = PKC_ListItem(path=path) + pickle_me(result) + else: + # kick off playback on second pass + conclude_playback(playqueue, pos) def playback_init(plex_id, plex_type, playqueue): diff --git a/resources/lib/playback_starter.py b/resources/lib/playback_starter.py index ccdca94e..d9a6414d 100644 --- a/resources/lib/playback_starter.py +++ b/resources/lib/playback_starter.py @@ -28,7 +28,7 @@ class Playback_Starter(Thread): if mode == 'play': playback.playback_triage(plex_id=params.get('plex_id'), plex_type=params.get('plex_type'), - path=params.get('path')) + path=item) elif mode == 'plex_node': playback.process_indirect(params['key'], params['offset']) elif mode == 'context_menu': diff --git a/resources/lib/playlist_func.py b/resources/lib/playlist_func.py index 76f1d23b..07ed82ba 100644 --- a/resources/lib/playlist_func.py +++ b/resources/lib/playlist_func.py @@ -138,6 +138,8 @@ class Playlist_Item(object): offset = None [int] the item's view offset UPON START in Plex time part = 0 [int] part number if Plex video consists of mult. parts force_transcode [bool] defaults to False + playback_init [bool] Hack to use setResolvedUrl twice (and thus only + "correctly") if playback_init is set to True """ def __init__(self): self.id = None @@ -156,6 +158,7 @@ class Playlist_Item(object): # If Plex video consists of several parts; part number self.part = 0 self.force_transcode = False + self.playback_init = False def __repr__(self): """