From 96fde4db32fe8e8dd31d6f4aa0769a4532b68439 Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 13 Nov 2021 14:05:51 +0100 Subject: [PATCH] Fix skip intro not working --- resources/lib/plex_companion/playstate.py | 7 ------- resources/lib/service_entry.py | 4 ++++ resources/lib/skip_plex_intro.py | 4 ++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/resources/lib/plex_companion/playstate.py b/resources/lib/plex_companion/playstate.py index b1872bff..79e16454 100644 --- a/resources/lib/plex_companion/playstate.py +++ b/resources/lib/plex_companion/playstate.py @@ -12,7 +12,6 @@ from .. import variables as v from .. import backgroundthread from .. import app from .. import timing -from .. import skip_plex_intro # Disable annoying requests warnings @@ -408,12 +407,6 @@ class PlaystateMgr(backgroundthread.KillableThread): else: continue signaled_playback_stop = False - try: - # Check whether an intro is currently running - skip_plex_intro.check() - except IndexError: - # Playback might have already stopped - pass # Send the playback progress info to the PMS self.pms_timeline(players, message) # Send the info to all Companion devices via the PMS diff --git a/resources/lib/service_entry.py b/resources/lib/service_entry.py index a966576c..c37b26b8 100644 --- a/resources/lib/service_entry.py +++ b/resources/lib/service_entry.py @@ -18,6 +18,7 @@ from . import variables as v from . import app from . import loghandler from . import backgroundthread +from . import skip_plex_intro from .windows import userselect ############################################################################### @@ -554,6 +555,9 @@ class Service(object): self.companion_listener.start() self.alexa_ws.start() + elif app.APP.is_playing: + skip_plex_intro.check() + xbmc.sleep(200) # EXITING PKC diff --git a/resources/lib/skip_plex_intro.py b/resources/lib/skip_plex_intro.py index ec6d76ad..f7b22867 100644 --- a/resources/lib/skip_plex_intro.py +++ b/resources/lib/skip_plex_intro.py @@ -15,6 +15,8 @@ def skip_intro(intros): if start <= progress < end: in_intro = True if in_intro and app.APP.skip_intro_dialog is None: + # WARNING: This Dialog only seems to work if called from the main + # thread. Otherwise, onClick and onAction won't work app.APP.skip_intro_dialog = SkipIntroDialog('script-plex-skip_intro.xml', v.ADDON_PATH, 'default', @@ -32,6 +34,8 @@ def skip_intro(intros): def check(): with app.APP.lock_playqueues: + if len(app.PLAYSTATE.active_players) != 1: + return playerid = list(app.PLAYSTATE.active_players)[0] intros = app.PLAYSTATE.player_states[playerid]['intro_markers'] if not intros: