diff --git a/syncplay/players/basePlayer.py b/syncplay/players/basePlayer.py index 5093668..4609757 100644 --- a/syncplay/players/basePlayer.py +++ b/syncplay/players/basePlayer.py @@ -89,7 +89,19 @@ class BasePlayer(object): @staticmethod def openCustomOpenDialog(self): raise NotImplementedError() - + + ''' + @type filePath: string + @return errorMessage: string + + Checks if the player has any problems with the given file (or lack of file) + If a problem is detected then it returns the error message + If the file is fine then it returns None + ''' + @staticmethod + def getFilePathErrors(filePath): + raise NotImplementedError() + class DummyPlayer(BasePlayer): @staticmethod @@ -107,3 +119,7 @@ class DummyPlayer(BasePlayer): @staticmethod def getExpandedPath(path): return path + + @staticmethod + def getFilePathErrors(filePath): + return None diff --git a/syncplay/players/mpc.py b/syncplay/players/mpc.py index d79a9ef..a62ac95 100644 --- a/syncplay/players/mpc.py +++ b/syncplay/players/mpc.py @@ -332,6 +332,10 @@ class MPCHCAPIPlayer(BasePlayer): self.__versionUpdate.set() self._mpcApi.sendRawCommand(MpcHcApi.CMD_CLOSEAPP, "") + @staticmethod + def getFilePathErrors(filePath): + return None + @staticmethod def run(client, playerPath, filePath, args): args.extend(['/open', '/new']) diff --git a/syncplay/players/mplayer.py b/syncplay/players/mplayer.py index db14c91..c5f2a4f 100644 --- a/syncplay/players/mplayer.py +++ b/syncplay/players/mplayer.py @@ -212,6 +212,11 @@ class MplayerPlayer(BasePlayer): return True return False + @staticmethod + def getFilePathErrors(filePath): + if not filePath: + return getMessage("no-file-path-config-error") + @staticmethod def getExpandedPath(playerPath): if not os.path.isfile(playerPath): diff --git a/syncplay/players/vlc.py b/syncplay/players/vlc.py index dd35517..3e1b3ae 100644 --- a/syncplay/players/vlc.py +++ b/syncplay/players/vlc.py @@ -200,6 +200,10 @@ class VlcPlayer(BasePlayer): return True return False + @staticmethod + def getFilePathErrors(filePath): + return None + @staticmethod def getIconPath(path): return constants.VLC_ICONPATH diff --git a/syncplay/ui/ConfigurationGetter.py b/syncplay/ui/ConfigurationGetter.py index 610646a..fc654aa 100755 --- a/syncplay/ui/ConfigurationGetter.py +++ b/syncplay/ui/ConfigurationGetter.py @@ -145,9 +145,9 @@ class ConfigurationGetter(object): self._config["playerClass"] = player else: raise InvalidConfigValue(getMessage("player-path-config-error")) - if player.__name__ in ['MpvPlayer', 'MplayerPlayer']: - if not self._config['file']: - raise InvalidConfigValue(getMessage("no-file-path-config-error")) + fileErrors = player.getFilePathErrors(self._config['file'] if self._config['file'] else None) + if fileErrors: + raise InvalidConfigValue(fileErrors) elif key == "host": self._config["host"], self._config["port"] = self._splitPortAndHost(self._config["host"]) hostNotValid = (self._config["host"] == "" or self._config["host"] is None)