aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjohn muhl2024-09-28 19:11:03 -0500
committerStefan Monnier2024-10-19 22:30:09 -0400
commit08f3bc1b8e6a3583c8ccda02a7cf1b59c8d3f514 (patch)
treefd0d282ea5f9e8224422c529b14f3f3e114cd3c5
parentde0800c511740de7ad4dcb7dda0a0083a094d749 (diff)
downloademacs-08f3bc1b8e6a3583c8ccda02a7cf1b59c8d3f514.tar.gz
emacs-08f3bc1b8e6a3583c8ccda02a7cf1b59c8d3f514.zip
Add ability to crossfade between songs in 'mpc'
* lisp/mpc.el (mpc-cmd-crossfade): (mpc-toggle-crossfade): New function. (mpc-crossfade-time): New option. (mpc-mode-menu): Add menu item to toggle crossfade. (Bug#73891)
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/mpc.el18
2 files changed, 23 insertions, 0 deletions
diff --git a/etc/NEWS b/etc/NEWS
index a889528ab6a..cfc5a8e1785 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -582,6 +582,11 @@ a desktop notification when the song changes, using
582customized using the new user options 'mpc-notifications-title' and 582customized using the new user options 'mpc-notifications-title' and
583'mpc-notifications-body'. 583'mpc-notifications-body'.
584 584
585*** New user option 'mpc-crossfade-time'.
586When non-nil, MPC will crossfade between songs for the specified number
587of seconds. Crossfading can be toggled using the command
588'mpc-toggle-crossfade' or from the MPC menu.
589
585 590
586* New Modes and Packages in Emacs 31.1 591* New Modes and Packages in Emacs 31.1
587 592
diff --git a/lisp/mpc.el b/lisp/mpc.el
index 9905e3aa554..01876bf230b 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -883,6 +883,11 @@ If PLAYLIST is t or nil or missing, use the main playlist."
883(defun mpc-cmd-tagtypes () 883(defun mpc-cmd-tagtypes ()
884 (mapcar #'cdr (mpc-proc-cmd-to-alist "tagtypes"))) 884 (mapcar #'cdr (mpc-proc-cmd-to-alist "tagtypes")))
885 885
886(defun mpc-cmd-crossfade (&optional arg)
887 "Set duration of crossfade to `mpc-crossfade-time' or ARG seconds."
888 (mpc-proc-cmd (list "crossfade" (or arg mpc-crossfade-time))
889 #'mpc-status-refresh))
890
886;; This was never integrated into MPD. 891;; This was never integrated into MPD.
887;; (defun mpc-cmd-download (file) 892;; (defun mpc-cmd-download (file)
888;; (with-current-buffer (generate-new-buffer " *mpc download*") 893;; (with-current-buffer (generate-new-buffer " *mpc download*")
@@ -918,6 +923,11 @@ If PLAYLIST is t or nil or missing, use the main playlist."
918 "Directory where MPC.el stores auxiliary data." 923 "Directory where MPC.el stores auxiliary data."
919 :type 'directory) 924 :type 'directory)
920 925
926(defcustom mpc-crossfade-time 3
927 "Number of seconds to crossfade between songs."
928 :version "31.1"
929 :type 'natnum)
930
921(defun mpc-data-directory () 931(defun mpc-data-directory ()
922 (unless (file-directory-p mpc-data-directory) 932 (unless (file-directory-p mpc-data-directory)
923 (make-directory mpc-data-directory)) 933 (make-directory mpc-data-directory))
@@ -1188,6 +1198,8 @@ string POST."
1188 :selected (member '(single . "1") mpc-status)] 1198 :selected (member '(single . "1") mpc-status)]
1189 ["Consume Mode" mpc-toggle-consume :style toggle 1199 ["Consume Mode" mpc-toggle-consume :style toggle
1190 :selected (member '(consume . "1") mpc-status)] 1200 :selected (member '(consume . "1") mpc-status)]
1201 ["Crossfade Songs" mpc-toggle-crossfade :style toggle
1202 :selected (alist-get 'xfade mpc-status)]
1191 "--" 1203 "--"
1192 ["Add new browser" mpc-tagbrowser] 1204 ["Add new browser" mpc-tagbrowser]
1193 ["Update DB" mpc-update] 1205 ["Update DB" mpc-update]
@@ -2428,6 +2440,12 @@ This is used so that they can be compared with `eq', which is needed for
2428 (mpc-cmd-random 2440 (mpc-cmd-random
2429 (if (string= "0" (cdr (assq 'random (mpc-cmd-status)))) "1" "0"))) 2441 (if (string= "0" (cdr (assq 'random (mpc-cmd-status)))) "1" "0")))
2430 2442
2443(defun mpc-toggle-crossfade ()
2444 "Toggle crossfading between songs."
2445 (interactive)
2446 (mpc-cmd-crossfade
2447 (if (alist-get 'xfade mpc-status) "0" mpc-crossfade-time)))
2448
2431(defun mpc-stop () 2449(defun mpc-stop ()
2432 "Stop playing the current queue of songs." 2450 "Stop playing the current queue of songs."
2433 (interactive) 2451 (interactive)