Handle mpv unresponsiveness by estimating position then critical error
This commit is contained in:
parent
2b555134d1
commit
04054c3078
@ -1,4 +1,4 @@
|
||||
version = '1.3.4'
|
||||
milestone = 'Chami'
|
||||
release_number = '20'
|
||||
release_number = '21'
|
||||
projectURL = 'http://syncplay.pl/'
|
||||
|
||||
@ -71,6 +71,7 @@ MPC_MIN_VER = "1.6.4"
|
||||
VLC_MIN_VERSION = "2.2.1"
|
||||
VLC_INTERFACE_MIN_VERSION = "0.2.8"
|
||||
VLC_LATENCY_ERROR_THRESHOLD = 2.0
|
||||
MPV_UNRESPONSIVE_THRESHOLD = 60.0
|
||||
CONTROLLED_ROOMS_MIN_VERSION = "1.3.0"
|
||||
USER_READY_MIN_VERSION = "1.3.0"
|
||||
MPC_PATHS = [
|
||||
|
||||
@ -94,6 +94,7 @@ en = {
|
||||
"vlc-interface-oldversion-warning": "Warning: Syncplay detected that an old version version of the Syncplay interface module for VLC was installed in the VLC directory. 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.",
|
||||
"media-player-latency-warning": u"Warning: The media player took {} seconds to respond. If you experience syncing issues then close applications to free up system resources, and if that doesn't work then try a different media player.", # Seconds to respond
|
||||
"mpv-unresponsive-error": u"mpv has not responded for {} seconds so appears to have malfunctioned. Please restart Syncplay.", # Seconds to respond
|
||||
|
||||
# Client prompts
|
||||
"enter-to-exit-prompt" : "Press enter to exit\n",
|
||||
@ -463,6 +464,7 @@ ru = {
|
||||
"vlc-interface-oldversion-warning" : u"Внимание: Syncplay обнаружил, что старая версия модуля интерфейса Syncplay для VLC уже установлена в директорию VLC. Пожалуйста, обратитесь к Руководству Пользователя 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.",
|
||||
"media-player-latency-warning": u"Внимание: У Вашего проигрывателя слишком большой отклик ({} секунд). Если Вы замечаете проблемы с синхронизацией, то закройте ресурсоемкие приложения, а если это не помогло - попробуйте другой проигрыватель.", # Seconds to respond
|
||||
"mpv-unresponsive-error": u"mpv has not responded for {} seconds so appears to have malfunctioned. Please restart Syncplay.", # Seconds to respond # TODO: Translate to Russian
|
||||
|
||||
# Client prompts
|
||||
"enter-to-exit-prompt" : u"Для выхода нажмите Enter\n",
|
||||
@ -832,6 +834,7 @@ de = {
|
||||
"vlc-interface-oldversion-warning": u"Warnung: Es ist eine alte Version des Syncplay Interface-Moduls für VLC im VLC-Verzeichnis installiert. 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.",
|
||||
"media-player-latency-warning": u"Warnung: Der Mediaplayer brauchte {} Sekunden zum Antworten. Wenn Probleme bei der Synchronisation auftreten, schließe bitte andere Anwendungen, um Ressourcen freizugeben. Sollte das nicht funktionieren, versuche es mit einem anderen Media-Player.", # Seconds to respond
|
||||
"mpv-unresponsive-error": u"mpv has not responded for {} seconds so appears to have malfunctioned. Please restart Syncplay.", # Seconds to respond # TODO: Translate to German
|
||||
|
||||
# Client prompts
|
||||
"enter-to-exit-prompt" : u"Enter drücken zum Beenden\n",
|
||||
|
||||
@ -106,6 +106,14 @@ class OldMpvPlayer(MpvPlayer):
|
||||
|
||||
class NewMpvPlayer(OldMpvPlayer):
|
||||
lastResetTime = None
|
||||
lastMPVPositionUpdate = None
|
||||
|
||||
def setPaused(self, value):
|
||||
if self._paused <> value:
|
||||
self._paused = not self._paused
|
||||
self._listener.sendLine('cycle pause')
|
||||
if value == False:
|
||||
self.lastMPVPositionUpdate = time.time()
|
||||
|
||||
def _getProperty(self, property_):
|
||||
floatProperties = ['length','time-pos']
|
||||
@ -115,7 +123,21 @@ class NewMpvPlayer(OldMpvPlayer):
|
||||
propertyID = property_
|
||||
self._listener.sendLine(u"print_text ""ANS_{}=${{{}}}""".format(property_, propertyID))
|
||||
|
||||
def getCalculatedPosition(self):
|
||||
if self.lastMPVPositionUpdate is None:
|
||||
return self._client.getGlobalPosition()
|
||||
diff = time.time() - self.lastMPVPositionUpdate
|
||||
if diff > constants.MPV_UNRESPONSIVE_THRESHOLD:
|
||||
self.reactor.callFromThread(self._client.ui.showErrorMessage, getMessage("mpv-unresponsive-error").format(int(diff)), True)
|
||||
self.drop()
|
||||
if diff > constants.PLAYER_ASK_DELAY and not self._paused:
|
||||
self._client.ui.showDebugMessage("mpv did not response in time, so assuming position is {} ({}+{})".format(self._position + diff, self._position, diff))
|
||||
return self._position + diff
|
||||
else:
|
||||
return self._position
|
||||
|
||||
def _storePosition(self, value):
|
||||
self.lastMPVPositionUpdate = time.time()
|
||||
if self._recentlyReset():
|
||||
self._position = 0
|
||||
elif self._fileIsLoaded():
|
||||
@ -136,7 +158,7 @@ class NewMpvPlayer(OldMpvPlayer):
|
||||
self._getPosition()
|
||||
self._positionAsk.wait(constants.MPV_LOCK_WAIT_TIME)
|
||||
self._pausedAsk.wait(constants.MPV_LOCK_WAIT_TIME)
|
||||
self._client.updatePlayerStatus(self._paused, self._position)
|
||||
self._client.updatePlayerStatus(self._paused, self.getCalculatedPosition())
|
||||
|
||||
def _preparePlayer(self):
|
||||
if self.delayedFilePath:
|
||||
@ -152,6 +174,10 @@ class NewMpvPlayer(OldMpvPlayer):
|
||||
self._clearFileLoaded()
|
||||
self._listener.sendLine(u'loadfile {}'.format(self._quoteArg(filePath)))
|
||||
|
||||
def setPosition(self, value):
|
||||
super(self.__class__, self).setPosition(value)
|
||||
self.lastMPVPositionUpdate = time.time()
|
||||
|
||||
def openFile(self, filePath, resetPosition=False):
|
||||
if resetPosition:
|
||||
self.lastResetTime = time.time()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user