From c1d09490bf6b6c50e0622128dc62dfd3fb6cc80f Mon Sep 17 00:00:00 2001 From: Uriziel Date: Thu, 27 Dec 2012 20:41:22 +0100 Subject: [PATCH 1/8] Little message update --- syncplay/ui/consoleUI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syncplay/ui/consoleUI.py b/syncplay/ui/consoleUI.py index 60e9de7..e987b21 100644 --- a/syncplay/ui/consoleUI.py +++ b/syncplay/ui/consoleUI.py @@ -115,7 +115,7 @@ class ConsoleUI(threading.Thread): self.showMessage("\tl - show user list", True) self.showMessage("\tu - undo last seek", True) self.showMessage("\tp - toggle pause", True) - self.showMessage("\t[s][+-][time] - seek to the given value of time, if + or - is not specified it's absolute time in seconds or min:sec", True) + self.showMessage("\t[s][+-]time - seek to the given value of time, if + or - is not specified it's absolute time in seconds or min:sec", True) self.showMessage("\th - this help", True) self.showMessage("Syncplay version: {}".format(syncplay.version), True) self.showMessage("More info available at: {}".format(syncplay.projectURL), True) From baf94036451e1d356854cce9c54ec82e141ffb27 Mon Sep 17 00:00:00 2001 From: Etoh Date: Fri, 28 Dec 2012 12:45:03 +0000 Subject: [PATCH 2/8] Update README.md - Improved Windows instructions --- README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a38966c..fc9a35d 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Syncplay does not use video streaming or file sharing so each user must have the ## Requirements Frozen Windows executables are available on the download page - https://github.com/Uriziel/syncplay/downloads -* On Windows: `Media Player Classic - Home Cinema (MPC-HC)` >= `1.6.4`. +* On Windows: `Media Player Classic - Home Cinema (MPC-HC)` >= `1.6.4` or `mplayer2`. * On Linux: `mplayer2`. `MPlayer` >= `1.1` should be compatible, but is not supported. ### Python scripts (for those not using the frozen executable package) @@ -33,9 +33,9 @@ If you are not using the frozen executable package then you will need the follow If you are using the frozen executable package available from the download page then you will not need to be able to run Python scripts. ## Supported players -### mplayer2 on Linux +### mplayer2 on Linux and Windows -On Linux `syncplay` acts as a front-end for mplayer2. +On Linux and Windows `syncplay` acts as a front-end for mplayer2. To use it select "Open with..." in context menu and choose `Syncplay` or from command line: "syncplay video_filename". If you wish to pass more arguments to mplayer2 prepend them with -- argument, it's treated as the last argument for wrapper. Default mplayer2 output is suppressed, but if mplayer2 quits with errors, those errors will be printed (at most 50 last lines). @@ -48,19 +48,17 @@ On Windows simply running `syncplayClient.exe` opens a Syncplay command-line win ### Getting started with Syncplay on Windows -1. Ensure that you have the latest version of `Media Player Classic - Home Cinema (MPC-HC)` installed. The latest stable build is `1.6.4`. +1. Ensure that you have the latest version of `Media Player Classic - Home Cinema (MPC-HC)` and/or `mplayer2` installed. The latest stable build of MPC-HC is `1.6.4`. -2. Download Syncplay frozen executable package from https://github.com/Uriziel/syncplay/downloads and extract to a folder of your choosing. +2. Download Syncplay frozen executable package from the link provided in the topic of the #syncplay channel on irc.rizon.net and extract to a folder of your choosing. 3. If you are running your own server then open `syncplayServer.exe` (see "How to use the server", below). -4. Open `syncplayClient.exe` (or open the media file you wish to play with `syncplayClient.exe`, e.g. using "Open with"). +4. Open the media file you wish to play with `syncplayClient.exe` (e.g. using "Open with"). If you are using `MPC-HC`, you can alternatively open `syncplayClient.exe` directly and then load the file later. 5. Enter configuration settings (see "Configuration window", below). Ensure that you are on the same server and room as your fellow viewers. -6. If you don't have the file you want to play open then open it from within the MPC-HC instance initiated by Syncplay. - -7. Playing, pausing and seeking from within the MPC-HC instance should now be synchronised with everyone else in the same 'room'. +6. Playing, pausing and seeking from within the media player instance should now be synchronised with everyone else in the same 'room'. ### Getting started with Syncplay on Linux From 5824b810d40dce7c9b4dfdd6395b9e72961c55f8 Mon Sep 17 00:00:00 2001 From: Etoh Date: Fri, 28 Dec 2012 12:51:55 +0000 Subject: [PATCH 3/8] Update README.md - Warning re: playback rate --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fc9a35d..feeb6ad 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ You can run `syncplayClient` with the following command-line switches to alter S ### Notification messages -* `Rewinded due to time difference with [user]` - This means that your media player ended up too far in front of the specified user and has jumped back to keep you in sync. This is usually because someone's computer isn't powerful enough to play the file smoothly. If someone is only a small amount in front then their playback rate will be reduced to 95% for a short amount of time to bring them back into sync. +* `Rewinded due to time difference with [user]` - This means that your media player ended up too far in front of the specified user and has jumped back to keep you in sync. This is usually because someone's computer isn't powerful enough to play the file smoothly. If someone is only a small amount in front then their playback rate will be reduced to 95% for a short amount of time to bring them back into sync. * `File you are playing appears to be different from [user]'s` - This means that the filename, size and/or duration of the file that the user is playing is different from the file that you are playing. This is for information only and is not an error. * `[User] has left` - This means that the user is no longer connected to the server. If room isolation is enabled on the server then this could also mean that the user moved to a different room. @@ -169,6 +169,7 @@ You might also be able to discuss your problem through Internet Relay Chat (IRC) 1. Changing your system time while Syncplay is running confuses the sync. PROTIP: Don't do it. 2. In MPC-HC the 'Remember File position' feature will not work as expected if you are using Syncplay. If you want to save/load the file position when using Syncplay then use MPC-HC's built in Favorites feature. 3. Connecting to port 8999 is disallowed in some firewall configurations. Check your firewall settings if you are experiencing problems connecting to a server. +4. Manually setting the playback rate may cause problems. Syncplay generally assumes a playback rate of 1.0 and in some instances sets the playback rate to help get everyone more in sync. ## Authors * *Concept and principal Syncplay developer* - Uriziel. From 8059bdf5ca2ad2d34e6afbed87450967bcef90e6 Mon Sep 17 00:00:00 2001 From: Etoh Date: Fri, 28 Dec 2012 12:59:26 +0000 Subject: [PATCH 4/8] Update README.md - Improve slow down notify info --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index feeb6ad..0f32800 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,9 @@ You can run `syncplayClient` with the following command-line switches to alter S ### Notification messages -* `Rewinded due to time difference with [user]` - This means that your media player ended up too far in front of the specified user and has jumped back to keep you in sync. This is usually because someone's computer isn't powerful enough to play the file smoothly. If someone is only a small amount in front then their playback rate will be reduced to 95% for a short amount of time to bring them back into sync. +* `Rewinded due to time difference with [user]` - This means that your media player ended up too far in front of the specified user and has jumped back to help keep you in sync. This is usually because someone's computer isn't powerful enough to play the file smoothly - it might be helpful for them to close unnecessary applications. +* `Slowing down due to time difference with [user]` - This means that your media player ended up too far in front of the specified user and has temporarily slowed down playback on your player to help keep you in sync. This is usually because someone's computer isn't powerful enough to play the file smoothly - it might be helpful for them to close unnecessary applications. +* `Reverting speed back to normal` - Slowing down due to time difference with user has ended (see above). * `File you are playing appears to be different from [user]'s` - This means that the filename, size and/or duration of the file that the user is playing is different from the file that you are playing. This is for information only and is not an error. * `[User] has left` - This means that the user is no longer connected to the server. If room isolation is enabled on the server then this could also mean that the user moved to a different room. From cf3f82e8293efcca85ab372e9e78e8fae5cceb63 Mon Sep 17 00:00:00 2001 From: Uriziel Date: Sat, 29 Dec 2012 12:05:30 +0100 Subject: [PATCH 5/8] Messages file for future use --- syncplay/messages.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 syncplay/messages.py diff --git a/syncplay/messages.py b/syncplay/messages.py new file mode 100644 index 0000000..5eebe31 --- /dev/null +++ b/syncplay/messages.py @@ -0,0 +1,7 @@ +en = { + "connecting" : "Attempting to connect to {}:{}" + } + +messages = { + "en": en + } \ No newline at end of file From e2f08b6df74deb7958044b391bae79cd02aa62d6 Mon Sep 17 00:00:00 2001 From: Uriziel Date: Sat, 29 Dec 2012 12:10:14 +0100 Subject: [PATCH 6/8] New method for getting messages --- syncplay/messages.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/syncplay/messages.py b/syncplay/messages.py index 5eebe31..a674c5a 100644 --- a/syncplay/messages.py +++ b/syncplay/messages.py @@ -4,4 +4,13 @@ en = { messages = { "en": en - } \ No newline at end of file + } + +def getMessage(locale, type_): + if(messages.has_key(locale)): + if(messages[locale].has_key(type_)): + return messages[locale][type_] + elif(messages["en"].has_key(type_)): + return messages["en"][type_] + else: + raise KeyError() \ No newline at end of file From 9d8c084fe5ddbcca78f6a60959b0f251307a7026 Mon Sep 17 00:00:00 2001 From: Uriziel Date: Sat, 29 Dec 2012 12:22:46 +0100 Subject: [PATCH 7/8] Message lookup fallback will work if locale was not found as well --- syncplay/messages.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syncplay/messages.py b/syncplay/messages.py index a674c5a..75e5efe 100644 --- a/syncplay/messages.py +++ b/syncplay/messages.py @@ -10,7 +10,7 @@ def getMessage(locale, type_): if(messages.has_key(locale)): if(messages[locale].has_key(type_)): return messages[locale][type_] - elif(messages["en"].has_key(type_)): - return messages["en"][type_] + if(messages["en"].has_key(type_)): + return messages["en"][type_] else: raise KeyError() \ No newline at end of file From 224c2667d5d51f130ab0c45157228ebc87209d24 Mon Sep 17 00:00:00 2001 From: Uriziel Date: Sat, 29 Dec 2012 12:37:54 +0100 Subject: [PATCH 8/8] All consatnts exported to separate file --- syncplay/client.py | 20 +++++++------- syncplay/constants.py | 43 ++++++++++++++++++++++++++++++ syncplay/players/mpc.py | 31 +++++++++------------ syncplay/players/mplayer.py | 8 +++--- syncplay/server.py | 7 ++--- syncplay/ui/ConfigurationGetter.py | 5 ++-- syncplay/ui/GuiConfiguration.py | 14 ++-------- syncplay/ui/consoleUI.py | 20 +++++++------- syncplay/utils.py | 3 ++- 9 files changed, 92 insertions(+), 59 deletions(-) create mode 100644 syncplay/constants.py diff --git a/syncplay/client.py b/syncplay/client.py index 613b716..04bd22f 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -5,10 +5,10 @@ import time from twisted.internet.protocol import ClientFactory from twisted.internet import reactor, task from syncplay.protocols import SyncClientProtocol -from syncplay import utils +from syncplay import utils, constants class SyncClientFactory(ClientFactory): - def __init__(self, client, retry = 10): + def __init__(self, client, retry = constants.RECONNECT_RETRIES): self._client = client self.retry = retry self._timesTried = 0 @@ -53,7 +53,7 @@ class SyncplayClient(object): self.userlist = SyncplayUserlist(self.ui, self) self._protocol = None if(args.room == None or args.room == ''): - args.room = 'default' + args.room = constants.DEFAULT_ROOM self.defaultRoom = args.room self.playerPositionBeforeLastSeek = 0.0 self.setUsername(args.name) @@ -94,7 +94,7 @@ class SyncplayClient(object): self._player = player self.scheduleAskPlayer() - def scheduleAskPlayer(self, when=0.1): + def scheduleAskPlayer(self, when=constants.PLAYER_ASK_DELAY): self._askPlayerTimer = task.LoopingCall(self.askPlayer) self._askPlayerTimer.start(when) @@ -106,7 +106,7 @@ class SyncplayClient(object): self.checkIfConnected() def checkIfConnected(self): - if(self._lastGlobalUpdate and self._protocol and time.time() - self._lastGlobalUpdate > 4.1): + if(self._lastGlobalUpdate and self._protocol and time.time() - self._lastGlobalUpdate > constants.PROTOCOL_TIMEOUT): self._lastGlobalUpdate = None self.ui.showErrorMessage("Connection with server timed out") self._protocol.drop() @@ -117,7 +117,7 @@ class SyncplayClient(object): pauseChange = self.getPlayerPaused() != paused and self.getGlobalPaused() != paused _playerDiff = abs(self.getPlayerPosition() - position) _globalDiff = abs(self.getGlobalPosition() - position) - seeked = _playerDiff > 1 and _globalDiff > 1 + seeked = _playerDiff > constants.SEEK_BOUNDARY and _globalDiff > constants.SEEK_BOUNDARY return pauseChange, seeked def updatePlayerStatus(self, paused, position): @@ -182,12 +182,12 @@ class SyncplayClient(object): return madeChangeOnPlayer def _slowDownToCoverTimeDifference(self, diff, setBy): - if(1.5 < diff and not self._speedChanged): - self._player.setSpeed(0.95) + if(constants.SLOWDOWN_KICKIN_BOUNDARY < diff and not self._speedChanged): + self._player.setSpeed(constants.SLOWDOWN_RATE) self._speedChanged = True message = "Slowing down due to time difference with <{}>".format(setBy) self.ui.showMessage(message) - elif(self._speedChanged and diff < 0.1 ): + elif(self._speedChanged and diff < constants.SLOWDOWN_RESET_BOUNDARY): self._player.setSpeed(1.00) self._speedChanged = False message = "Reverting speed back to normal" @@ -363,7 +363,7 @@ class SyncplayUser(object): return False sameName = self.file['name'] == file_['name'] sameSize = self.file['size'] == file_['size'] - sameDuration = int(self.file['duration']) - int(file_['duration']) < 1 + sameDuration = int(self.file['duration']) - int(file_['duration']) < constants.DIFFFERENT_DURATION_BOUNDARY return sameName and sameSize and sameDuration def __lt__(self, other): diff --git a/syncplay/constants.py b/syncplay/constants.py new file mode 100644 index 0000000..5efcd3c --- /dev/null +++ b/syncplay/constants.py @@ -0,0 +1,43 @@ +DEFAULT_PORT = 8999 +MPC_OPEN_MAX_WAIT_TIME = 10 +MPC_LOCK_WAIT_TIME = 0.2 +OSD_DURATION = 3000 +MPC_OSD_POSITION = 2 #Right corner, 1 for left +MPC_RETRY_WAIT_TIME = 0.01 +MPC_MAX_RETRIES = 30 +MPC_PAUSE_TOGGLE_DELAY = 0.05 +MPLAYER_OSD_LEVEL = 1 +MPLAYER_ANSWER_REGEX = "^ANS_([a-zA-Z_]+)=(.+)$" +MPLAYER_SLAVE_ARGS = [ '-slave', '-msglevel', 'all=1:global=4'] +UI_COMMAND_REGEX = r"^(?P[^\ ]+)(?:\ (?P.+))?" +UI_OFFSET_REGEX = r"^(?:o|offset)\ ?(?P[/+-])?(?P