diff --git a/syncplay/client.py b/syncplay/client.py index 70d8577..8ef9d5e 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -194,7 +194,22 @@ class SyncplayClient(object): roomFilesDiffer = not self.userlist.areAllFilesInRoomSameOnFirstUnpause() if (paused == False and roomFilesDiffer): self.userlist.roomCheckedForDifferentFiles() - self._player.displayMessage(getMessage("en", "room-files-not-same"), constants.DIFFERENT_FILE_MESSAGE_DURATION) + self.ui.showMessage(getMessage("en", "room-files-not-same"), True) + self.__scheduleDifferentFilesWarningOSDDisplay() + + def __scheduleDifferentFilesWarningOSDDisplay(self): + self.__differentFileMessageTimer = task.LoopingCall(self.__displayDifferentFileMessageOnOSD) + self.__differentFileMessageDisplayedFor = 0 + self.__differentFileMessageTimer.start(constants.WARNING_OSD_MESSAGES_LOOP_INTERVAL, True) + + def __displayDifferentFileMessageOnOSD(self): + if (constants.DIFFERENT_FILE_MESSAGE_DURATION > self.__differentFileMessageDisplayedFor): + self._player.displayMessage(getMessage("en", "room-files-not-same")) + self.__differentFileMessageDisplayedFor += constants.WARNING_OSD_MESSAGES_LOOP_INTERVAL + else: + self.__differentFileMessageDisplayedFor = 0 + self.__differentFileMessageTimer.stop() + def _changePlayerStateAccordingToGlobalState(self, position, paused, doSeek, setBy): madeChangeOnPlayer = False diff --git a/syncplay/constants.py b/syncplay/constants.py index 75de6a2..2de4ab5 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -1,7 +1,7 @@ #You might want to change these DEFAULT_PORT = 8999 -OSD_DURATION = 3000 -DIFFERENT_FILE_MESSAGE_DURATION = 15000 +OSD_DURATION = 3 +DIFFERENT_FILE_MESSAGE_DURATION = 15 MPC_OSD_POSITION = 2 #Right corner, 1 for left MPLAYER_OSD_LEVEL = 1 UI_TIME_FORMAT = "[%X] " @@ -17,6 +17,7 @@ DIFFFERENT_DURATION_THRESHOLD = 1 PROTOCOL_TIMEOUT = 12.5 RECONNECT_RETRIES = 10 SERVER_STATE_INTERVAL = 1 +WARNING_OSD_MESSAGES_LOOP_INTERVAL = 1 #Usually there's no need to adjust these COMMANDS_UNDO = ["u", "undo", "revert"] diff --git a/syncplay/players/basePlayer.py b/syncplay/players/basePlayer.py index 7e3367c..c26dc6b 100644 --- a/syncplay/players/basePlayer.py +++ b/syncplay/players/basePlayer.py @@ -12,7 +12,7 @@ class BasePlayer(object): ''' Display given message on player's OSD or similar means ''' - def displayMessage(self, message, duration = constants.OSD_DURATION): + def displayMessage(self, message, duration = (constants.OSD_DURATION*1000)): raise NotImplementedError() ''' diff --git a/syncplay/players/mpc.py b/syncplay/players/mpc.py index eeacba7..d71aa63 100644 --- a/syncplay/players/mpc.py +++ b/syncplay/players/mpc.py @@ -78,7 +78,7 @@ class MpcHcApi: def setSpeed(self, rate): self.__listener.SendCommand(self.CMD_SETSPEED, unicode(rate)) - def sendOsd(self, message, MsgPos=constants.MPC_OSD_POSITION, DurationMs=constants.OSD_DURATION): + def sendOsd(self, message, MsgPos=constants.MPC_OSD_POSITION, DurationMs=(constants.OSD_DURATION*1000)): class __OSDDATASTRUCT(ctypes.Structure): _fields_ = [ ('nMsgPos', ctypes.c_int32), @@ -383,7 +383,7 @@ class MPCHCAPIPlayer(BasePlayer): if(filePath): self._mpcApi.openFile(filePath) - def displayMessage(self, message, duration = constants.OSD_DURATION): + def displayMessage(self, message, duration = (constants.OSD_DURATION*1000)): self._mpcApi.sendOsd(message, constants.MPC_OSD_POSITION, duration) @retry(MpcHcApi.PlayerNotReadyException, constants.MPC_MAX_RETRIES, constants.MPC_RETRY_WAIT_TIME, 1) diff --git a/syncplay/players/mplayer.py b/syncplay/players/mplayer.py index e91849b..e7b4240 100644 --- a/syncplay/players/mplayer.py +++ b/syncplay/players/mplayer.py @@ -74,7 +74,7 @@ class MplayerPlayer(BasePlayer): def _getProperty(self, property_): self._listener.sendLine("get_property {}".format(property_)) - def displayMessage(self, message, duration = constants.OSD_DURATION): + def displayMessage(self, message, duration = (constants.OSD_DURATION*1000)): self._listener.sendLine('osd_show_text "{!s}" {} {}'.format(message, duration, constants.MPLAYER_OSD_LEVEL)) def setSpeed(self, value):