46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
from syncplay.players.mplayer import MplayerPlayer
|
|
from syncplay import constants
|
|
import os
|
|
|
|
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 not os.path.isfile(playerPath):
|
|
if os.path.isfile(playerPath + u"mpv.exe"):
|
|
playerPath += u"mpv.exe"
|
|
return playerPath
|
|
elif 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
|
|
|
|
@staticmethod
|
|
def getIconPath(path):
|
|
return constants.MPV_ICONPATH
|