Re-work drop (mpc.py)
This commit is contained in:
parent
33a079e124
commit
385a6bb5ab
@ -311,7 +311,7 @@ class MPCHCAPIPlayer(BasePlayer):
|
|||||||
self.__client = client
|
self.__client = client
|
||||||
self._mpcApi = MpcHcApi()
|
self._mpcApi = MpcHcApi()
|
||||||
self._mpcApi.callbacks.onUpdateFilename = lambda _: self.__makePing()
|
self._mpcApi.callbacks.onUpdateFilename = lambda _: self.__makePing()
|
||||||
self._mpcApi.callbacks.onMpcClosed = lambda _: self.reactor.callFromThread(self.__client.stop, (False),)
|
self._mpcApi.callbacks.onMpcClosed = lambda _: self.reactor.callFromThread(self.__client.stop,)
|
||||||
self._mpcApi.callbacks.onFileStateChange = lambda _: self.__lockAsking()
|
self._mpcApi.callbacks.onFileStateChange = lambda _: self.__lockAsking()
|
||||||
self._mpcApi.callbacks.onUpdatePlaystate = lambda _: self.__unlockAsking()
|
self._mpcApi.callbacks.onUpdatePlaystate = lambda _: self.__unlockAsking()
|
||||||
self._mpcApi.callbacks.onGetCurrentPosition = lambda _: self.__onGetPosition()
|
self._mpcApi.callbacks.onGetCurrentPosition = lambda _: self.__onGetPosition()
|
||||||
@ -356,8 +356,7 @@ class MPCHCAPIPlayer(BasePlayer):
|
|||||||
def __dropIfNotSufficientVersion(self):
|
def __dropIfNotSufficientVersion(self):
|
||||||
self._mpcApi.askForVersion()
|
self._mpcApi.askForVersion()
|
||||||
if(not self.__versionUpdate.wait(0.1) or not self._mpcApi.version):
|
if(not self.__versionUpdate.wait(0.1) or not self._mpcApi.version):
|
||||||
self.__mpcError(getMessage("en", "mpc-version-insufficient-error").format(constants.MPC_MIN_VER))
|
self.reactor.callFromThread(self.__client.stop, getMessage("en", "mpc-version-insufficient-error").format(constants.MPC_MIN_VER),)
|
||||||
self.reactor.callFromThread(self.__client.stop, (True),)
|
|
||||||
|
|
||||||
def __testMpcReady(self):
|
def __testMpcReady(self):
|
||||||
if(not self.__preventAsking.wait(10)):
|
if(not self.__preventAsking.wait(10)):
|
||||||
@ -370,8 +369,7 @@ class MPCHCAPIPlayer(BasePlayer):
|
|||||||
self.__handleUpdatedFilename()
|
self.__handleUpdatedFilename()
|
||||||
self.askForStatus()
|
self.askForStatus()
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
self.__client.ui.showErrorMessage(err.message)
|
self.reactor.callFromThread(self.__client.stop, err.message,)
|
||||||
self.reactor.callFromThread(self.__client.stop)
|
|
||||||
|
|
||||||
def initPlayer(self, filePath):
|
def initPlayer(self, filePath):
|
||||||
self.__dropIfNotSufficientVersion()
|
self.__dropIfNotSufficientVersion()
|
||||||
@ -456,10 +454,6 @@ class MPCHCAPIPlayer(BasePlayer):
|
|||||||
self.__setUpStateForNewlyOpenedFile()
|
self.__setUpStateForNewlyOpenedFile()
|
||||||
args = (self._mpcApi.filePlaying, self._mpcApi.fileDuration, self._mpcApi.filePath)
|
args = (self._mpcApi.filePlaying, self._mpcApi.fileDuration, self._mpcApi.filePath)
|
||||||
self.reactor.callFromThread(self.__client.updateFile, *args)
|
self.reactor.callFromThread(self.__client.updateFile, *args)
|
||||||
|
|
||||||
def __mpcError(self, err=""):
|
|
||||||
self.__client.ui.showErrorMessage(err)
|
|
||||||
self.reactor.callFromThread(self.__client.stop)
|
|
||||||
|
|
||||||
def sendCustomCommand(self, cmd, val):
|
def sendCustomCommand(self, cmd, val):
|
||||||
self._mpcApi.sendRawCommand(cmd, val)
|
self._mpcApi.sendRawCommand(cmd, val)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user