From 2b1c2430a43005a2cc7e83bae248d598b4250bba Mon Sep 17 00:00:00 2001 From: Et0h Date: Tue, 7 Apr 2015 17:36:01 +0100 Subject: [PATCH] Output debug to stderr, give error if VLC latency > 2s, uprelease to 7 --- syncplay/__init__.py | 2 +- syncplay/client.py | 3 ++- syncplay/constants.py | 1 + syncplay/messages.py | 3 +++ syncplay/players/vlc.py | 2 ++ 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/syncplay/__init__.py b/syncplay/__init__.py index 324bd66..b2c90aa 100644 --- a/syncplay/__init__.py +++ b/syncplay/__init__.py @@ -1,4 +1,4 @@ version = '1.3.0' milestone = 'Chami' -release_number = '6' +release_number = '7' projectURL = 'http://syncplay.pl/' diff --git a/syncplay/client.py b/syncplay/client.py index 2e414f0..9aa5e5f 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -2,6 +2,7 @@ import hashlib import os.path import time import re +import sys from twisted.internet.protocol import ClientFactory from twisted.internet import reactor, task from functools import wraps @@ -1131,7 +1132,7 @@ class UiManager(object): def showDebugMessage(self, message): if constants.DEBUG_MODE and message.rstrip(): - print "{}{}".format(time.strftime(constants.UI_TIME_FORMAT, time.localtime()),message.rstrip()) + sys.stderr.write("{}{}\n".format(time.strftime(constants.UI_TIME_FORMAT, time.localtime()),message.rstrip())) def showMessage(self, message, noPlayer=False, noTimestamp=False, secondaryOSD=False): if not noPlayer: self.showOSDMessage(message, duration=constants.OSD_DURATION, secondaryOSD=secondaryOSD) diff --git a/syncplay/constants.py b/syncplay/constants.py index 9c1f097..dadbba7 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -64,6 +64,7 @@ COMMANDS_TOGGLE = ['t','toggle'] MPC_MIN_VER = "1.6.4" VLC_MIN_VERSION = "2.0.0" VLC_INTERFACE_MIN_VERSION = "0.2.5" +VLC_LATENCY_ERROR_THRESHOLD = 2.0 CONTROLLED_ROOMS_MIN_VERSION = "1.3.0" USER_READY_MIN_VERSION = "1.3.0" MPC_PATHS = [ diff --git a/syncplay/messages.py b/syncplay/messages.py index ad8d243..7f1fb1c 100755 --- a/syncplay/messages.py +++ b/syncplay/messages.py @@ -93,6 +93,7 @@ en = { "vlc-interface-version-mismatch": "Warning: You are running version {} of the Syncplay interface module for VLC, but Syncplay is designed to run with version {} and above.", # VLC interface version, VLC interface min version "vlc-interface-oldversion-ignored": "Warning: Syncplay detected that an old version version of the Syncplay interface module for VLC was installed in the VLC directory. As such, if you are running VLC 2.0 then it will be ignored in favour of the syncplay.lua module contained within the Syncplay directory, but this will mean that other custom interface scripts and extensions will not work. Please refer to the Syncplay User Guide at http://syncplay.pl/guide/ for instructions on how to install syncplay.lua.", "vlc-interface-not-installed": "Warning: The Syncplay interface module for VLC was not found in the VLC directory. As such, if you are running VLC 2.0 then VLC will use the syncplay.lua module contained within the Syncplay directory, but this will mean that other custom interface scripts and extensions will not work. Please refer to the Syncplay User Guide at http://syncplay.pl/guide/ for instructions on how to install syncplay.lua.", + "vlc-latency-error": u"Warning: VLC interface script took {} seconds to respond. If this happens regularly then you should move to a different media player!", # Seconds to respond # Client prompts "enter-to-exit-prompt" : "Press enter to exit\n", @@ -447,6 +448,7 @@ ru = { "vlc-interface-version-mismatch" : u"Внимание: В используете модуль интерфейса Syncplay устаревшей версии {} для VLC. К сожалению, Syncplay способен работать с версией {} и выше.", # VLC interface version, VLC interface min version "vlc-interface-oldversion-ignored" : u"Внимание: Syncplay обнаружил, что старая версия модуля интерфейса Syncplay для VLC уже установлена в директорию VLC. По существу, если Вы используете VLC 2.0, то предпочтение будет отдано файлу syncplay.lua, содержащемуся в директории Syncplay, но в таком случае другие пользовательские скрипты и расширения интерфейса не будут работать. Пожалуйста, обратитесь к Руководству Пользователя Syncplay (http://syncplay.pl/guide/) за инструкциями о том, как установить syncplay.lua.", "vlc-interface-not-installed" : u"Внимание: Модуль интерфейса Syncplay для VLC не обнаружен в директории VLC. По существу, если Вы используете VLC 2.0, то VLC будет использовать модуль syncplay.lua из директории Syncplay, но в таком случае другие пользовательские скрипты и расширения интерфейса не будут работать. Пожалуйста, обратитесь к Руководству Пользователя Syncplay (http://syncplay.pl/guide/) за инструкциями о том, как установить syncplay.lua.", + "vlc-latency-error": u"Warning: VLC interface script took {} seconds to respond. If this happens regularly then you should move to a different media player!", # Seconds to respond # TODO: Translate into Russian # Client prompts "enter-to-exit-prompt" : u"Для выхода нажмите Enter\n", @@ -801,6 +803,7 @@ de = { "vlc-interface-version-mismatch": u"Warnung: Du nutzt Version {} des VLC-Syncplay Interface-Moduls, Syncplay benötigt aber mindestens Version {}.", # VLC interface version, VLC interface min version "vlc-interface-oldversion-ignored": u"Warnung: Es ist eine alte Version des Syncplay Interface-Moduls für VLC im VLC-Verzeichnis installiert. Daher wird, wenn du VLC 2.0 nutzt, die syncplay.lua die mit Syncplay mitgeliefert wurde, verwendet. Dies bedeutet allerdings, dass keine anderen Interface-Skripts und Erweiterungen geladen werden. In der Syncplay-Anleitung unter http://syncplay.pl/guide/ [Englisch] findest du Details zur Installation des syncplay.lua-Skripts.", "vlc-interface-not-installed": u"Warnung: Es wurde kein Syncplay Interface-Modul für VLC im VLC-Verzeichnis gefunden. Daher wird, wenn du VLC 2.0 nutzt, die syncplay.lua die mit Syncplay mitgeliefert wurde, verwendet. Dies bedeutet allerdings, dass keine anderen Interface-Skripts und Erweiterungen geladen werden. In der Syncplay-Anleitung unter http://syncplay.pl/guide/ [Englisch] findest du Details zur Installation des syncplay.lua-Skripts.", + "vlc-latency-error": u"Warning: VLC interface script took {} seconds to respond. If this happens regularly then you should move to a different media player!", # Seconds to respond # TODO: Translate into German # Client prompts "enter-to-exit-prompt" : u"Enter drücken zum Beenden\n", diff --git a/syncplay/players/vlc.py b/syncplay/players/vlc.py index fdc5b56..a0e0493 100644 --- a/syncplay/players/vlc.py +++ b/syncplay/players/vlc.py @@ -100,6 +100,8 @@ class VlcPlayer(BasePlayer): diff = time.time() - self._lastVLCPositionUpdate if diff > constants.PLAYER_ASK_DELAY and not self._paused: self._client.ui.showDebugMessage("VLC did not response in time, so assuming position is {} ({}+{})".format(self._position + diff, self._position, diff)) + if diff > constants.VLC_LATENCY_ERROR_THRESHOLD: + self._client.ui.showErrorMessage(getMessage("vlc-latency-error").format(int(diff))) return self._position + diff else: return self._position