emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/mpv a5c6eed9ac 44/50: Add volume control commands


From: ELPA Syncer
Subject: [nongnu] elpa/mpv a5c6eed9ac 44/50: Add volume control commands
Date: Tue, 28 Dec 2021 00:58:43 -0500 (EST)

branch: elpa/mpv
commit a5c6eed9acf2faf31e56b3ebe86b1b0405636d45
Author: c1-g <char1iegordon@protonmail.com>
Commit: Johann Klähn <johann@jklaehn.de>

    Add volume control commands
---
 README.md |  1 +
 mpv.el    | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/README.md b/README.md
index e9f581df94..cecebce604 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,7 @@ Among others, mpv.el provides
 - `mpv-kill`
 - `mpv-seek-forward` / `mpv-seek-backward`
 - `mpv-speed-increase` / `mpv-speed-decrease`
+- `mpv-volume-increase` / `mpv-speed-volume`
 - `mpv-insert-playback-position`
 - `mpv-seek-to-position-at-point`
 
diff --git a/mpv.el b/mpv.el
index 5348c92c83..d99d9ff206 100644
--- a/mpv.el
+++ b/mpv.el
@@ -63,6 +63,11 @@
   :type 'number
   :group 'mpv)
 
+(defcustom mpv-volume-step 1.50
+  "Scale factor used when adjusting volume."
+  :type 'number
+  :group 'mpv)
+
 (defcustom mpv-seek-step 5
   "Step size in seconds used when seeking."
   :type 'number
@@ -323,6 +328,28 @@ This can be used with the `org-open-at-point-functions' 
hook."
   (interactive "p")
   (mpv-speed-increase (- steps)))
 
+;;;###autoload
+(defun mpv-volume-set (factor)
+  "Set playback volume to FACTOR."
+  (interactive "nFactor: ")
+  (mpv--enqueue `("set" "volume" ,(abs factor)) #'ignore))
+
+;;;###autoload
+(defun mpv-volume-increase (steps)
+  "Increase playback volume by STEPS factors of `mpv-volume-step'."
+  (interactive "p")
+  (let ((factor (* (abs steps)
+                   (if (> steps 0)
+                       mpv-volume-step
+                     (/ 1 mpv-volume-step)))))
+    (mpv--enqueue `("multiply" "volume" ,factor) #'ignore)))
+
+;;;###autoload
+(defun mpv-volume-decrease (steps)
+  "Decrease playback volume by STEPS factors of `mpv-volume-step'."
+  (interactive "p")
+  (mpv-volume-increase (- steps)))
+
 (defun mpv--raw-prefix-to-seconds (arg)
   "Convert raw prefix argument ARG to seconds using `mpv-seek-step'.
 Numeric arguments will be treated as seconds, repeated use



reply via email to

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