Allow mpv with no file [#53] (Thanks wiiaboo)

This commit is contained in:
Et0h 2015-02-16 23:39:42 +00:00
parent eddd079140
commit a795acae0a
3 changed files with 16 additions and 5 deletions

View File

@ -133,7 +133,7 @@ USERLIST_GUI_USERNAME_OFFSET = 21 # Pixels
MPLAYER_SLAVE_ARGS = ['-slave', '--hr-seek=always', '-nomsgcolor', '-msglevel', 'all=1:global=4:cplayer=4', '-af', 'scaletempo']
# --quiet works with both mpv 0.2 and 0.3
MPV_SLAVE_ARGS = ['--hr-seek=always', '--quiet', '--keep-open', '-af', 'scaletempo']
MPV_SLAVE_ARGS = ['--force-window','--idle','--hr-seek=always', '--quiet', '--keep-open', '-af', 'scaletempo']
MPV_SLAVE_ARGS_WINDOWS = ['--slave-broken']
MPV_SLAVE_ARGS_NONWINDOWS = ['--input-terminal=no','--input-file=/dev/stdin']
MPV_SLAVE_ARGS_NEW = ['--term-playing-msg=<SyncplayUpdateFile>\nANS_filename=${filename}\nANS_length=${=length}\nANS_path=${path}\n</SyncplayUpdateFile>']

View File

@ -255,14 +255,16 @@ class MplayerPlayer(BasePlayer):
class __Listener(threading.Thread):
def __init__(self, playerController, playerPath, filePath, args):
self.__playerController = playerController
if not filePath:
if self.__playerController.getPlayerPathErrors(playerPath,filePath):
raise ValueError()
if '://' not in filePath:
if filePath and '://' not in filePath:
if not os.path.isfile(filePath) and 'PWD' in os.environ:
filePath = os.environ['PWD'] + os.path.sep + filePath
filePath = os.path.realpath(filePath)
call = [playerPath, filePath]
call = [playerPath]
if filePath:
call.extend(filePath)
call.extend(playerController.getStartupArgs(playerPath))
if args:
call.extend(args)
@ -273,11 +275,16 @@ class MplayerPlayer(BasePlayer):
env = os.environ.copy()
if 'TERM' in env:
del env['TERM']
if filePath:
self.__process = subprocess.Popen(call, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=self.__getCwd(filePath, env), env=env)
else:
self.__process = subprocess.Popen(call, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, env=env)
threading.Thread.__init__(self, name="MPlayer Listener")
def __getCwd(self, filePath, env):
if not filePath:
return None
if os.path.isfile(filePath):
cwd = os.path.dirname(filePath)
elif 'HOME' in env:

View File

@ -67,6 +67,10 @@ class MpvPlayer(MplayerPlayer):
def getIconPath(path):
return constants.MPV_ICONPATH
@staticmethod
def getPlayerPathErrors(playerPath, filePath):
return None
class OldMpvPlayer(MpvPlayer):
POSITION_QUERY = 'time-pos'
OSD_QUERY = 'show_text'