Merge pull request #671 from kelciour/mpv-changes

A few mpv changes
This commit is contained in:
Damien Elmes 2020-06-22 12:12:58 +10:00 committed by GitHub
commit f24321dc65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

View file

@ -39,6 +39,7 @@ Sander Santema <github.com/sandersantema/>
Thomas Brownback <https://github.com/brownbat/>
Andrew Gaul <andrew@gaul.org>
kenden
Nickolay Yudin <kelciour@gmail.com>
********************

View file

@ -84,6 +84,7 @@ class MPVBase:
"--ontop",
"--audio-display=no",
"--keep-open=no",
"--reset-on-next-file=pause",
]
def __init__(self, window_id=None, debug=False):

View file

@ -333,11 +333,20 @@ class MpvManager(MPV, SoundOrVideoPlayer):
self._on_done: Optional[OnDoneCallback] = None
self.default_argv += ["--config-dir=" + base_path]
super().__init__(window_id=None, debug=False)
self.init()
def init(self) -> None:
self.command("keybind", "q", "stop")
self.command("keybind", "Q", "stop")
self.command("keybind", "CLOSE_WIN", "stop")
self.command("keybind", "ctrl+w", "stop")
self.command("keybind", "ctrl+c", "stop")
def play(self, tag: AVTag, on_done: OnDoneCallback) -> None:
assert isinstance(tag, SoundOrVideoTag)
self._on_done = on_done
path = os.path.join(os.getcwd(), tag.filename)
self.command("script-message", "osc-visibility", "never", "no-osd")
self.command("loadfile", path, "append-play")
gui_hooks.av_player_did_begin_playing(self, tag)
@ -350,10 +359,13 @@ class MpvManager(MPV, SoundOrVideoPlayer):
def seek_relative(self, secs: int) -> None:
self.command("seek", secs, "relative")
def on_idle(self) -> None:
if self._on_done:
def on_property_idle_active(self, val) -> None:
if val and self._on_done:
self._on_done()
def on_start_file(self) -> None:
self.command("script-message", "osc-visibility", "auto", "no-osd")
def shutdown(self) -> None:
self.close()