Hi all, thought I'd share a way to control
the volume of EMMS using MPV as a backend. I couldn't find any solutions on the net, and this took quite a bit of trial and error so hopefully this will save you some pain.
(defvar emms-player-mpv-volume 100)
(defun emms-player-mpv-get-volume ()
"Sets `emms-player-mpv-volume' to the current volume value
and sends a message of the current volume status."
(emms-player-mpv-cmd '(get_property volume)
#'(lambda (vol err)
(unless err
(let ((vol (truncate vol)))
(setq emms-player-mpv-volume vol)
(message "Music volume: %s%%"
vol))))))
(defun emms-player-mpv-raise-volume (&optional amount)
(interactive)
(let* ((amount (or amount 10))
(new-volume (+ emms-player-mpv-volume amount)))
(if (> new-volume 100)
(emms-player-mpv-cmd '(set_property volume 100))
(emms-player-mpv-cmd `(add volume ,amount))))
(emms-player-mpv-get-volume))
(defun emms-player-mpv-lower-volume (&optional amount)
(interactive)
(emms-player-mpv-cmd `(add volume ,(- (or amount '10))))
(emms-player-mpv-get-volume))
For reference my `emms-player-mpv-parameters` is set to `'("--quiet" "--really-quiet" "--no-audio-display" "--force-window=no" "--vo=null" "--no-resume-playback")`