diff options
author | Case Duckworth | 2022-01-29 19:33:54 -0600 |
---|---|---|
committer | Case Duckworth | 2022-01-29 19:33:54 -0600 |
commit | 301cd5df28052d307796d708b5911e1d8d5590da (patch) | |
tree | c78371a356d3bb38963d89c5211e1fc3f794999b /lisp | |
parent | Remove auto-insert (diff) | |
download | emacs-301cd5df28052d307796d708b5911e1d8d5590da.tar.gz emacs-301cd5df28052d307796d708b5911e1d8d5590da.zip |
Configure emms
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/+emms.el | 46 |
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 | ||