All constants are now seconds (instead of miliseconds);

Redone message displaying about not all files being the same in the room
This commit is contained in:
Uriziel 2013-01-13 16:39:58 +01:00
parent 0a99e98956
commit c91ff941fa
5 changed files with 23 additions and 7 deletions

View File

@ -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

View File

@ -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"]

View File

@ -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()
'''

View File

@ -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)

View File

@ -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):