diff --git a/resources/lib/app/playstate.py b/resources/lib/app/playstate.py index 1e63bece..67430e87 100644 --- a/resources/lib/app/playstate.py +++ b/resources/lib/app/playstate.py @@ -64,7 +64,5 @@ class PlayState(object): self.audioplaylist = None # Was the playback initiated by the user using the Kodi context menu? self.context_menu_play = False - # Set by context menu - shall we force-transcode the next playing item? - self.force_transcode = False # Which Kodi player is/has been active? (either int 1, 2 or 3) self.active_players = set() diff --git a/resources/lib/context_entry.py b/resources/lib/context_entry.py index 211ca709..9c6a0236 100644 --- a/resources/lib/context_entry.py +++ b/resources/lib/context_entry.py @@ -7,7 +7,7 @@ import xbmcgui from .plex_api import API from .plex_db import PlexDB -from . import context, plex_functions as PF, playqueue as PQ +from . import context, plex_functions as PF from . import utils, variables as v, app ############################################################################### @@ -112,8 +112,7 @@ class ContextMenu(object): """ selected = self._selected_option if selected == OPTIONS['Transcode']: - app.PLAYSTATE.force_transcode = True - self._PMS_play() + self._PMS_play(transcode=True) elif selected == OPTIONS['PMS_Play']: self._PMS_play() elif selected == OPTIONS['Extras']: @@ -139,17 +138,21 @@ class ContextMenu(object): if PF.delete_item_from_pms(self.plex_id) is False: utils.dialog("ok", heading="{plex}", line1=utils.lang(30414)) - def _PMS_play(self): + def _PMS_play(self, transcode=False): """ For using direct paths: Initiates playback using the PMS """ - playqueue = PQ.get_playqueue_from_type( - v.KODI_PLAYLIST_TYPE_FROM_KODI_TYPE[self.kodi_type]) - playqueue.clear() - app.PLAYSTATE.context_menu_play = True - handle = self.api.path(force_first_media=False, force_addon=True) - handle = 'RunPlugin(%s)' % handle - xbmc.executebuiltin(handle.encode('utf-8')) + path = ('http://127.0.0.1:%s/plex/play/file.strm?plex_id=%s' + % (v.WEBSERVICE_PORT, self.plex_id)) + if self.plex_type: + path += '&plex_type=%s' % self.plex_type + if self.kodi_id: + path += '&kodi_id=%s' % self.kodi_id + if self.kodi_type: + path += '&kodi_type=%s' % self.kodi_type + if transcode: + path += '&transcode=true' + xbmc.executebuiltin(('PlayMedia(%s)' % path).encode('utf-8')) def _extras(self): """ diff --git a/resources/lib/playstrm.py b/resources/lib/playstrm.py index 97938b8d..3fd26f83 100644 --- a/resources/lib/playstrm.py +++ b/resources/lib/playstrm.py @@ -108,9 +108,12 @@ class PlayStrm(object): else: self.xml[0].set('pkc_db_item', None) self.api = API(self.xml[0]) - self.playqueue_item = PL.playlist_item_from_xml(self.xml[0], - kodi_id=self.kodi_id, - kodi_type=self.kodi_type) + + def set_playqueue_item(self, xml, kodi_id, kodi_type): + self.playqueue_item = PL.playlist_item_from_xml(xml, + kodi_id=kodi_id, + kodi_type=kodi_type) + self.playqueue_item.force_transcode = self.transcode def start_playback(self, index=0): LOG.debug('Starting playback at %s', index) @@ -196,7 +199,6 @@ class PlayStrm(object): utils.lang(30128), icon='{error}') app.PLAYSTATE.context_menu_play = False - app.PLAYSTATE.force_transcode = False app.PLAYSTATE.resume_playback = False return PL.get_playlist_details_from_xml(self.playqueue, xml) @@ -208,7 +210,7 @@ class PlayStrm(object): else: listitem = widgets.get_listitem(self.xml[0], resume=False) listitem.setSubtitles(self.api.cache_external_subs()) - self.playqueue_item = PL.playlist_item_from_xml(self.xml[0]) + self.set_playqueue_item(self.xml[0], self.kodi_id, self.kodi_type) play = PlayUtils(self.api, self.playqueue_item) url = play.getPlayUrl().encode('utf-8') listitem.setPath(url) @@ -250,7 +252,7 @@ class PlayStrm(object): continue LOG.debug('Adding trailer: %s', api.title()) listitem = widgets.get_listitem(intro, resume=False) - self.playqueue_item = PL.playlist_item_from_xml(intro) + self.set_playqueue_item(intro, None, None) play = PlayUtils(api, self.playqueue_item) url = play.getPlayUrl().encode('utf-8') listitem.setPath(url) @@ -265,9 +267,7 @@ class PlayStrm(object): continue self.api.set_part_number(part) LOG.debug('Adding addional part %s', part) - self.playqueue_item = PL.playlist_item_from_xml(self.xml[0], - kodi_id=self.kodi_id, - kodi_type=self.kodi_type) + self.set_playqueue_item(self.xml[0], self.kodi_id, self.kodi_type) self.playqueue_item.part = part listitem = widgets.get_listitem(self.xml[0], resume=False) listitem.setSubtitles(self.api.cache_external_subs())