From 5e3f3daf905b11a4dd74655e3a5adceb9bd090ea Mon Sep 17 00:00:00 2001 From: croneter Date: Fri, 1 Nov 2019 13:00:34 +0100 Subject: [PATCH] Get rid of ContextMonitor and the dedicated Python thread - with new resume mechanics, this is not needed anymore --- resources/lib/kodimonitor.py | 38 ---------------------------------- resources/lib/playback.py | 4 ---- resources/lib/service_entry.py | 4 ---- 3 files changed, 46 deletions(-) diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index aa864961..e143140f 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -11,7 +11,6 @@ import json import binascii import xbmc -import xbmcgui from .plex_api import API from .plex_db import PlexDB @@ -23,10 +22,6 @@ from . import backgroundthread, app, variables as v LOG = getLogger('PLEX.kodimonitor') -# "Start from beginning", "Play from beginning" -STRINGS = (utils.lang(12021).encode('utf-8'), - utils.lang(12023).encode('utf-8')) - class KodiMonitor(xbmc.Monitor): """ @@ -593,36 +588,3 @@ def _videolibrary_onupdate(data): PF.scrobble(db_item['plex_id'], 'watched') else: PF.scrobble(db_item['plex_id'], 'unwatched') - - -class ContextMonitor(backgroundthread.KillableThread): - """ - Detect the resume dialog for widgets. Could also be used to detect - external players (see Emby implementation) - - Let's not register this thread because it won't quit due to - xbmc.getCondVisibility - It should still exit at some point due to xbmc.abortRequested - """ - def run(self): - LOG.info("----===## Starting ContextMonitor ##===----") - # app.APP.register_thread(self) - try: - self._run() - finally: - # app.APP.deregister_thread(self) - LOG.info("##===---- ContextMonitor Stopped ----===##") - - def _run(self): - while not self.isCanceled(): - # The following function will block if called while PKC should - # exit! - if xbmc.getCondVisibility('Window.IsVisible(DialogContextMenu.xml)'): - if xbmc.getInfoLabel('Control.GetLabel(1002)') in STRINGS: - # Remember that the item IS indeed resumable - control = int(xbmcgui.Window(10106).getFocusId()) - app.PLAYSTATE.resume_playback = True if control == 1001 else False - else: - # Different context menu is displayed - app.PLAYSTATE.resume_playback = False - xbmc.sleep(100) diff --git a/resources/lib/playback.py b/resources/lib/playback.py index df54d18a..796cbe7b 100644 --- a/resources/lib/playback.py +++ b/resources/lib/playback.py @@ -54,7 +54,6 @@ def playback_triage(plex_id=None, plex_type=None, path=None, resolve=True, # playback app.PLAYSTATE.context_menu_play = False app.PLAYSTATE.force_transcode = False - app.PLAYSTATE.resume_playback = None def _playback_triage(plex_id, plex_type, path, resolve, resume): @@ -133,9 +132,6 @@ def _playback_triage(plex_id, plex_type, path, resolve, resume): initiate = True else: initiate = False - if not initiate and app.PLAYSTATE.resume_playback is not None: - LOG.debug('Detected re-playing of the same item') - initiate = True if initiate: _playback_init(plex_id, plex_type, playqueue, pos, resume) else: diff --git a/resources/lib/service_entry.py b/resources/lib/service_entry.py index 70e97a90..b7b10aed 100644 --- a/resources/lib/service_entry.py +++ b/resources/lib/service_entry.py @@ -95,7 +95,6 @@ class Service(object): self.setup = None self.alexa = None self.playqueue = None - self.context_monitor = None # Flags for other threads self.connection_check_running = False self.auth_running = False @@ -422,9 +421,6 @@ class Service(object): # Some plumbing app.init() app.APP.monitor = kodimonitor.KodiMonitor() - self.context_monitor = kodimonitor.ContextMonitor() - # Start immediately to catch user input even before auth - self.context_monitor.start() app.APP.player = xbmc.Player() # Initialize the PKC playqueues PQ.init_playqueues()