continue
return resp
- def runcmd(self, cmd):
- self.send(json.dumps(cmd).encode("utf-8") + b"\n")
+ def runcmd(self, *cmd):
+ self.send(json.dumps({"command": cmd}).encode("utf-8") + b"\n")
resp = self.getresp()
if "error" not in resp:
sys.stderr.write("mpsync: strange response from %s: %r\n" % (self.path, resp))
return resp
def getprop(self, pname):
- return self.runcmd({"command": ["get_property", pname]})["data"]
+ return self.runcmd("get_property", pname)["data"]
def setprop(self, pname, val):
- self.runcmd({"command": ["set_property", pname, val]})
+ self.runcmd("set_property", pname, val)
def usage(out):
out.write("usage: mpsync [-h] SOCKET...\n")
targets.append(target(path))
def runcmd(*cmd):
- cmd = {"command": cmd}
for tgt in targets:
- tgt.runcmd(cmd)
+ tgt.runcmd(*cmd)
def simulcmd(*cmd):
cmd = json.dumps({"command": cmd}).encode("utf-8") + b"\n"
return ret
def main(tty):
- paused = targets[0].getprop("pause")
runcmd("set_property", "hr-seek", "yes")
+ paused = targets[0].getprop("pause")
+ mutemode = 0
offsets = [0.0] * len(targets)
while True:
c, mods = tty.readkey()
relseek(5, offsets)
elif c == rawtty.K_DOWN and mods == {rawtty.MOD_SHIFT}:
relseek(-5, offsets)
+ elif c == 's':
+ relseek(0, offsets)
+ elif c == 'm':
+ mutemode = (mutemode + 1) % 3
+ if mutemode == 0:
+ for tgt in targets:
+ tgt.setprop("mute", False)
+ elif mutemode == 1:
+ for i, tgt in enumerate(targets):
+ tgt.setprop("mute", i != 0)
+ elif mutemode == 2:
+ for tgt in targets:
+ tgt.setprop("mute", True)
+ targets[0].runcmd("show_text", "Audio mode: %s" % ["All", "One", "None"][mutemode])
elif c == 'S':
offsets = getoffsets()
- print(offsets)
+ for tgt, off in zip(targets, offsets):
+ tgt.runcmd("show_text", "Offset: %f" % off)
elif c == '.':
runcmd("frame_step")
paused = True