Reduce MPC problems when file change takes too long
This commit is contained in:
parent
2c885d07b2
commit
1964d25e96
@ -418,20 +418,22 @@ class MPCHCAPIPlayer(BasePlayer):
|
|||||||
self._mpcApi.askForCurrentPosition()
|
self._mpcApi.askForCurrentPosition()
|
||||||
self.__positionUpdate.wait(constants.MPC_LOCK_WAIT_TIME)
|
self.__positionUpdate.wait(constants.MPC_LOCK_WAIT_TIME)
|
||||||
return self._mpcApi.lastFilePosition
|
return self._mpcApi.lastFilePosition
|
||||||
|
|
||||||
@retry(MpcHcApi.PlayerNotReadyException, constants.MPC_MAX_RETRIES, constants.MPC_RETRY_WAIT_TIME, 1)
|
|
||||||
def askForStatus(self):
|
def askForStatus(self):
|
||||||
if self._mpcApi.filePlaying and self.__preventAsking.wait(0) and self.__fileUpdate.acquire(0):
|
try:
|
||||||
self.__fileUpdate.release()
|
if self._mpcApi.filePlaying and self.__preventAsking.wait(0) and self.__fileUpdate.acquire(0):
|
||||||
position = self.__getPosition()
|
|
||||||
paused = self._mpcApi.isPaused()
|
|
||||||
position = float(position)
|
|
||||||
if self.__preventAsking.wait(0) and self.__fileUpdate.acquire(0):
|
|
||||||
self.__client.updatePlayerStatus(paused, position)
|
|
||||||
self.__fileUpdate.release()
|
self.__fileUpdate.release()
|
||||||
return
|
position = self.__getPosition()
|
||||||
self.__echoGlobalStatus()
|
paused = self._mpcApi.isPaused()
|
||||||
|
position = float(position)
|
||||||
|
if self.__preventAsking.wait(0) and self.__fileUpdate.acquire(0):
|
||||||
|
self.__client.updatePlayerStatus(paused, position)
|
||||||
|
self.__fileUpdate.release()
|
||||||
|
else:
|
||||||
|
self.__echoGlobalStatus()
|
||||||
|
except MpcHcApi.PlayerNotReadyException:
|
||||||
|
self.__echoGlobalStatus()
|
||||||
|
|
||||||
def __echoGlobalStatus(self):
|
def __echoGlobalStatus(self):
|
||||||
self.__client.updatePlayerStatus(self.__client.getGlobalPaused(), self.__client.getGlobalPosition())
|
self.__client.updatePlayerStatus(self.__client.getGlobalPaused(), self.__client.getGlobalPosition())
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user