From fe6873d58b27844f6f6ce58944509bae8716f1d5 Mon Sep 17 00:00:00 2001 From: alby128 Date: Wed, 1 Nov 2017 18:20:43 +0100 Subject: [PATCH] Fixed unpause bug when VLC reaches EOF --- syncplay/constants.py | 2 ++ syncplay/players/vlc.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) mode change 100644 => 100755 syncplay/players/vlc.py diff --git a/syncplay/constants.py b/syncplay/constants.py index 81bee71..41834a0 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -193,6 +193,8 @@ UNPAUSE_IFOTHERSREADY_MODE = "IfOthersReady" UNPAUSE_IFMINUSERSREADY_MODE = "IfMinUsersReady" UNPAUSE_ALWAYS_MODE = "Always" +VLC_EOF_DURATION_THRESHOLD = 2.0 + PRIVACY_HIDDENFILENAME = "**Hidden filename**" INVERTED_STATE_MARKER = "*" ERROR_MESSAGE_MARKER = "*" diff --git a/syncplay/players/vlc.py b/syncplay/players/vlc.py old mode 100644 new mode 100755 index c1228a0..dde4d5b --- a/syncplay/players/vlc.py +++ b/syncplay/players/vlc.py @@ -208,18 +208,22 @@ class VlcPlayer(BasePlayer): self._durationAsk.set() elif name == "playstate": self._paused = bool(value != 'playing') if(value != "no-input" and self._filechanged == False) else self._client.getGlobalPaused() + diff = time.time() - self._lastVLCPositionUpdate if self._lastVLCPositionUpdate else 0 if self._paused == False \ and self._position == self._previousPreviousPosition \ and self._previousPosition == self._position \ and self._duration > constants.PLAYLIST_LOAD_NEXT_FILE_MINIMUM_LENGTH \ - and self._position == self._duration: - self._paused = True + and (self._duration - self._position) < constants.VLC_EOF_DURATION_THRESHOLD \ + and diff > constants.VLC_LATENCY_ERROR_THRESHOLD: self._client.ui.showDebugMessage("Treating 'playing' response as 'paused' due to VLC EOF bug") + self.setPaused(True) self._pausedAsk.set() elif name == "position": newPosition = float(value.replace(",", ".")) if (value != "no-input" and self._filechanged == False) else self._client.getGlobalPosition() if newPosition == self._previousPosition and newPosition <> self._duration and not self._paused: self._client.ui.showDebugMessage("Not considering position {} duplicate as new time because of VLC time precision bug".format(newPosition)) + self._previousPreviousPosition = self._previousPosition + self._previousPosition = self._position self._positionAsk.set() return self._previousPreviousPosition = self._previousPosition