From 234c34e0da05068346baec392c118398247fa0a9 Mon Sep 17 00:00:00 2001 From: Core447 Date: Wed, 27 Mar 2024 09:58:41 +0100 Subject: [PATCH] Improve show_current_rec_status --- actions/ToggleRecord/ToggleRecord.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/actions/ToggleRecord/ToggleRecord.py b/actions/ToggleRecord/ToggleRecord.py index e94a45b..945392d 100644 --- a/actions/ToggleRecord/ToggleRecord.py +++ b/actions/ToggleRecord/ToggleRecord.py @@ -13,6 +13,7 @@ class ToggleRecord(OBSActionBase): self.current_state = -1 def on_ready(self): + self.current_state = -1 # Connect to obs if not connected if self.plugin_base.backend is not None: if not self.plugin_base.backend.get_connected(): # self.plugin_base.obs.connect_to(host="localhost", port=4444, timeout=3, legacy=False) @@ -22,12 +23,18 @@ class ToggleRecord(OBSActionBase): self.show_current_rec_status() def show_current_rec_status(self, new_paused = False): + if self.plugin_base.backend is None: + self.current_state = -1 + self.show_error() + return if not self.plugin_base.backend.get_connected(): - self.set_media(media_path=os.path.join(self.plugin_base.PATH, "assets", "error.png")) + self.current_state = -1 + self.show_error() return status = self.plugin_base.backend.get_record_status() if status is None: - self.set_media(media_path=os.path.join(self.plugin_base.PATH, "assets", "error.png")) + self.current_state = -1 + self.show_error() return if status["paused"]: self.show_for_state(2) @@ -61,11 +68,18 @@ class ToggleRecord(OBSActionBase): self.set_media(media_path=os.path.join(self.plugin_base.PATH, "assets", image)) def on_key_down(self): + if self.plugin_base.backend is None: + self.current_state = -1 + self.show_error() + return if not self.plugin_base.backend.get_connected(): + self.current_state = -1 + self.show_error() return self.plugin_base.backend.toggle_record() def on_tick(self): + return self.show_current_rec_status() def show_rec_time(self):