Idea on volume adjusting

funk443--- via <[email protected]>
Newsgroups gmane.emacs.emms.user
Message-ID <[email protected]>
  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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.