56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
from syncplay.players.mplayer import MplayerPlayer
|
|
from syncplay import constants
|
|
import os
|
|
|
|
class MpvPlayer(MplayerPlayer):
|
|
SLAVE_ARGS = constants.MPV_SLAVE_ARGS
|
|
POSITION_QUERY = 'time-pos'
|
|
OSD_QUERY = 'show_text'
|
|
|
|
def _setProperty(self, property_, value):
|
|
self._listener.sendLine("no-osd set {} {}".format(property_, value))
|
|
|
|
def setPaused(self, value):
|
|
if self._paused <> value:
|
|
self._paused = not self._paused
|
|
self._listener.sendLine('cycle pause')
|
|
|
|
@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
|