Configure emms

This commit is contained in:
Case Duckworth 2022-01-29 19:33:54 -06:00
parent 726d90d708
commit 301cd5df28
2 changed files with 48 additions and 2 deletions

View File

@ -1156,10 +1156,10 @@ See also `crux-reopen-as-root-mode'."
(add-hook 'embark-collect-mode-hook #'consult-preview-at-point-mode))
(setup (:straight emms)
(:also-load +emms)
;; TODO: Definitely need to do more customization here
(:option emms-source-file-default-directory "~/var/music/"
emms-player-mpv-update-metadata t
emms-player-mpv-ipc-method 'file)
emms-player-mpv-update-metadata t)
(require 'emms-setup)
(emms-all)
(emms-default-players)

46
lisp/+emms.el Normal file
View File

@ -0,0 +1,46 @@
;;; +emms.el --- EMMS customizations -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:
(require 'emms-player-mpv)
(require 'el-patch)
;; https://lists.gnu.org/archive/html/emms-help/2022-01/msg00006.html
(el-patch-feature emms-player-mpv)
(with-eval-after-load 'emms-player-mpv
(el-patch-defun emms-player-mpv-start (track)
(setq emms-player-mpv-stopped nil)
(emms-player-mpv-proc-playing nil)
(let
((track-name (emms-track-get track 'name))
(track-is-playlist (memq (emms-track-get track 'type)
'(streamlist playlist))))
(if (emms-player-mpv-ipc-fifo-p)
(progn
;; ipc-stop is to clear any buffered commands
(emms-player-mpv-ipc-stop)
(emms-player-mpv-proc-init (if track-is-playlist "--playlist" "--")
track-name)
(emms-player-started emms-player-mpv))
(let*
((play-cmd
`(batch
((,(el-patch-swap
(if track-is-playlist 'loadlist 'loadfile)
'loadfile)
,track-name replace))
((set pause no))))
(start-func
;; Try running play-cmd and retry it on connection failure, e.g. if mpv died
(apply-partially 'emms-player-mpv-cmd play-cmd
(lambda (_mpv-data mpv-error)
(when (eq mpv-error 'connection-error)
(emms-player-mpv-cmd play-cmd))))))
(if emms-player-mpv-ipc-stop-command
(setq emms-player-mpv-ipc-stop-command start-func)
(funcall start-func)))))))
(provide '+emms)
;;; +emms.el ends here