From 439857a9cebb44d682ca30c48b9222a9509f8803 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 7 Apr 2019 13:27:26 +0200 Subject: [PATCH] Rewire autoplay flag --- resources/lib/app/playstate.py | 2 ++ resources/lib/kodimonitor.py | 7 +++++-- resources/lib/playstrm.py | 8 +++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/resources/lib/app/playstate.py b/resources/lib/app/playstate.py index 3b9be12f..e44b21a1 100644 --- a/resources/lib/app/playstate.py +++ b/resources/lib/app/playstate.py @@ -57,6 +57,8 @@ class PlayState(object): # from the beginning? # Do set to None if NO resume dialog is displayed! True/False otherwise self.resume_playback = None + # Don't ask user whether to resume but immediatly resume + self.autoplay = False # 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? diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index 8fde54b4..827adb71 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -32,6 +32,7 @@ class KodiMonitor(xbmc.Monitor): def __init__(self): self._already_slept = False self.hack_replay = None + self.playlistid = None xbmc.Monitor.__init__(self) for playerid in app.PLAYSTATE.player_states: app.PLAYSTATE.player_states[playerid] = copy.deepcopy(app.PLAYSTATE.template) @@ -202,14 +203,16 @@ class KodiMonitor(xbmc.Monitor): """ pass - @staticmethod - def _playlist_onclear(data): + def _playlist_onclear(self, data): """ Called if a Kodi playlist is cleared. Example data dict: { u'playlistid': 1, } """ + if self.playlistid == data['playlistid']: + LOG.debug('Resetting autoplay') + app.PLAYSTATE.autoplay = False playqueue = PQ.PLAYQUEUES[data['playlistid']] if not playqueue.is_pkc_clear(): playqueue.pkc_edit = True diff --git a/resources/lib/playstrm.py b/resources/lib/playstrm.py index e44093b6..7fa81f4e 100644 --- a/resources/lib/playstrm.py +++ b/resources/lib/playstrm.py @@ -208,19 +208,17 @@ class PlayStrm(object): ''' seektime = app.PLAYSTATE.resume_playback app.PLAYSTATE.resume_playback = None - auto_play = utils.window('plex.autoplay.bool') - if auto_play: + if app.PLAYSTATE.autoplay: seektime = False LOG.info('Skip resume for autoplay') elif seektime is None: resume = self.api.resume_point() if resume: seektime = resume_dialog(resume) - LOG.info('Resume: %s', seektime) + LOG.info('User chose resume: %s', seektime) if seektime is None: raise PlayStrmException('User backed out of resume dialog.') - # Todo: Probably need to have a look here - utils.window('plex.autoplay.bool', value='true') + app.PLAYSTATE.autoplay = True return seektime def _set_intros(self, xml):