make .command() behave the same way for mplayer and mpv

This commit is contained in:
Damien Elmes 2020-01-22 14:11:25 +10:00
parent be3393fcb4
commit 6af7933084

View file

@ -390,15 +390,16 @@ class SimpleMplayerSlaveModePlayer(SimpleMplayerPlayer):
) )
self._wait_for_termination() self._wait_for_termination()
def command(self, text: str) -> None: def command(self, *args) -> None:
"""Send a command over the slave interface. """Send a command over the slave interface.
The trailing newline is automatically added.""" The trailing newline is automatically added."""
self._process.stdin.write(text.encode("utf8") + b"\n") str_args = [str(x) for x in args]
self._process.stdin.write(" ".join(str_args).encode("utf8") + b"\n")
self._process.stdin.flush() self._process.stdin.flush()
def seek_relative(self, secs: int) -> None: def seek_relative(self, secs: int) -> None:
self.command(f"seek {secs} 0") self.command("seek", secs, 0)
def toggle_pause(self): def toggle_pause(self):
self.command("pause") self.command("pause")