emms-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Idea on volume adjusting


From: funk443
Subject: Idea on volume adjusting
Date: Tue, 31 Jan 2023 23:29:55 +0100 (CET)

  Currently volume adjustment of EMMS can only adjust master volume, which will bring some inconvenience while someone was trying to have some music via EMMS in the background while doing other stuffs that also plays sound (e.g. playing games, talking to others...).
  So I wrote some functions to adjust the volume of MPV player only, and please correct me if I am doing something wrong.




(require 'emms-player-mpv)

(defvar emms-volume--mpv)

(defun emms-volume--mpv-get-volume ()
  (emms-player-mpv-cmd '(get_property volume)
                       (lambda (vol err)
                         (setq emms-volume--mpv (truncate vol)))))

(defun emms-volume-mpv-change (amount)
  (let* ((cur-vol emms-volume--mpv)
         (new-vol (+ amount cur-vol)))
    (cond ((> new-vol 100)
           (setq new-vol 100))
          ((< new-vol 0)
           (setq new-vol 0))
          (t nil))
    (setq emms-volume--mpv new-vol)
    (emms-player-mpv-cmd `(set_property volume ,new-vol))
    (message (format "Volume: %s" new-vol))))

(provide 'emms-volume-mpv)




-----
Sent via Tutanota
https://tutanota.com

reply via email to

[Prev in Thread] Current Thread [Next in Thread]