Fixed crashing with mpv < 0.4
This commit is contained in:
parent
2597dee602
commit
1c37e30c7d
@ -10,7 +10,6 @@ import os
|
||||
class MplayerPlayer(BasePlayer):
|
||||
speedSupported = True
|
||||
RE_ANSWER = re.compile(constants.MPLAYER_ANSWER_REGEX)
|
||||
SLAVE_ARGS = constants.MPLAYER_SLAVE_ARGS
|
||||
POSITION_QUERY = 'time_pos'
|
||||
OSD_QUERY = 'osd_show_text'
|
||||
|
||||
@ -153,7 +152,7 @@ class MplayerPlayer(BasePlayer):
|
||||
self._filenameAsk.set()
|
||||
elif name == "exiting":
|
||||
if value != 'Quit':
|
||||
if self.quitReason == None:
|
||||
if self.quitReason is None:
|
||||
self.quitReason = getMessage("media-player-error").format(value)
|
||||
self.reactor.callFromThread(self._client.ui.showErrorMessage, self.quitReason, True)
|
||||
self.drop()
|
||||
@ -176,6 +175,10 @@ class MplayerPlayer(BasePlayer):
|
||||
def getIconPath(path):
|
||||
return constants.MPLAYER_ICONPATH
|
||||
|
||||
@staticmethod
|
||||
def getStartupArgs(path):
|
||||
return constants.MPLAYER_SLAVE_ARGS
|
||||
|
||||
@staticmethod
|
||||
def isValidPlayerPath(path):
|
||||
if "mplayer" in path and MplayerPlayer.getExpandedPath(path):
|
||||
@ -225,7 +228,7 @@ class MplayerPlayer(BasePlayer):
|
||||
filePath = os.path.realpath(filePath)
|
||||
|
||||
call = [playerPath, filePath]
|
||||
call.extend(playerController.SLAVE_ARGS)
|
||||
call.extend(playerController.getStartupArgs(playerPath))
|
||||
if args:
|
||||
call.extend(args)
|
||||
# At least mpv may output escape sequences which result in syncplay
|
||||
|
||||
@ -1,15 +1,13 @@
|
||||
import re
|
||||
import subprocess
|
||||
from syncplay.players.mplayer import MplayerPlayer
|
||||
from syncplay import constants
|
||||
import os, sys
|
||||
|
||||
class MpvPlayer(MplayerPlayer):
|
||||
SLAVE_ARGS = constants.MPV_SLAVE_ARGS
|
||||
if sys.platform.startswith('win'):
|
||||
SLAVE_ARGS.extend(constants.MPV_SLAVE_ARGS_WINDOWS)
|
||||
else:
|
||||
SLAVE_ARGS.extend(constants.MPV_SLAVE_ARGS_NONWINDOWS)
|
||||
POSITION_QUERY = 'time-pos'
|
||||
OSD_QUERY = 'show_text'
|
||||
RE_VERSION = re.compile('.*mpv (\d)\.(\d)\.\d.*')
|
||||
|
||||
def _setProperty(self, property_, value):
|
||||
self._listener.sendLine("no-osd set {} {}".format(property_, value))
|
||||
@ -23,6 +21,17 @@ class MpvPlayer(MplayerPlayer):
|
||||
def run(client, playerPath, filePath, args):
|
||||
return MpvPlayer(client, MpvPlayer.getExpandedPath(playerPath), filePath, args)
|
||||
|
||||
@staticmethod
|
||||
def getStartupArgs(path):
|
||||
ver = MpvPlayer.RE_VERSION.search(subprocess.check_output([path, '--version']))
|
||||
new_mpv = ver is None or int(ver.group(1)) > 0 or int(ver.group(2)) >= 5
|
||||
args = constants.MPV_SLAVE_ARGS
|
||||
if sys.platform.startswith('win') or not new_mpv:
|
||||
args.extend(constants.MPV_SLAVE_ARGS_WINDOWS)
|
||||
else:
|
||||
args.extend(constants.MPV_SLAVE_ARGS_NONWINDOWS)
|
||||
return args
|
||||
|
||||
@staticmethod
|
||||
def getDefaultPlayerPathsList():
|
||||
l = []
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user