Fix PKC not exiting correctly due to a call to xbmc.getCondVisibility
This commit is contained in:
parent
fa9ca95e2e
commit
a9ff70fac7
2 changed files with 42 additions and 19 deletions
|
@ -7,7 +7,9 @@ from __future__ import absolute_import, division, unicode_literals
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from json import loads
|
from json import loads
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
|
import xbmcgui
|
||||||
|
|
||||||
from .plex_db import PlexDB
|
from .plex_db import PlexDB
|
||||||
from . import kodi_db
|
from . import kodi_db
|
||||||
|
@ -16,11 +18,11 @@ from . import utils, timing, plex_functions as PF, playback
|
||||||
from . import json_rpc as js, playqueue as PQ, playlist_func as PL
|
from . import json_rpc as js, playqueue as PQ, playlist_func as PL
|
||||||
from . import backgroundthread, app, variables as v
|
from . import backgroundthread, app, variables as v
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
LOG = getLogger('PLEX.kodimonitor')
|
LOG = getLogger('PLEX.kodimonitor')
|
||||||
|
|
||||||
###############################################################################
|
# "Start from beginning", "Play from beginning"
|
||||||
|
STRINGS = (utils.try_encode(utils.lang(12021)),
|
||||||
|
utils.try_encode(utils.lang(12023)))
|
||||||
|
|
||||||
|
|
||||||
class KodiMonitor(xbmc.Monitor):
|
class KodiMonitor(xbmc.Monitor):
|
||||||
|
@ -530,3 +532,36 @@ def _clean_file_table():
|
||||||
LOG.debug('Database was locked, unable to clean file table')
|
LOG.debug('Database was locked, unable to clean file table')
|
||||||
else:
|
else:
|
||||||
LOG.debug('Done cleaning up Kodi file table')
|
LOG.debug('Done cleaning up Kodi file table')
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
app.APP.monitor.waitForAbort(0.1)
|
||||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import absolute_import, division, unicode_literals
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
|
||||||
|
|
||||||
from . import utils, clientinfo, timing
|
from . import utils, clientinfo, timing
|
||||||
from . import initialsetup
|
from . import initialsetup
|
||||||
|
@ -30,10 +29,6 @@ WINDOW_PROPERTIES = (
|
||||||
"pms_token", "plex_token", "plex_authenticated", "plex_restricteduser",
|
"pms_token", "plex_token", "plex_authenticated", "plex_restricteduser",
|
||||||
"plex_allows_mediaDeletion", "plexkodiconnect.command", "plex_result")
|
"plex_allows_mediaDeletion", "plexkodiconnect.command", "plex_result")
|
||||||
|
|
||||||
# "Start from beginning", "Play from beginning"
|
|
||||||
STRINGS = (utils.try_encode(utils.lang(12021)),
|
|
||||||
utils.try_encode(utils.lang(12023)))
|
|
||||||
|
|
||||||
|
|
||||||
class Service(object):
|
class Service(object):
|
||||||
ws = None
|
ws = None
|
||||||
|
@ -105,6 +100,7 @@ class Service(object):
|
||||||
self.setup = None
|
self.setup = None
|
||||||
self.alexa = None
|
self.alexa = None
|
||||||
self.playqueue = None
|
self.playqueue = None
|
||||||
|
self.context_monitor = None
|
||||||
# Flags for other threads
|
# Flags for other threads
|
||||||
self.connection_check_running = False
|
self.connection_check_running = False
|
||||||
self.auth_running = False
|
self.auth_running = False
|
||||||
|
@ -402,6 +398,9 @@ class Service(object):
|
||||||
# Some plumbing
|
# Some plumbing
|
||||||
app.init()
|
app.init()
|
||||||
app.APP.monitor = kodimonitor.KodiMonitor()
|
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()
|
app.APP.player = xbmc.Player()
|
||||||
# Initialize the PKC playqueues
|
# Initialize the PKC playqueues
|
||||||
PQ.init_playqueues()
|
PQ.init_playqueues()
|
||||||
|
@ -467,17 +466,6 @@ class Service(object):
|
||||||
app.APP.monitor.waitForAbort(0.1)
|
app.APP.monitor.waitForAbort(0.1)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Detect the resume dialog for widgets. Could also be used to detect
|
|
||||||
# external players (see Emby implementation)
|
|
||||||
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
|
|
||||||
|
|
||||||
# Before proceeding, need to make sure:
|
# Before proceeding, need to make sure:
|
||||||
# 1. Server is online
|
# 1. Server is online
|
||||||
# 2. User is set
|
# 2. User is set
|
||||||
|
|
Loading…
Reference in a new issue