about summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+emms.el46
1 files changed, 46 insertions, 0 deletions
diff --git a/lisp/+emms.el b/lisp/+emms.el new file mode 100644 index 0000000..403cbff --- /dev/null +++ b/lisp/+emms.el
@@ -0,0 +1,46 @@
1;;; +emms.el --- EMMS customizations -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;;; Code:
6
7(require 'emms-player-mpv)
8(require 'el-patch)
9
10;; https://lists.gnu.org/archive/html/emms-help/2022-01/msg00006.html
11(el-patch-feature emms-player-mpv)
12(with-eval-after-load 'emms-player-mpv
13 (el-patch-defun emms-player-mpv-start (track)
14 (setq emms-player-mpv-stopped nil)
15 (emms-player-mpv-proc-playing nil)
16 (let
17 ((track-name (emms-track-get track 'name))
18 (track-is-playlist (memq (emms-track-get track 'type)
19 '(streamlist playlist))))
20 (if (emms-player-mpv-ipc-fifo-p)
21 (progn
22 ;; ipc-stop is to clear any buffered commands
23 (emms-player-mpv-ipc-stop)
24 (emms-player-mpv-proc-init (if track-is-playlist "--playlist" "--")
25 track-name)
26 (emms-player-started emms-player-mpv))
27 (let*
28 ((play-cmd
29 `(batch
30 ((,(el-patch-swap
31 (if track-is-playlist 'loadlist 'loadfile)
32 'loadfile)
33 ,track-name replace))
34 ((set pause no))))
35 (start-func
36 ;; Try running play-cmd and retry it on connection failure, e.g. if mpv died
37 (apply-partially 'emms-player-mpv-cmd play-cmd
38 (lambda (_mpv-data mpv-error)
39 (when (eq mpv-error 'connection-error)
40 (emms-player-mpv-cmd play-cmd))))))
41 (if emms-player-mpv-ipc-stop-command
42 (setq emms-player-mpv-ipc-stop-command start-func)
43 (funcall start-func)))))))
44
45(provide '+emms)
46;;; +emms.el ends here