diff options
author | Mike Kazantsev <mk.fraggod@gmail.com> | 2021-10-19 22:39:57 +0500 |
---|---|---|
committer | fraggod@malediction <mk.fraggod@gmail.com> | 2021-10-19 22:51:21 +0500 |
commit | ea6728d31c2dabb5c8c5e2cb6652fd6da2127384 (patch) | |
tree | f37f704a044ce28d1bb6ed579841045621e10076 | |
parent | 12f7d295a3add2362d80132144d9ca8ea026f64c (diff) |
* emms-player-mpv.el: update emms playback position and pause state from mpv pause/restart events
-rw-r--r-- | emms-player-mpv.el | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/emms-player-mpv.el b/emms-player-mpv.el index 53b25b4..7bf8a8c 100644 --- a/emms-player-mpv.el +++ b/emms-player-mpv.el @@ -60,6 +60,7 @@ (require 'emms) (require 'emms-player-simple) +(require 'emms-playing-time) (require 'json) (require 'cl-lib) @@ -655,6 +656,12 @@ potential duplication if used for same properties from different functions." (emms-player-mpv-debug-msg "idle-check (stopped=%s)" emms-player-mpv-stopped) (unless emms-player-mpv-stopped (emms-player-stopped))) +(defun emms-player-mpv-event-playing-time-sync () + "Request and update `emms-playing-time' after playback seek/restart or unpause." + (emms-player-mpv-ipc-req-send '(get_property time-pos) + #'(lambda (pos err) + (unless err (emms-playing-time-set pos))))) + (defun emms-player-mpv-event-handler (json-data) "Handler for supported mpv events, including property changes. Called before `emms-player-mpv-event-functions' and does same thing as these hooks." @@ -665,7 +672,15 @@ Called before `emms-player-mpv-event-functions' and does same thing as these hoo ;; and don't correspond to actual playback state. (unless (emms-player-mpv-proc-playing-p) (emms-player-mpv-proc-playing t) - (emms-player-started emms-player-mpv))) + (emms-player-started emms-player-mpv)) + (emms-player-mpv-event-playing-time-sync)) + ("pause" + (setq emms-player-paused-p t) + (run-hooks 'emms-player-paused-hook)) + ("unpause" + (emms-player-mpv-event-playing-time-sync) + (setq emms-player-paused-p nil) + (run-hooks 'emms-player-paused-hook)) ("end-file" (when (emms-player-mpv-proc-playing-p) (emms-player-mpv-proc-playing nil) |