2013-10-13 22:45:51 +01:00

37 lines
1.1 KiB
Python

from syncplay.players.mplayer import MplayerPlayer
from syncplay import constants
class MpvPlayer(MplayerPlayer):
SLAVE_ARGS = constants.MPV_SLAVE_ARGS
@staticmethod
def run(client, playerPath, filePath, args):
return MpvPlayer(client, MpvPlayer.getExpandedPath(playerPath), filePath, args)
@staticmethod
def getDefaultPlayerPathsList():
l = []
for path in constants.MPV_PATHS:
p = MpvPlayer.getExpandedPath(path)
if p:
l.append(p)
return l
@staticmethod
def isValidPlayerPath(path):
if("mpv" in path and MpvPlayer.getExpandedPath(path)):
return True
return False
@staticmethod
def getExpandedPath(playerPath):
if(os.path.isfile(playerPath + u"\\mpv.exe")):
playerPath += u"\\mpv.exe"
return playerPath
if os.access(playerPath, os.X_OK):
return playerPath
for path in os.environ['PATH'].split(':'):
path = os.path.join(os.path.realpath(path), playerPath)
if os.access(path, os.X_OK):
return path