diff --git a/syncplay/constants.py b/syncplay/constants.py index 62c1eca..a84f9fc 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -157,6 +157,8 @@ MPV_NEW_VERSION = False VLC_SLAVE_ARGS = ['--extraintf=luaintf', '--lua-intf=syncplay', '--no-quiet', '--no-input-fast-seek', '--play-and-pause', '--start-time=0'] VLC_SLAVE_NONOSX_ARGS = ['--no-one-instance', '--no-one-instance-when-started-from-file'] +MPV_SUPERSEDE_IF_DUPLICATE_COMMANDS = ["no-osd set time-pos ", "loadfile "] +MPV_REMOVE_BOTH_IF_DUPLICATE_COMMANDS = ["cycle pause"] MPLAYER_ANSWER_REGEX = "^ANS_([a-zA-Z_-]+)=(.+)$|^(Exiting)\.\.\. \((.+)\)$" VLC_ANSWER_REGEX = r"(?:^(?P[a-zA-Z_]+)(?:\: )?(?P.*))" UI_COMMAND_REGEX = r"^(?P[^\ ]+)(?:\ (?P.+))?" diff --git a/syncplay/players/mplayer.py b/syncplay/players/mplayer.py index 5cf9bd5..929f1dd 100644 --- a/syncplay/players/mplayer.py +++ b/syncplay/players/mplayer.py @@ -350,6 +350,27 @@ class MplayerPlayer(BasePlayer): if self.readyToSend == False and "print_text ANS_pause" in line: self.__playerController._client.ui.showDebugMessage(" Not ready to get status update, so skipping") return + try: + if self.sendQueue: + if constants.MPV_SUPERSEDE_IF_DUPLICATE_COMMANDS: + for command in constants.MPV_SUPERSEDE_IF_DUPLICATE_COMMANDS: + if line.startswith(command): + for itemID, deletionCandidate in enumerate(self.sendQueue): + if deletionCandidate.startswith(command): + self.__playerController._client.ui.showDebugMessage(u" Remove duplicate (supersede): {}".format(self.sendQueue[itemID])) + self.sendQueue.remove(self.sendQueue[itemID]) + break + break + if constants.MPV_REMOVE_BOTH_IF_DUPLICATE_COMMANDS: + for command in constants.MPV_REMOVE_BOTH_IF_DUPLICATE_COMMANDS: + if line == command: + for itemID, deletionCandidate in enumerate(self.sendQueue): + if deletionCandidate == command: + self.__playerController._client.ui.showDebugMessage(u" Remove duplicate (delete both): {}".format(self.sendQueue[itemID])) + self.__playerController._client.ui.showDebugMessage(self.sendQueue[itemID]) + return + except: + self.__playerController._client.ui.showDebugMessage(" Problem removing duplicates, etc") self.sendQueue.append(line) self.processSendQueue() if notReadyAfterThis: