From f3d53460e92dc50f7a998375c2fb4a766a1af942 Mon Sep 17 00:00:00 2001 From: Jake Weinstein Date: Sun, 14 Sep 2025 14:46:04 -0500 Subject: [PATCH] Add setting to prevent auto-playing when you're alone in the room --- syncplay/client.py | 12 +++++++++++- syncplay/messages_en.py | 2 ++ syncplay/ui/ConfigurationGetter.py | 4 +++- syncplay/ui/GuiConfiguration.py | 3 +++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/syncplay/client.py b/syncplay/client.py index 54f12950..da36746b 100755 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -986,6 +986,10 @@ def instaplayConditionsMet(self): if not self.userlist.currentUser.canControl(): return False + # Check if user is alone in the room and preventAutoplayWhenAloneInRoom is enabled + if self._config["preventAutoplayWhenAloneInRoom"] and self.userlist.areYouAloneInRoom() and not self._recentlyAdvanced(): + return False + unpauseAction = self._config['unpauseAction'] if self.userlist.currentUser.isReady() or unpauseAction == constants.UNPAUSE_ALWAYS_MODE: return True @@ -998,9 +1002,15 @@ def instaplayConditionsMet(self): return False def autoplayConditionsMet(self): + recentlyAdvanced = self._recentlyAdvanced() + + # Check if user is alone in the room and preventAutoplayWhenAloneInRoom is enabled + if self._config["preventAutoplayWhenAloneInRoom"] and self.userlist.areYouAloneInRoom() and not recentlyAdvanced: + return False + if self.seamlessMusicOveride(): self.setPaused(False) - recentlyAdvanced = self._recentlyAdvanced() + return ( self._playerPaused and (self.autoPlay or recentlyAdvanced) and self.userlist.currentUser.canControl() and self.userlist.isReadinessSupported() diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index f568cbf9..bc62b89a 100644 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -238,6 +238,7 @@ "dontslowdownwithme-label": "Never slow down or rewind others (experimental)", "pausing-title": "Pausing", "pauseonleave-label": "Pause when user leaves (e.g. if they are disconnected)", + "preventautoplaywhenaloneinroom-label": "Don't auto-play videos before others join", "readiness-title": "Initial readiness state", "readyatstart-label": "Set me as 'ready to watch' by default", "forceguiprompt-label": "Don't always show the Syncplay configuration window", # (Inverted) @@ -424,6 +425,7 @@ "slowondesync-tooltip": "Reduce playback rate temporarily when needed to bring you back in sync with other viewers. Not supported on MPC-HC/BE.", "dontslowdownwithme-tooltip": "Means others do not get slowed down or rewinded if your playback is lagging. Useful for room operators.", "pauseonleave-tooltip": "Pause playback if you get disconnected or someone leaves from your room.", + "preventautoplaywhenaloneinroom-tooltip": "Don't auto-play videos before others have joined the room.", "readyatstart-tooltip": "Set yourself as 'ready' at start (otherwise you are set as 'not ready' until you change your readiness state)", "forceguiprompt-tooltip": "Configuration dialogue is not shown when opening a file with Syncplay.", # (Inverted) "nostore-tooltip": "Run Syncplay with the given configuration, but do not permanently store the changes.", # (Inverted) diff --git a/syncplay/ui/ConfigurationGetter.py b/syncplay/ui/ConfigurationGetter.py index 0df41867..5c0952c0 100755 --- a/syncplay/ui/ConfigurationGetter.py +++ b/syncplay/ui/ConfigurationGetter.py @@ -57,6 +57,7 @@ def __init__(self): "filenamePrivacyMode": constants.PRIVACY_SENDRAW_MODE, "filesizePrivacyMode": constants.PRIVACY_SENDRAW_MODE, "pauseOnLeave": False, + "preventAutoplayWhenAloneInRoom": False, "readyAtStart": False, "unpauseAction": constants.UNPAUSE_IFOTHERSREADY_MODE, "autoplayInitialState": None, @@ -122,6 +123,7 @@ def __init__(self): "noStore", "dontSlowDownWithMe", "pauseOnLeave", + "preventAutoplayWhenAloneInRoom", "readyAtStart", "autoplayRequireSameFilenames", "clearGUIData", @@ -201,7 +203,7 @@ def __init__(self): "fastforwardOnDesync", "dontSlowDownWithMe", "forceGuiPrompt", "filenamePrivacyMode", "filesizePrivacyMode", "unpauseAction", - "pauseOnLeave", "readyAtStart", "autoplayMinUsers", + "pauseOnLeave", "preventAutoplayWhenAloneInRoom", "readyAtStart", "autoplayMinUsers", "autoplayInitialState", "mediaSearchDirectories", "sharedPlaylistEnabled", "loopAtEndOfPlaylist", "loopSingleFiles", diff --git a/syncplay/ui/GuiConfiguration.py b/syncplay/ui/GuiConfiguration.py index 43ef0007..7a834f8c 100755 --- a/syncplay/ui/GuiConfiguration.py +++ b/syncplay/ui/GuiConfiguration.py @@ -815,6 +815,9 @@ def addReadinessTab(self): self.pauseonleaveCheckbox = QCheckBox(getMessage("pauseonleave-label")) self.pauseonleaveCheckbox.setObjectName("pauseOnLeave") self.readyPauseLayout.addWidget(self.pauseonleaveCheckbox) + self.preventAutoplayWhenAloneInRoomCheckbox = QCheckBox(getMessage("preventautoplaywhenaloneinroom-label")) + self.preventAutoplayWhenAloneInRoomCheckbox.setObjectName("preventAutoplayWhenAloneInRoom") + self.readyPauseLayout.addWidget(self.preventAutoplayWhenAloneInRoomCheckbox) self.readyLayout.addWidget(self.readyPauseGroup) # Unpausing