Move detection of context menu to main loop
- One thread less!
This commit is contained in:
parent
c4156cb865
commit
7d2f785a8d
2 changed files with 16 additions and 33 deletions
|
@ -8,7 +8,6 @@ from logging import getLogger
|
||||||
from json import loads
|
from json import loads
|
||||||
import copy
|
import copy
|
||||||
import xbmc
|
import xbmc
|
||||||
from xbmcgui import Window
|
|
||||||
|
|
||||||
from .plex_db import PlexDB
|
from .plex_db import PlexDB
|
||||||
from . import kodi_db
|
from . import kodi_db
|
||||||
|
@ -396,36 +395,6 @@ class KodiMonitor(xbmc.Monitor):
|
||||||
LOG.debug('Set the player state: %s', status)
|
LOG.debug('Set the player state: %s', status)
|
||||||
|
|
||||||
|
|
||||||
class SpecialMonitor(backgroundthread.KillableThread):
|
|
||||||
"""
|
|
||||||
Detect the resume dialog for widgets.
|
|
||||||
Could also be used to detect external players (see Emby implementation)
|
|
||||||
"""
|
|
||||||
def run(self):
|
|
||||||
LOG.info("----====# Starting Special Monitor #====----")
|
|
||||||
# "Start from beginning", "Play from beginning"
|
|
||||||
strings = (utils.try_encode(utils.lang(12021)),
|
|
||||||
utils.try_encode(utils.lang(12023)))
|
|
||||||
while not self.isCanceled():
|
|
||||||
if xbmc.getCondVisibility('Window.IsVisible(DialogContextMenu.xml)'):
|
|
||||||
if xbmc.getInfoLabel('Control.GetLabel(1002)') in strings:
|
|
||||||
# Remember that the item IS indeed resumable
|
|
||||||
control = int(Window(10106).getFocusId())
|
|
||||||
app.PLAYSTATE.resume_playback = True if control == 1001 else False
|
|
||||||
else:
|
|
||||||
# Different context menu is displayed
|
|
||||||
app.PLAYSTATE.resume_playback = False
|
|
||||||
if xbmc.getCondVisibility('Window.IsVisible(MyVideoNav.xml)'):
|
|
||||||
path = xbmc.getInfoLabel('container.folderpath')
|
|
||||||
if (isinstance(path, str) and
|
|
||||||
path.startswith('special://profile/playlists')):
|
|
||||||
pass
|
|
||||||
# TODO: start polling PMS for playlist changes
|
|
||||||
# Optionally: poll PMS continuously with custom intervall
|
|
||||||
app.APP.monitor.waitForAbort(0.2)
|
|
||||||
LOG.info("#====---- Special Monitor Stopped ----====#")
|
|
||||||
|
|
||||||
|
|
||||||
def _playback_cleanup(ended=False):
|
def _playback_cleanup(ended=False):
|
||||||
"""
|
"""
|
||||||
PKC cleanup after playback ends/is stopped. Pass ended=True if Kodi
|
PKC cleanup after playback ends/is stopped. Pass ended=True if Kodi
|
||||||
|
|
|
@ -4,6 +4,7 @@ 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, artwork
|
from . import initialsetup, artwork
|
||||||
|
@ -30,6 +31,10 @@ WINDOW_PROPERTIES = (
|
||||||
"plex_authenticated", "plex_restricteduser", "plex_allows_mediaDeletion",
|
"plex_authenticated", "plex_restricteduser", "plex_allows_mediaDeletion",
|
||||||
"plex_command", "plex_result")
|
"plex_command", "plex_result")
|
||||||
|
|
||||||
|
# "Start from beginning", "Play from beginning"
|
||||||
|
STRINGS = (utils.try_encode(utils.lang(12021)),
|
||||||
|
utils.try_encode(utils.lang(12023)))
|
||||||
|
|
||||||
|
|
||||||
class Service():
|
class Service():
|
||||||
ws = None
|
ws = None
|
||||||
|
@ -336,7 +341,6 @@ class Service():
|
||||||
self.alexa = websocket_client.Alexa_Websocket()
|
self.alexa = websocket_client.Alexa_Websocket()
|
||||||
self.sync = sync.Sync()
|
self.sync = sync.Sync()
|
||||||
self.plexcompanion = plex_companion.PlexCompanion()
|
self.plexcompanion = plex_companion.PlexCompanion()
|
||||||
self.specialmonitor = kodimonitor.SpecialMonitor()
|
|
||||||
self.playback_starter = playback_starter.PlaybackStarter()
|
self.playback_starter = playback_starter.PlaybackStarter()
|
||||||
self.playqueue = playqueue.PlayqueueMonitor()
|
self.playqueue = playqueue.PlayqueueMonitor()
|
||||||
|
|
||||||
|
@ -399,6 +403,17 @@ class Service():
|
||||||
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
|
||||||
|
@ -428,7 +443,6 @@ class Service():
|
||||||
continue
|
continue
|
||||||
elif not self.startup_completed:
|
elif not self.startup_completed:
|
||||||
self.startup_completed = True
|
self.startup_completed = True
|
||||||
self.specialmonitor.start()
|
|
||||||
self.ws.start()
|
self.ws.start()
|
||||||
self.sync.start()
|
self.sync.start()
|
||||||
self.plexcompanion.start()
|
self.plexcompanion.start()
|
||||||
|
|
Loading…
Reference in a new issue