Replace window var plex.playlist.ready with app.PLAYSTATE var

This commit is contained in:
croneter 2019-05-26 17:35:37 +02:00
parent 7e676eb043
commit e204ef9849
3 changed files with 11 additions and 5 deletions

View file

@ -61,8 +61,14 @@ class PlayState(object):
self.autoplay = False self.autoplay = False
# Was the playback initiated by the user using the Kodi context menu? # Was the playback initiated by the user using the Kodi context menu?
self.context_menu_play = False self.context_menu_play = False
# Which Kodi player is/has been active? (either int 1, 2 or 3) # Which Kodi player is/has been active? (either int 0, 1, 2)
self.active_players = set() self.active_players = set()
# Have we initiated playback via Plex Companion or Alexa - so from the # Have we initiated playback via Plex Companion or Alexa - so from the
# Plex side of things? # Plex side of things?
self.initiated_by_plex = False self.initiated_by_plex = False
# PKC adds/replaces items in the playqueue. We need to use
# xbmcplugin.setResolvedUrl() AFTER an item has successfully been added
# This flag is set by Kodimonitor/xbmc.Monitor() and the Playlist.OnAdd
# signal only when the currently playing item that called the
# webservice has successfully been processed
self.playlist_ready = False

View file

@ -149,7 +149,7 @@ class KodiMonitor(xbmc.Monitor):
self.playlistid = data['playlistid'] self.playlistid = data['playlistid']
if utils.window('plex.playlist.start') and data['position'] == int(utils.window('plex.playlist.start')): if utils.window('plex.playlist.start') and data['position'] == int(utils.window('plex.playlist.start')):
LOG.debug('Playlist ready') LOG.debug('Playlist ready')
utils.window('plex.playlist.ready', value='true') app.PLAYSTATE.playlist_ready = True
utils.window('plex.playlist.start', clear=True) utils.window('plex.playlist.start', clear=True)
def _playlist_onremove(self, data): def _playlist_onremove(self, data):

View file

@ -324,7 +324,7 @@ class QueuePlay(backgroundthread.KillableThread):
# Release default.py # Release default.py
utils.window('plex.playlist.play', value='true') utils.window('plex.playlist.play', value='true')
# The playlist will be ready anyway # The playlist will be ready anyway
utils.window('plex.playlist.ready', value='true') app.PLAYSTATE.playlist_ready = True
playqueue = PQ.get_playqueue_from_type(v.KODI_TYPE_AUDIO) playqueue = PQ.get_playqueue_from_type(v.KODI_TYPE_AUDIO)
playqueue.clear() playqueue.clear()
playqueue = PQ.get_playqueue_from_type(v.KODI_TYPE_VIDEO) playqueue = PQ.get_playqueue_from_type(v.KODI_TYPE_VIDEO)
@ -349,7 +349,7 @@ class QueuePlay(backgroundthread.KillableThread):
try: try:
self._run() self._run()
finally: finally:
utils.window('plex.playlist.ready', clear=True) app.PLAYSTATE.playlist_ready = False
utils.window('plex.playlist.start', clear=True) utils.window('plex.playlist.start', clear=True)
app.PLAYSTATE.initiated_by_plex = False app.PLAYSTATE.initiated_by_plex = False
self.server.threads.remove(self) self.server.threads.remove(self)
@ -387,7 +387,7 @@ class QueuePlay(backgroundthread.KillableThread):
# avoid issues with ongoing Live TV playback # avoid issues with ongoing Live TV playback
app.APP.player.stop() app.APP.player.stop()
count = 50 count = 50
while not utils.window('plex.playlist.ready'): while not app.PLAYSTATE.playlist_ready:
xbmc.sleep(50) xbmc.sleep(50)
if not count: if not count:
LOG.info('Playback aborted') LOG.info('Playback aborted')