MPV support.

This commit is contained in:
daniel-123 2013-01-11 20:30:37 +01:00
parent e61cddacbe
commit 98c63b7db9
3 changed files with 30 additions and 1 deletions

View File

@ -38,6 +38,7 @@ MPC_PATHS = [
"C:\Program Files\MPC HomeCinema (x64)\mpc-hc64.exe",
]
MPLAYER_PATHS = ["mplayer2", "mplayer"]
MPV_PATHS = ["mpv", "/opt/mpv/mpv"]
#Changing these is usually not something you're looking for
PLAYER_ASK_DELAY = 0.1
PING_MOVING_AVERAGE_WEIGHT = 0.85
@ -49,6 +50,7 @@ MPC_PAUSE_TOGGLE_DELAY = 0.05
#These are not changes you're looking for
MPLAYER_SLAVE_ARGS = [ '-slave', '-msglevel', 'all=1:global=4']
MPV_SLAVE_ARGS = [ '--slave-broken', '-msglevel', 'all=1:global=4']
MPLAYER_ANSWER_REGEX = "^ANS_([a-zA-Z_]+)=(.+)$"
UI_COMMAND_REGEX = r"^(?P<command>[^\ ]+)(?:\ (?P<parameter>.+))?"
UI_OFFSET_REGEX = r"^(?:o|offset)\ ?(?P<sign>[/+-])?(?P<time>\d{1,4}(?:[^\d\.](?:\d{1,6})){0,2}(?:\.(?:\d{1,3}))?)$"

View File

@ -1,4 +1,5 @@
from syncplay.players.mplayer import MplayerPlayer
from syncplay.players.mpv import MpvPlayer
try:
from syncplay.players.mpc import MPCHCAPIPlayer
except ImportError:
@ -6,4 +7,4 @@ except ImportError:
MPCHCAPIPlayer = DummyPlayer
def getAvailablePlayers():
return [MPCHCAPIPlayer, MplayerPlayer]
return [MPCHCAPIPlayer, MplayerPlayer, MpvPlayer]

26
syncplay/players/mpv.py Normal file
View File

@ -0,0 +1,26 @@
import subprocess
import threading
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