Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions syncplay/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ def getValueForOS(constantDict):
r"c:\program Files (x86)\mpv\mpv.exe", r"c:\program Files (x86)\mpv-player\mpv.exe",
"/Applications/mpv.app/Contents/MacOS/mpv"]
MPVNET_PATHS = [r"c:\program files\mpv.net\mpvnet.exe", r"c:\program Files (x86)\mpv.net\mpvnet.exe"]
MEMENTO_PATHS = ["memento", "/usr/bin/memento", "/usr/local/bin/memento"]

try:
import os
MPVNET_PATHS.append(os.path.expandvars(r'%LOCALAPPDATA%\Microsoft\WindowsApps\mpvnet.exe'))
Expand All @@ -203,6 +205,7 @@ def getValueForOS(constantDict):
MPLAYER_ICONPATH = "mplayer.png"
MPV_ICONPATH = "mpv.png"
MPVNET_ICONPATH = "mpvnet.png"
MEMENTO_ICONPATH = "memento.png"
MPC_ICONPATH = "mpc-hc.png"
MPC64_ICONPATH = "mpc-hc64.png"
MPC_BE_ICONPATH = "mpc-be.png"
Expand Down
4 changes: 3 additions & 1 deletion syncplay/players/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from syncplay.players.mplayer import MplayerPlayer
from syncplay.players.mpv import MpvPlayer
from syncplay.players.mpvnet import MpvnetPlayer
from syncplay.players.memento import MementoPlayer
from syncplay.players.vlc import VlcPlayer

try:
from syncplay.players.mpc import MPCHCAPIPlayer
except ImportError:
Expand All @@ -20,4 +22,4 @@


def getAvailablePlayers():
return [MPCHCAPIPlayer, MpvPlayer, MpvnetPlayer, VlcPlayer, MpcBePlayer, MplayerPlayer, IinaPlayer]
return [MPCHCAPIPlayer, MpvPlayer, MpvnetPlayer, MementoPlayer, VlcPlayer, MpcBePlayer, MplayerPlayer, IinaPlayer]
71 changes: 71 additions & 0 deletions syncplay/players/memento.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import os

from syncplay import constants

from syncplay.players.mpv import MpvPlayer
from syncplay.utils import findResourcePath, playerPathExists


class MementoPlayer(MpvPlayer):
@staticmethod
def run(client, playerPath, filePath, args):
return MementoPlayer(
client, MementoPlayer.getExpandedPath(playerPath), filePath, args
)

@staticmethod
def getDefaultPlayerPathsList():
l = []
for path in constants.MEMENTO_PATHS:
p = MementoPlayer.getExpandedPath(path)
if p:
l.append(p)
return l

@staticmethod
def isValidPlayerPath(path):
if "memento" in path and MementoPlayer.getExpandedPath(path):
return True
return False

@staticmethod
def getExpandedPath(playerPath):
if not playerPathExists(playerPath):
if playerPathExists(playerPath + "memento.exe"):
playerPath += "memento.exe"
return playerPath
elif playerPathExists(playerPath + "\\memento.exe"):
playerPath += "\\memento.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.MEMENTO_ICONPATH

@staticmethod
def getStartupArgs(userArgs):
args = constants.MPV_ARGS
args["scripts"] = findResourcePath("syncplayintf.lua")
if userArgs:
for argToAdd in userArgs:
if argToAdd.startswith("--"):
argToAdd = argToAdd[2:]
elif argToAdd.startswith("-"):
argToAdd = argToAdd[1:]
if argToAdd.strip() == "":
continue
if "=" in argToAdd:
(argName, argValue) = argToAdd.split("=", 1)
if argValue[0] == '"' and argValue[-1] == '"':
argValue = argValue[1:-1]
else:
argName = argToAdd
argValue = ""
args[argName] = argValue
return args
Binary file added syncplay/resources/memento.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading