[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emms-patches] [PATCH] let emms-player-mpd support single track repe
From: |
S . P . Tseng |
Subject: |
Re: [Emms-patches] [PATCH] let emms-player-mpd support single track repeat. |
Date: |
Tue, 01 Sep 2009 11:53:50 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) |
Michael Olson <address@hidden> writes:
> That doesn't belong in emms.el, because we do not want mentions of
> emms-player-mpd there. It's supposed to be generic. So this most
> likely belongs in emms-player-mpd.el's start functions. If there's no
> way to get it there, make a new call to emms-player-get-player called
> 'pre-start, or something to that effect.
>
Other emms-player call emms-next-noerror when one track finish. This function
will check variable emms-repeat-track. But emms-player-mpd works in a different
way, mpd daemon auto play when one track finish, and the client should periodic
check the status. It can not use emms-repeat-track like other emms-player.
I add a hook for `emms-toggle-repeat-track'. It will keep generic. Use (= time
0) to check whether reset playing time.
Here is the new patch.
>From 34a82d5afb9d69798693a75324b753d73b347956 Mon Sep 17 00:00:00 2001
From: S.P.Tseng <address@hidden>
Date: Tue, 1 Sep 2009 11:42:37 +0800
Subject: [PATCH] emms-player-mpd: support repeat track mode.
---
lisp/emms-player-mpd.el | 12 +++++++++++-
lisp/emms.el | 6 ++++++
2 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/lisp/emms-player-mpd.el b/lisp/emms-player-mpd.el
index fa8f911..75cd6b5 100644
--- a/lisp/emms-player-mpd.el
+++ b/lisp/emms-player-mpd.el
@@ -694,7 +694,8 @@ main EMMS playlist buffer."
(setq emms-player-mpd-last-state "play")
(unless (or (null song)
(and (stringp emms-player-mpd-current-song)
- (string= song emms-player-mpd-current-song)))
+ (string= song emms-player-mpd-current-song)
+ (and emms-repeat-track (= time 0))))
(let ((emms-player-stopped-p t))
(emms-player-stopped))
(emms-player-mpd-select-song emms-player-mpd-current-song song)
@@ -1017,6 +1018,15 @@ from other functions."
(interactive)
(emms-player-mpd-send "previous" nil #'ignore))
+(defun emms-player-mpd-toggle-single ()
+ (when (eq (emms-player-for
+ (emms-playlist-current-selected-track)) 'emms-player-mpd)
+ (emms-player-mpd-send
+ (concat "single " (if emms-repeat-track "1" "0"))
+ nil #'ignore)))
+
+(add-hook 'emms-toggle-repeat-track-hooks 'emms-player-mpd-toggle-single)
+
;;; Volume
(defun emms-volume-mpd-change (amount)
diff --git a/lisp/emms.el b/lisp/emms.el
index 3c5402d..b693a73 100644
--- a/lisp/emms.el
+++ b/lisp/emms.el
@@ -238,6 +238,11 @@ Use `emms-player-paused-p' to find the current state."
:group 'emms
:type 'hook)
+(defcustom emms-toggle-repeat-track-hooks nil
+ "*Hook run when repeat track toggle."
+ :group 'emms
+ :type 'hook)
+
(defcustom emms-seek-seconds 10
"The number of seconds to seek forward or backward when seeking.
This is a number in seconds."
@@ -501,6 +506,7 @@ See `emms-repeat-playlist'."
See `emms-repeat-track'."
(interactive)
(setq emms-repeat-track (not emms-repeat-track))
+ (run-hooks 'emms-toggle-repeat-track-hooks)
(if emms-repeat-track
(message "Will repeat the current track.")
(message "Will advance to the next track after this one.")))
--
1.6.4.2