From ea9f32b461801ef3ff463532ccc25d2c25240be6 Mon Sep 17 00:00:00 2001 From: Et0h Date: Thu, 19 Jun 2014 16:19:08 +0100 Subject: [PATCH] Add rewind/slowdown threshold to GuiConfig, etc --- syncplay/client.py | 4 +- syncplay/constants.py | 5 +- syncplay/messages.py | 8 +- syncplay/ui/ConfigurationGetter.py | 6 +- syncplay/ui/GuiConfiguration.py | 121 +++++++++++++++++++---------- 5 files changed, 94 insertions(+), 50 deletions(-) diff --git a/syncplay/client.py b/syncplay/client.py index c158eb0..e2851a6 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -204,7 +204,7 @@ class SyncplayClient(object): def _slowDownToCoverTimeDifference(self, diff, setBy): hideFromOSD = not constants.SHOW_SLOWDOWN_OSD - if(constants.SLOWDOWN_KICKIN_THRESHOLD < diff and not self._speedChanged): + if(self._config['slowdownThreshold'] < diff and not self._speedChanged): self._player.setSpeed(constants.SLOWDOWN_RATE) self._speedChanged = True self.ui.showMessage(getMessage("en", "slowdown-notification").format(setBy), hideFromOSD) @@ -226,7 +226,7 @@ class SyncplayClient(object): self._lastGlobalUpdate = time.time() if (doSeek): madeChangeOnPlayer = self._serverSeeked(position, setBy) - if (diff > constants.REWIND_THRESHOLD and not doSeek and not self._config['rewindOnDesync'] == False): + if (diff > self._config['rewindThreshold'] and not doSeek and not self._config['rewindThreshold'] == 0.0): madeChangeOnPlayer = self._rewindPlayerDueToTimeDifference(position, setBy) if (self._player.speedSupported and not doSeek and not paused): if (self._config['slowMeOnDesync'] == constants.OPTION_ALWAYS or (self._config['slowMeOnDesync'] == constants.OPTION_AUTO and self._player.speedRecommended)): diff --git a/syncplay/constants.py b/syncplay/constants.py index 87cb7c9..a2949b6 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -21,17 +21,16 @@ SHOW_BUTTON_LABELS = True # If disabled, only shows icons for main GUI buttons SHOW_TOOLTIPS = True #Changing these might be ok -REWIND_THRESHOLD = 4 +DEFAULT_REWIND_THRESHOLD = 4 SEEK_THRESHOLD = 1 SLOWDOWN_RATE = 0.95 -SLOWDOWN_KICKIN_THRESHOLD = 1.5 +DEFAULT_SLOWDOWN_KICKIN_THRESHOLD = 1.5 SLOWDOWN_RESET_THRESHOLD = 0.1 DIFFFERENT_DURATION_THRESHOLD = 2.5 PROTOCOL_TIMEOUT = 12.5 RECONNECT_RETRIES = 10 SERVER_STATE_INTERVAL = 1 WARNING_OSD_MESSAGES_LOOP_INTERVAL = 1 -SHOW_REWIND_ON_DESYNC_CHECKBOX = False MERGE_PLAYPAUSE_BUTTONS = False SYNC_ON_PAUSE = True # Client seek to global position - subtitles may disappear on some media players #Usually there's no need to adjust these diff --git a/syncplay/messages.py b/syncplay/messages.py index 7bfb61c..4a9cb80 100644 --- a/syncplay/messages.py +++ b/syncplay/messages.py @@ -118,6 +118,10 @@ en = { "browse-label" : "Browse", "more-title" : "Show more settings", + "slowdown-threshold-label" : "Slow down threshold:", + "rewind-threshold-label" : "Rewind threshold:", + "never-rewind-value" : "Never", + "seconds-suffix" : " secs", "privacy-sendraw-option" : "Send raw", "privacy-sendhashed-option" : "Send hashed", "privacy-dontsend-option" : "Don't send", @@ -129,7 +133,6 @@ en = { "slowdown-never-option" : "Never", "dontslowwithme-label" : "Never slow down or rewind others", "pauseonleave-label" : "Pause when user leaves", - "rewind-label" : "Rewind on major desync (highly recommended)", "alwayshow-label" : "Do not always show this dialog", "donotstore-label" : "Do not store this configuration", @@ -178,6 +181,8 @@ en = { "media-path-tooltip" : "Location of video or stream to be opened. Necessary for mpv and mplayer2.", "more-tooltip" : "Display less frequently used settings.", + "slowdown-threshold-tooltip" : "Time ahead of slowest client before temporarily reducing playback speed (default: {} secs).".format(constants.DEFAULT_SLOWDOWN_KICKIN_THRESHOLD), + "rewind-threshold-tooltip" : "Time ahead slowest client before seeking to get back in sync (default: {} secs). 'Never' can result in major desync!".format(constants.DEFAULT_REWIND_THRESHOLD), "filename-privacy-tooltip" : "Privacy mode for sending currently playing filename to server.", "filesize-privacy-tooltip" : "Privacy mode for sending size of currently playing file to server.", "privacy-sendraw-tooltip" : "Send this information without obfuscation. This is the default option with most functionality.", @@ -189,7 +194,6 @@ en = { "slowdown-never-tooltip" : "Never slow down on desync (even on players where this is probably better than rewinding).", "dontslowwithme-tooltip" : "Means others do not get slowed down or rewinded if your playback is lagging.", "pauseonleave-tooltip" : "Pause playback if you get disconnected or someone leaves from your room.", - "rewind-tooltip" : "Jump back when needed to get back in sync. Recommended.", "alwayshow-tooltip" : "Configuration dialogue is not shown when opening a file with Syncplay.", "donotstore-tooltip" : "Run Syncplay with the given configuration, but do not permanently store the changes.", diff --git a/syncplay/ui/ConfigurationGetter.py b/syncplay/ui/ConfigurationGetter.py index ffb20fd..b26d20f 100644 --- a/syncplay/ui/ConfigurationGetter.py +++ b/syncplay/ui/ConfigurationGetter.py @@ -33,9 +33,10 @@ class ConfigurationGetter(object): "file": None, "playerArgs": [], "playerClass": None, + "slowdownThreshold": constants.DEFAULT_SLOWDOWN_KICKIN_THRESHOLD, + "rewindThreshold": constants.DEFAULT_REWIND_THRESHOLD, "slowMeOnDesync": constants.OPTION_AUTO, "dontSlowDownWithMe": False, - "rewindOnDesync": True, "filenamePrivacyMode": constants.PRIVACY_SENDRAW_MODE, "filesizePrivacyMode": constants.PRIVACY_SENDRAW_MODE, "pauseOnLeave": False, @@ -60,13 +61,12 @@ class ConfigurationGetter(object): "noStore", "dontSlowDownWithMe", "pauseOnLeave", - "rewindOnDesync", "clearGUIData" ] self._iniStructure = { "server_data": ["host", "port", "password"], - "client_settings": ["name", "room", "playerPath", "slowMeOnDesync", "dontSlowDownWithMe", "rewindOnDesync", "forceGuiPrompt", "filenamePrivacyMode", "filesizePrivacyMode", "pauseOnLeave"], + "client_settings": ["name", "room", "playerPath", "slowdownThreshold", "rewindThreshold", "slowMeOnDesync", "dontSlowDownWithMe", "forceGuiPrompt", "filenamePrivacyMode", "filesizePrivacyMode", "pauseOnLeave"], } # diff --git a/syncplay/ui/GuiConfiguration.py b/syncplay/ui/GuiConfiguration.py index bd9741e..2bcd27a 100644 --- a/syncplay/ui/GuiConfiguration.py +++ b/syncplay/ui/GuiConfiguration.py @@ -1,6 +1,6 @@ from PySide import QtCore, QtGui from PySide.QtCore import QSettings, Qt, QCoreApplication -from PySide.QtGui import QApplication, QLineEdit, QCursor, QLabel, QCheckBox, QDesktopServices, QIcon, QImage, QButtonGroup, QRadioButton +from PySide.QtGui import QApplication, QLineEdit, QCursor, QLabel, QCheckBox, QDesktopServices, QIcon, QImage, QButtonGroup, QRadioButton, QDoubleSpinBox from syncplay.players.playerFactory import PlayerFactory import os @@ -206,12 +206,12 @@ class ConfigDialog(QtGui.QDialog): else: self.config['pauseOnLeave'] = False - - if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True: - if self.rewindCheckbox.isChecked() == True: - self.config['rewindOnDesync'] = True - else: - self.config['rewindOnDesync'] = False + if not self.slowdownThresholdSpinbox.text: + self.slowdownThresholdSpinbox.value = constants.DEFAULT_SLOWDOWN_KICKIN_THRESHOLD + if not self.rewindThresholdSpinbox.text: + self.rewindThresholdSpinbox.value = constants.DEFAULT_REWIND_THRESHOLD + self.config['slowdownThreshold'] = self.slowdownThresholdSpinbox.value() + self.config['rewindThreshold'] = self.rewindThresholdSpinbox.value() if self.filenameprivacySendRawOption.isChecked() == True: self.config['filenamePrivacyMode'] = constants.PRIVACY_SENDRAW_MODE @@ -347,9 +347,6 @@ class ConfigDialog(QtGui.QDialog): self.mediapathLabel.setToolTip(getMessage("en", "media-path-tooltip")) self.mediapathTextbox.setToolTip(getMessage("en", "media-path-tooltip")) - if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True: - self.rewindCheckbox = QCheckBox(getMessage("en", "rewind-label")) - self.rewindCheckbox.setToolTip(getMessage("en", "rewind-tooltip")) self.mediaplayerSettingsLayout = QtGui.QGridLayout() self.mediaplayerSettingsLayout.addWidget(self.executablepathLabel, 0, 0) self.mediaplayerSettingsLayout.addWidget(self.executableiconLabel, 0, 1) @@ -364,6 +361,49 @@ class ConfigDialog(QtGui.QDialog): self.moreSettingsGroup.setCheckable(True) + self.slowdownThresholdLabel = QLabel(getMessage("en", "slowdown-threshold-label"), self) + self.slowdownThresholdSpinbox = QDoubleSpinBox() + try: + self.slowdownThresholdSpinbox.setValue(float(config['slowdownThreshold'])) + except ValueError: + self.slowdownThresholdSpinbox.setValue(constants.DEFAULT_SLOWDOWN_KICKIN_THRESHOLD) + self.slowdownThresholdSpinbox.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) + self.slowdownThresholdSpinbox.setMinimumWidth(80) + self.slowdownThresholdSpinbox.setMaximumWidth(80) + self.slowdownThresholdSpinbox.setMinimum(0.1) + self.slowdownThresholdSpinbox.setSingleStep(0.1) + self.slowdownThresholdSpinbox.setSuffix(" secs") + self.slowdownThresholdSpinbox.adjustSize() + + self.rewindThresholdLabel = QLabel(getMessage("en", "rewind-threshold-label"), self) + self.rewindThresholdSpinbox = QDoubleSpinBox() + try: + self.rewindThresholdSpinbox.setValue(float(config['rewindThreshold'])) + except ValueError: + self.rewindThresholdSpinbox.setValue(constants.DEFAULT_REWIND_THRESHOLD) + self.rewindThresholdSpinbox.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) + self.rewindThresholdSpinbox.setMinimumWidth(80) + self.rewindThresholdSpinbox.setMaximumWidth(80) + self.rewindThresholdSpinbox.setMinimum(0) + self.rewindThresholdSpinbox.setSingleStep(0.1) + self.rewindThresholdSpinbox.setSpecialValueText(getMessage("en", "never-rewind-value")) + self.rewindThresholdSpinbox.setSuffix(getMessage("en", "seconds-suffix")) + self.rewindThresholdSpinbox.adjustSize() + + self.slowdownThresholdLabel.setToolTip(getMessage("en", "slowdown-threshold-tooltip")) + self.slowdownThresholdSpinbox.setToolTip(getMessage("en", "slowdown-threshold-tooltip")) + self.rewindThresholdLabel.setToolTip(getMessage("en", "rewind-threshold-tooltip")) + self.rewindThresholdSpinbox.setToolTip(getMessage("en", "rewind-threshold-tooltip")) + + self.slowdownLabel = QLabel(getMessage("en", "slowdown-label"), self) + self.slowdownButtonGroup = QButtonGroup() + self.slowdownAutoOption = QRadioButton(getMessage("en", "slowdown-auto-option")) + self.slowdownAlwaysOption = QRadioButton(getMessage("en", "slowdown-always-option")) + self.slowdownNeverOption = QRadioButton(getMessage("en", "slowdown-never-option")) + self.slowdownButtonGroup.addButton(self.slowdownAutoOption) + self.slowdownButtonGroup.addButton(self.slowdownAlwaysOption) + self.slowdownButtonGroup.addButton(self.slowdownNeverOption) + self.filenameprivacyLabel = QLabel(getMessage("en", "filename-privacy-label"), self) self.filenameprivacyButtonGroup = QButtonGroup() self.filenameprivacySendRawOption = QRadioButton(getMessage("en", "privacy-sendraw-option")) @@ -382,15 +422,6 @@ class ConfigDialog(QtGui.QDialog): self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacySendHashedOption) self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacyDontSendOption) - self.slowdownLabel = QLabel(getMessage("en", "slowdown-label"), self) - self.slowdownButtonGroup = QButtonGroup() - self.slowdownAutoOption = QRadioButton(getMessage("en", "slowdown-auto-option")) - self.slowdownAlwaysOption = QRadioButton(getMessage("en", "slowdown-always-option")) - self.slowdownNeverOption = QRadioButton(getMessage("en", "slowdown-never-option")) - self.slowdownButtonGroup.addButton(self.slowdownAutoOption) - self.slowdownButtonGroup.addButton(self.slowdownAlwaysOption) - self.slowdownButtonGroup.addButton(self.slowdownNeverOption) - self.dontslowwithmeCheckbox = QCheckBox(getMessage("en", "dontslowwithme-label")) self.pauseonleaveCheckbox = QCheckBox(getMessage("en", "pauseonleave-label")) self.alwaysshowCheckbox = QCheckBox(getMessage("en", "alwayshow-label")) @@ -412,8 +443,6 @@ class ConfigDialog(QtGui.QDialog): else: self.filesizeprivacySendRawOption.setChecked(True) - if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True and config['slowMeOnDesync'] == True: - self.rewindCheckbox.setChecked(True) if config['pauseOnLeave'] == True: self.pauseonleaveCheckbox.setChecked(True) @@ -448,34 +477,45 @@ class ConfigDialog(QtGui.QDialog): self.moreSettingsLayout = QtGui.QGridLayout() + self.thresholdSettingsLayout = QtGui.QGridLayout() + self.thresholdFrame = QtGui.QFrame() + self.thresholdFrame.setLineWidth(0) + self.thresholdFrame.setMidLineWidth(0) + self.thresholdSettingsLayout.setContentsMargins(0, 0, 0, 0) + self.thresholdSettingsLayout.addWidget(self.slowdownThresholdLabel, 0, 0, Qt.AlignLeft) + self.thresholdSettingsLayout.addWidget(self.slowdownThresholdSpinbox, 0, 1, Qt.AlignLeft) + self.thresholdSettingsLayout.addWidget(self.rewindThresholdLabel, 0, 2, Qt.AlignLeft) + self.thresholdSettingsLayout.addWidget(self.rewindThresholdSpinbox, 0, 3, Qt.AlignLeft) + self.thresholdFrame.setLayout(self.thresholdSettingsLayout) + self.moreSettingsLayout.addWidget(self.thresholdFrame, 0, 0, 1, 4, Qt.AlignLeft) + self.privacySettingsLayout = QtGui.QGridLayout() - self.privacyFrame = QtGui.QFrame() - self.privacyFrame.setLineWidth(0) - self.privacyFrame.setMidLineWidth(0) + self.radioFrame = QtGui.QFrame() + self.radioFrame.setLineWidth(0) + self.radioFrame.setMidLineWidth(0) self.privacySettingsLayout.setContentsMargins(0, 0, 0, 0) - self.privacySettingsLayout.addWidget(self.filenameprivacyLabel, 0, 0) - self.privacySettingsLayout.addWidget(self.filenameprivacySendRawOption, 0, 1, Qt.AlignLeft) - self.privacySettingsLayout.addWidget(self.filenameprivacySendHashedOption, 0, 2, Qt.AlignLeft) - self.privacySettingsLayout.addWidget(self.filenameprivacyDontSendOption, 0, 3, Qt.AlignLeft) - self.privacySettingsLayout.addWidget(self.filesizeprivacyLabel, 1, 0) - self.privacySettingsLayout.addWidget(self.filesizeprivacySendRawOption, 1, 1, Qt.AlignLeft) - self.privacySettingsLayout.addWidget(self.filesizeprivacySendHashedOption, 1, 2, Qt.AlignLeft) - self.privacySettingsLayout.addWidget(self.filesizeprivacyDontSendOption, 1, 3, Qt.AlignLeft) - self.privacySettingsLayout.addWidget(self.slowdownLabel, 2, 0) - self.privacySettingsLayout.addWidget(self.slowdownAutoOption, 2, 1, Qt.AlignLeft) - self.privacySettingsLayout.addWidget(self.slowdownAlwaysOption, 2, 2, Qt.AlignLeft) - self.privacySettingsLayout.addWidget(self.slowdownNeverOption, 2, 3, Qt.AlignLeft) - self.privacyFrame.setLayout(self.privacySettingsLayout) + self.privacySettingsLayout.addWidget(self.slowdownLabel, 0, 0) + self.privacySettingsLayout.addWidget(self.slowdownAutoOption, 0, 1, Qt.AlignLeft) + self.privacySettingsLayout.addWidget(self.slowdownAlwaysOption, 0, 2, Qt.AlignLeft) + self.privacySettingsLayout.addWidget(self.slowdownNeverOption, 0, 3, Qt.AlignLeft) + self.privacySettingsLayout.addWidget(self.filenameprivacyLabel, 1, 0) + self.privacySettingsLayout.addWidget(self.filenameprivacySendRawOption, 1, 1, Qt.AlignLeft) + self.privacySettingsLayout.addWidget(self.filenameprivacySendHashedOption, 1, 2, Qt.AlignLeft) + self.privacySettingsLayout.addWidget(self.filenameprivacyDontSendOption, 1, 3, Qt.AlignLeft) + self.privacySettingsLayout.addWidget(self.filesizeprivacyLabel, 2, 0) + self.privacySettingsLayout.addWidget(self.filesizeprivacySendRawOption, 2, 1, Qt.AlignLeft) + self.privacySettingsLayout.addWidget(self.filesizeprivacySendHashedOption, 2, 2, Qt.AlignLeft) + self.privacySettingsLayout.addWidget(self.filesizeprivacyDontSendOption, 2, 3, Qt.AlignLeft) + self.radioFrame.setLayout(self.privacySettingsLayout) - self.moreSettingsLayout.addWidget(self.privacyFrame, 0, 0, 1, 4) + self.moreSettingsLayout.addWidget(self.radioFrame, 1, 0, 1, 4) - if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True: - self.moreSettingsLayout.addWidget(self.rewindCheckbox, 3, 0, 1, 4) self.moreSettingsLayout.addWidget(self.dontslowwithmeCheckbox, 4, 0, 1, 2) self.moreSettingsLayout.addWidget(self.pauseonleaveCheckbox, 5, 0, 1, 2) self.moreSettingsLayout.addWidget(self.alwaysshowCheckbox, 4, 2, 1, 2) self.moreSettingsLayout.addWidget(self.donotstoreCheckbox, 5, 2, 1, 2) + self.moreSettingsGroup.setLayout(self.moreSettingsLayout) self.showmoreCheckbox = QCheckBox(getMessage("en", "more-title")) @@ -493,6 +533,7 @@ class ConfigDialog(QtGui.QDialog): self.showmoreCheckbox.setToolTip(getMessage("en", "more-tooltip")) + self.donotstoreCheckbox.toggled.connect(self.runButtonTextUpdate) self.mainLayout = QtGui.QVBoxLayout()