Revert "Merge branch 'player-cookie' of https://github.com/tari/syncplay into sharedplaylists"
This reverts commit 509dfea336e48f7ccd848e44ebe8bb60e6332822, reversing changes made to 5ce752cbef589ade76ae5dc1bcfafc7c9e34c0ea.
This commit is contained in:
parent
c40b9e5aff
commit
5a36a2416a
@ -112,8 +112,6 @@ class SyncplayClient(object):
|
||||
self.autoPlay = False
|
||||
self.autoPlayThreshold = None
|
||||
|
||||
self._lastPlayerCommand = time.time()
|
||||
|
||||
self.autoplayTimer = task.LoopingCall(self.autoplayCountdown)
|
||||
self.autoplayTimeLeft = constants.AUTOPLAY_DELAY
|
||||
|
||||
@ -153,16 +151,6 @@ class SyncplayClient(object):
|
||||
def playerIsNotReady(self):
|
||||
return self._player is None
|
||||
|
||||
def _playerRequest(self, f, *args, **kwargs):
|
||||
"""Send a request with cookie to the player."""
|
||||
kwargs['cookie'] = time.time()
|
||||
f(*args, **kwargs)
|
||||
|
||||
def _playerCommand(self, f, *args, **kwargs):
|
||||
"""Send a command to the player, affecting cookie freshness."""
|
||||
self._lastPlayerCommand = time.time()
|
||||
f(*args, **kwargs)
|
||||
|
||||
def scheduleAskPlayer(self, when=constants.PLAYER_ASK_DELAY):
|
||||
self._askPlayerTimer = task.LoopingCall(self.askPlayer)
|
||||
self._askPlayerTimer.start(when)
|
||||
@ -171,7 +159,7 @@ class SyncplayClient(object):
|
||||
if not self._running:
|
||||
return
|
||||
if self._player:
|
||||
self._playerRequest(self._player.askForStatus)
|
||||
self._player.askForStatus()
|
||||
self.checkIfConnected()
|
||||
|
||||
def checkIfConnected(self):
|
||||
@ -192,22 +180,11 @@ class SyncplayClient(object):
|
||||
def rewindFile(self):
|
||||
self.setPosition(0)
|
||||
|
||||
def _ignoringPlayerStatus(self, cookie=None):
|
||||
if cookie is None:
|
||||
cookie = time.time()
|
||||
return cookie < self._lastPlayerCommand + self._config['playerCommandDelay']
|
||||
|
||||
def updatePlayerStatus(self, paused, position, cookie=None):
|
||||
# Ignore status report if the cookie is stale
|
||||
if self._ignoringPlayerStatus(cookie):
|
||||
self.ui.showDebugMessage('Ignoring stale player status with cookie {}'.format(cookie))
|
||||
return
|
||||
|
||||
def updatePlayerStatus(self, paused, position):
|
||||
position -= self.getUserOffset()
|
||||
pauseChange, seeked = self._determinePlayerStateChange(paused, position)
|
||||
self._playerPosition = position
|
||||
self._playerPaused = paused
|
||||
|
||||
currentLength = self.userlist.currentUser.file["duration"] if self.userlist.currentUser.file else 0
|
||||
if pauseChange and paused and currentLength > constants.PLAYLIST_LOAD_NEXT_FILE_MINIMUM_LENGTH\
|
||||
and abs(position - currentLength ) < constants.PLAYLIST_LOAD_NEXT_FILE_TIME_FROM_END_THRESHOLD:
|
||||
@ -224,7 +201,7 @@ class SyncplayClient(object):
|
||||
|
||||
def _toggleReady(self, pauseChange, paused):
|
||||
if not self.userlist.currentUser.canControl():
|
||||
self._playerCommand(self._player.setPaused, self._globalPaused)
|
||||
self._player.setPaused(self._globalPaused)
|
||||
self.toggleReady(manuallyInitiated=True)
|
||||
self._playerPaused = self._globalPaused
|
||||
pauseChange = False
|
||||
@ -234,7 +211,7 @@ class SyncplayClient(object):
|
||||
self.ui.showMessage(getMessage("set-as-not-ready-notification"))
|
||||
elif not paused and not self.instaplayConditionsMet():
|
||||
paused = True
|
||||
self._playerCommand(self._player.setPaused, paused)
|
||||
self._player.setPaused(paused)
|
||||
self._playerPaused = paused
|
||||
self.changeReadyState(True, manuallyInitiated=True)
|
||||
pauseChange = False
|
||||
@ -262,7 +239,7 @@ class SyncplayClient(object):
|
||||
def _initPlayerState(self, position, paused):
|
||||
if self.userlist.currentUser.file:
|
||||
self.setPosition(position)
|
||||
self._playerCommand(self._player.setPaused, paused)
|
||||
self._player.setPaused(paused)
|
||||
madeChangeOnPlayer = True
|
||||
return madeChangeOnPlayer
|
||||
|
||||
@ -290,21 +267,16 @@ class SyncplayClient(object):
|
||||
|
||||
def _serverUnpaused(self, setBy):
|
||||
hideFromOSD = not constants.SHOW_SAME_ROOM_OSD
|
||||
# In high-player-latency situations we might report our state back to
|
||||
# the server before any player status is accepted as fresh. Override
|
||||
# the locally-stored playback state.
|
||||
self._playerPaused = False
|
||||
self._playerCommand(self._player.setPaused, False)
|
||||
self._player.setPaused(False)
|
||||
madeChangeOnPlayer = True
|
||||
self.ui.showMessage(getMessage("unpause-notification").format(setBy), hideFromOSD)
|
||||
return madeChangeOnPlayer
|
||||
|
||||
def _serverPaused(self, setBy):
|
||||
hideFromOSD = not constants.SHOW_SAME_ROOM_OSD
|
||||
self._playerPaused = True
|
||||
if constants.SYNC_ON_PAUSE and self.getUsername() <> setBy:
|
||||
self.setPosition(self.getGlobalPosition())
|
||||
self._playerCommand(self._player.setPaused, True)
|
||||
self._player.setPaused(True)
|
||||
madeChangeOnPlayer = True
|
||||
if (self.lastLeftTime < time.time() - constants.OSD_DURATION) or (hideFromOSD == True):
|
||||
self.ui.showMessage(getMessage("pause-notification").format(setBy), hideFromOSD)
|
||||
@ -569,19 +541,18 @@ class SyncplayClient(object):
|
||||
def setPosition(self, position):
|
||||
if self._lastPlayerUpdate:
|
||||
self._lastPlayerUpdate = time.time()
|
||||
self._playerPosition = position
|
||||
position += self.getUserOffset()
|
||||
if self._player and self.userlist.currentUser.file:
|
||||
if position < 0:
|
||||
position = 0
|
||||
self._protocol.sendState(self.getPlayerPosition(), self.getPlayerPaused(), True, None, True)
|
||||
self._playerCommand(self._player.setPosition, position)
|
||||
self._player.setPosition(position)
|
||||
|
||||
def setPaused(self, paused):
|
||||
if self._player and self.userlist.currentUser.file:
|
||||
if self._lastPlayerUpdate and not paused:
|
||||
self._lastPlayerUpdate = time.time()
|
||||
self._playerCommand(self._player.setPaused, paused)
|
||||
self._player.setPaused(paused)
|
||||
|
||||
def start(self, host, port):
|
||||
if self._running:
|
||||
|
||||
@ -51,7 +51,6 @@ SERVER_STATE_INTERVAL = 1
|
||||
WARNING_OSD_MESSAGES_LOOP_INTERVAL = 1
|
||||
AUTOPLAY_DELAY = 3.0
|
||||
SYNC_ON_PAUSE = True # Client seek to global position - subtitles may disappear on some media players
|
||||
DEFAULT_PLAYER_COMMAND_DELAY = 0.05
|
||||
|
||||
# Options for the File Switch feature:
|
||||
FOLDER_SEARCH_TIMEOUT = 60.0 # Secs - How long to wait until searches in folder to update cache are aborted (may be longer than this if hard drive needs to spin up)
|
||||
|
||||
@ -200,9 +200,6 @@ en = {
|
||||
"readyatstart-label" : "Set me as 'ready to watch' by default",
|
||||
"forceguiprompt-label" : "Don't always show the Syncplay configuration window", # (Inverted)
|
||||
"showosd-label" : "Enable OSD Messages",
|
||||
"playercommanddelay-title" : "Player latency compensation",
|
||||
"playercommanddelay-label" : "Seconds to ignore player status after commands",
|
||||
"playercommanddelay-tooltip" : "Larger values are less likely to spuriously (un)pause but tend to sync less accurately.",
|
||||
|
||||
"showosdwarnings-label" : "Include warnings (e.g. when files are different, users not ready)",
|
||||
"showsameroomosd-label" : "Include events in your room",
|
||||
|
||||
@ -6,7 +6,7 @@ class BasePlayer(object):
|
||||
execute updatePlayerStatus(paused, position) on client
|
||||
Given the arguments: boolean paused and float position in seconds
|
||||
'''
|
||||
def askForStatus(self, cookie=None):
|
||||
def askForStatus(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
'''
|
||||
@ -121,4 +121,4 @@ class DummyPlayer(BasePlayer):
|
||||
|
||||
@staticmethod
|
||||
def getPlayerPathErrors(playerPath, filePath):
|
||||
return None
|
||||
return None
|
||||
@ -2,8 +2,7 @@
|
||||
import time
|
||||
import threading
|
||||
import thread
|
||||
# noinspection PyUnresolvedReferences
|
||||
import win32con, win32api, win32gui, ctypes, ctypes.wintypes
|
||||
import win32con, win32api, win32gui, ctypes, ctypes.wintypes #@UnresolvedImport @UnusedImport
|
||||
from functools import wraps
|
||||
from syncplay.players.basePlayer import BasePlayer
|
||||
import re
|
||||
@ -420,7 +419,7 @@ class MPCHCAPIPlayer(BasePlayer):
|
||||
self.__positionUpdate.wait(constants.MPC_LOCK_WAIT_TIME)
|
||||
return self._mpcApi.lastFilePosition
|
||||
|
||||
def askForStatus(self, cookie=None):
|
||||
def askForStatus(self):
|
||||
try:
|
||||
if self._mpcApi.filePlaying and self.__preventAsking.wait(0) and self.__fileUpdate.acquire(0):
|
||||
self.__fileUpdate.release()
|
||||
@ -428,17 +427,15 @@ class MPCHCAPIPlayer(BasePlayer):
|
||||
paused = self._mpcApi.isPaused()
|
||||
position = float(position)
|
||||
if self.__preventAsking.wait(0) and self.__fileUpdate.acquire(0):
|
||||
self.__client.updatePlayerStatus(paused, position, cookie=cookie)
|
||||
self.__client.updatePlayerStatus(paused, position)
|
||||
self.__fileUpdate.release()
|
||||
else:
|
||||
self.__echoGlobalStatus(cookie)
|
||||
self.__echoGlobalStatus()
|
||||
except MpcHcApi.PlayerNotReadyException:
|
||||
self.__echoGlobalStatus(cookie)
|
||||
self.__echoGlobalStatus()
|
||||
|
||||
def __echoGlobalStatus(self, cookie):
|
||||
self.__client.updatePlayerStatus(self.__client.getGlobalPaused(),
|
||||
self.__client.getGlobalPosition(),
|
||||
cookie=cookie)
|
||||
def __echoGlobalStatus(self):
|
||||
self.__client.updatePlayerStatus(self.__client.getGlobalPaused(), self.__client.getGlobalPosition())
|
||||
|
||||
def __forcePause(self):
|
||||
for _ in xrange(constants.MPC_MAX_RETRIES):
|
||||
|
||||
@ -72,14 +72,14 @@ class MplayerPlayer(BasePlayer):
|
||||
self.reactor.callLater(0, self._client.initPlayer, self)
|
||||
self._onFileUpdate()
|
||||
|
||||
def askForStatus(self, cookie=None):
|
||||
def askForStatus(self):
|
||||
self._positionAsk.clear()
|
||||
self._pausedAsk.clear()
|
||||
self._getPaused()
|
||||
self._getPosition()
|
||||
self._positionAsk.wait()
|
||||
self._pausedAsk.wait()
|
||||
self._client.updatePlayerStatus(self._paused, self._position, cookie=cookie)
|
||||
self._client.updatePlayerStatus(self._paused, self._position)
|
||||
|
||||
def _setProperty(self, property_, value):
|
||||
self._listener.sendLine("set_property {} {}".format(property_, value))
|
||||
|
||||
@ -160,15 +160,13 @@ class NewMpvPlayer(OldMpvPlayer):
|
||||
else:
|
||||
self._paused = self._client.getGlobalPaused()
|
||||
|
||||
def askForStatus(self, cookie=None):
|
||||
def askForStatus(self):
|
||||
self._positionAsk.clear()
|
||||
self._pausedAsk.clear()
|
||||
self._getPausedAndPosition()
|
||||
self._positionAsk.wait(constants.MPV_LOCK_WAIT_TIME)
|
||||
self._pausedAsk.wait(constants.MPV_LOCK_WAIT_TIME)
|
||||
self._client.updatePlayerStatus(self._paused if self.fileLoaded else self._client.getGlobalPaused(),
|
||||
self.getCalculatedPosition(),
|
||||
cookie=cookie)
|
||||
self._client.updatePlayerStatus(self._paused if self.fileLoaded else self._client.getGlobalPaused(), self.getCalculatedPosition())
|
||||
|
||||
def _getPausedAndPosition(self):
|
||||
self._listener.sendLine(u"print_text ANS_pause=${pause}\r\nprint_text ANS_time-pos=${=time-pos}")
|
||||
@ -234,4 +232,4 @@ class NewMpvPlayer(OldMpvPlayer):
|
||||
if self.fileLoaded == True and self.lastLoadedTime != None and time.time() > (self.lastLoadedTime + constants.MPV_NEWFILE_IGNORE_TIME):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
@ -83,20 +83,16 @@ class VlcPlayer(BasePlayer):
|
||||
self.setPaused(self._client.getGlobalPaused())
|
||||
self.setPosition(self._client.getGlobalPosition())
|
||||
|
||||
def askForStatus(self, cookie=None):
|
||||
def askForStatus(self):
|
||||
self._filechanged = False
|
||||
self._positionAsk.clear()
|
||||
self._pausedAsk.clear()
|
||||
self._listener.sendLine(".")
|
||||
if self._filename and not self._filechanged:
|
||||
self._positionAsk.wait(constants.PLAYER_ASK_DELAY)
|
||||
self._client.updatePlayerStatus(self._paused,
|
||||
self.getCalculatedPosition(),
|
||||
cookie=cookie)
|
||||
self._client.updatePlayerStatus(self._paused, self.getCalculatedPosition())
|
||||
else:
|
||||
self._client.updatePlayerStatus(self._client.getGlobalPaused(),
|
||||
self._client.getGlobalPosition(),
|
||||
cookie=cookie)
|
||||
self._client.updatePlayerStatus(self._client.getGlobalPaused(), self._client.getGlobalPosition())
|
||||
|
||||
def getCalculatedPosition(self):
|
||||
if self._lastVLCPositionUpdate is None:
|
||||
|
||||
@ -66,8 +66,7 @@ class ConfigurationGetter(object):
|
||||
"showSameRoomOSD" : True,
|
||||
"showNonControllerOSD" : False,
|
||||
"showContactInfo" : True,
|
||||
"showDurationNotification" : True,
|
||||
"playerCommandDelay": constants.DEFAULT_PLAYER_COMMAND_DELAY
|
||||
"showDurationNotification" : True
|
||||
}
|
||||
|
||||
self._defaultConfig = self._config.copy()
|
||||
@ -124,7 +123,6 @@ class ConfigurationGetter(object):
|
||||
"rewindThreshold",
|
||||
"fastforwardThreshold",
|
||||
"autoplayMinUsers",
|
||||
"playerCommandDelay",
|
||||
]
|
||||
|
||||
self._iniStructure = {
|
||||
@ -138,8 +136,7 @@ class ConfigurationGetter(object):
|
||||
"filesizePrivacyMode", "unpauseAction",
|
||||
"pauseOnLeave", "readyAtStart", "autoplayMinUsers",
|
||||
"autoplayInitialState", "mediaSearchDirectories",
|
||||
"sharedPlaylistEnabled", "playerCommandDelay",
|
||||
"loopAtEndOfPlaylist"],
|
||||
"sharedPlaylistEnabled", "loopAtEndOfPlaylist"],
|
||||
"gui": ["showOSD", "showOSDWarnings", "showSlowdownOSD",
|
||||
"showDifferentRoomOSD", "showSameRoomOSD",
|
||||
"showNonControllerOSD", "showDurationNotification"],
|
||||
|
||||
@ -416,8 +416,6 @@ class ConfigDialog(QtGui.QDialog):
|
||||
widget.setChecked(True)
|
||||
elif isinstance(widget, QLineEdit):
|
||||
widget.setText(self.config[valueName])
|
||||
elif isinstance(widget, QDoubleSpinBox):
|
||||
widget.setValue(self.config[valueName])
|
||||
|
||||
def saveValues(self, widget):
|
||||
valueName = str(widget.objectName())
|
||||
@ -440,8 +438,6 @@ class ConfigDialog(QtGui.QDialog):
|
||||
self.config[radioName] = radioValue
|
||||
elif isinstance(widget, QLineEdit):
|
||||
self.config[valueName] = widget.text()
|
||||
elif isinstance(widget, QDoubleSpinBox):
|
||||
self.config[valueName] = widget.value()
|
||||
|
||||
def connectChildren(self, widget):
|
||||
widgetName = str(widget.objectName())
|
||||
@ -737,10 +733,6 @@ class ConfigDialog(QtGui.QDialog):
|
||||
self.rewindCheckbox.setObjectName("rewindOnDesync")
|
||||
self.fastforwardCheckbox = QCheckBox(getMessage("fastforwardondesync-label"))
|
||||
self.fastforwardCheckbox.setObjectName("fastforwardOnDesync")
|
||||
self.commandDelaySpinbox = QDoubleSpinBox()
|
||||
self.commandDelaySpinbox.setObjectName("playerCommandDelay")
|
||||
self.commandDelaySpinbox.setMaximum(10)
|
||||
self.commandDelaySpinbox.setSingleStep(.1)
|
||||
|
||||
self.desyncSettingsLayout = QtGui.QGridLayout()
|
||||
self.desyncSettingsLayout.setSpacing(2)
|
||||
@ -769,17 +761,10 @@ class ConfigDialog(QtGui.QDialog):
|
||||
self.othersyncSettingsLayout.setAlignment(Qt.AlignLeft)
|
||||
self.othersyncSettingsLayout.addWidget(self.fastforwardCheckbox, 3, 0,1,2, Qt.AlignLeft)
|
||||
|
||||
self.playerLatencyGroup = QtGui.QGroupBox(getMessage("playercommanddelay-title"))
|
||||
self.playerLatencyLayout = QtGui.QHBoxLayout()
|
||||
self.playerLatencyGroup.setLayout(self.playerLatencyLayout)
|
||||
self.playerLatencyLayout.addWidget(self.commandDelaySpinbox)
|
||||
self.playerLatencyLayout.addWidget(QLabel(getMessage("playercommanddelay-label")))
|
||||
|
||||
self.othersyncSettingsGroup.setLayout(self.othersyncSettingsLayout)
|
||||
self.othersyncSettingsGroup.setMaximumHeight(self.othersyncSettingsGroup.minimumSizeHint().height())
|
||||
self.syncSettingsLayout.addWidget(self.othersyncSettingsGroup)
|
||||
self.syncSettingsLayout.addWidget(self.desyncSettingsGroup)
|
||||
self.syncSettingsLayout.addWidget(self.playerLatencyGroup)
|
||||
self.syncSettingsFrame.setLayout(self.syncSettingsLayout)
|
||||
self.desyncSettingsGroup.setMaximumHeight(self.desyncSettingsGroup.minimumSizeHint().height())
|
||||
self.syncSettingsLayout.setAlignment(Qt.AlignTop)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user