Fix on setting intial state for mpc

This commit is contained in:
Uriziel 2012-12-10 23:14:03 +01:00
parent ec176eaf05
commit a9083796f1

View File

@ -132,9 +132,11 @@ class MPCHCAPIPlayer(BasePlayer):
try: try:
self.__forcePause(self.__client.getGlobalPaused()) self.__forcePause(self.__client.getGlobalPaused())
self._mpcApi.seek(self.__client.getGlobalPosition()) self._mpcApi.seek(self.__client.getGlobalPosition())
time.sleep(0.1)
if(self._mpcApi.isPaused() <> self.__client.getGlobalPaused()): if(self._mpcApi.isPaused() <> self.__client.getGlobalPaused()):
self.__setUpStateForNewlyOpenedFile() time.sleep(0.1)
self._mpcApi.playPause()
if(self._mpcApi.isPaused() <> self.__client.getGlobalPaused()):
self.__setUpStateForNewlyOpenedFile()
except MpcHcApi.PlayerNotReadyException: except MpcHcApi.PlayerNotReadyException:
time.sleep(0.1) time.sleep(0.1)
self.__setUpStateForNewlyOpenedFile() self.__setUpStateForNewlyOpenedFile()
@ -189,6 +191,7 @@ class MpcHcApi:
self.__listener.SendCommand(self.CMD_OPENFILE, filePath) self.__listener.SendCommand(self.CMD_OPENFILE, filePath)
def isPaused(self): def isPaused(self):
print self.playState
return (self.playState <> self.__MPC_PLAYSTATE.PS_PLAY and self.playState <> None) return (self.playState <> self.__MPC_PLAYSTATE.PS_PLAY and self.playState <> None)
def askForVersion(self): def askForVersion(self):
@ -198,6 +201,10 @@ class MpcHcApi:
def pause(self): def pause(self):
self.__listener.SendCommand(self.CMD_PAUSE) self.__listener.SendCommand(self.CMD_PAUSE)
@waitForFileStateReady
def playPause(self):
self.__listener.SendCommand(self.CMD_PLAYPAUSE)
@waitForFileStateReady @waitForFileStateReady
def unpause(self): def unpause(self):
self.__listener.SendCommand(self.CMD_PLAY) self.__listener.SendCommand(self.CMD_PLAY)