aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emms-lyrics.el12
-rw-r--r--emms-player-mpd.el2
-rw-r--r--emms-player-mpg321-remote.el4
-rw-r--r--emms-playing-time.el12
-rw-r--r--emms.el7
5 files changed, 30 insertions, 7 deletions
diff --git a/emms-lyrics.el b/emms-lyrics.el
index be28b2f..3886c72 100644
--- a/emms-lyrics.el
+++ b/emms-lyrics.el
@@ -230,6 +230,12 @@ To find FILE, will look up in current directory and `emms-lyrics-dir'."
(setq emms-player-paused-p paused-orig))
(emms-lyrics-set-timer)))
+(defun emms-lyrics-sync (sec)
+ "Synchronize the lyric display at SEC seconds."
+ (setq emms-lyrics-start-time (current-time)
+ emms-lyrics-elapsed-time 0)
+ (emms-lyrics-seek sec))
+
(defun emms-lyrics-toggle-display-on-minibuffer ()
"Toggle display lyrics on minibbufer."
(interactive)
@@ -261,7 +267,8 @@ To find FILE, will look up in current directory and `emms-lyrics-dir'."
(add-hook 'emms-player-stopped-hook 'emms-lyrics-stop)
(add-hook 'emms-player-finished-hook 'emms-lyrics-stop)
(add-hook 'emms-player-paused-hook 'emms-lyrics-pause)
- (add-hook 'emms-player-seeked-functions 'emms-lyrics-seek))
+ (add-hook 'emms-player-seeked-functions 'emms-lyrics-seek)
+ (add-hook 'emms-player-time-set-functions 'emms-lyrics-sync))
(emms-lyrics-stop)
(setq emms-lyrics-display-p nil)
(emms-lyrics-restore-mode-line)
@@ -269,7 +276,8 @@ To find FILE, will look up in current directory and `emms-lyrics-dir'."
(remove-hook 'emms-player-stopped-hook 'emms-lyrics-stop)
(remove-hook 'emms-player-finished-hook 'emms-lyrics-stop)
(remove-hook 'emms-player-paused-hook 'emms-lyrics-pause)
- (remove-hook 'emms-player-seeked-functions 'emms-lyrics-seek)))
+ (remove-hook 'emms-player-seeked-functions 'emms-lyrics-seek)
+ (remove-hook 'emms-player-time-set-functions 'emms-lyrics-sync)))
;;;###autoload
(defun emms-lyrics-enable ()
diff --git a/emms-player-mpd.el b/emms-player-mpd.el
index 0ab8b8b..650a9b1 100644
--- a/emms-player-mpd.el
+++ b/emms-player-mpd.el
@@ -675,7 +675,7 @@ MusicPD playlist."
(point))))
(emms-player-started 'emms-player-mpd)
(when time
- (run-hook-with-args 'emms-player-seeked-functions time)))))))
+ (run-hook-with-args 'emms-player-time-set-functions time)))))))
(defun emms-player-mpd-detect-song-change (&optional info)
"Detect whether a song change has occurred.
diff --git a/emms-player-mpg321-remote.el b/emms-player-mpg321-remote.el
index be5f63f..f97a0d8 100644
--- a/emms-player-mpg321-remote.el
+++ b/emms-player-mpg321-remote.el
@@ -159,8 +159,8 @@ For example: (list \"-o\" \"alsa\")"
((string= cmd "@F")
;; even though a timer is constantly updating this variable,
;; updating it here will cause it to stay pretty much in sync.
- (setq emms-playing-time
- (truncate (string-to-number (nth 3 data)))))))))
+ (run-hook-with-args 'emms-player-time-set-functions
+ (truncate (string-to-number (nth 3 data)))))))))
(defun emms-player-mpg321-remote-start-playing (track)
"Start playing a song by telling the remote process to play it.
diff --git a/emms-playing-time.el b/emms-playing-time.el
index 659e391..3176dcf 100644
--- a/emms-playing-time.el
+++ b/emms-playing-time.el
@@ -103,6 +103,12 @@ should enable `emms-playing-time-display-p' first, though."
(when (< emms-playing-time 0) ; back to start point
(setq emms-playing-time 0)))
+(defun emms-playing-time-set (sec)
+ "Set the playing time to SEC."
+ (setq emms-playing-time sec)
+ (when (< emms-playing-time 0) ; back to start point
+ (setq emms-playing-time 0)))
+
(defun emms-playing-time (arg)
"Turn on emms playing time if ARG is positive, off otherwise."
(interactive "p")
@@ -114,7 +120,8 @@ should enable `emms-playing-time-display-p' first, though."
(add-hook 'emms-player-stopped-hook 'emms-playing-time-stop)
(add-hook 'emms-player-finished-hook 'emms-playing-time-stop)
(add-hook 'emms-player-paused-hook 'emms-playing-time-pause)
- (add-hook 'emms-player-seeked-functions 'emms-playing-time-seek))
+ (add-hook 'emms-player-seeked-functions 'emms-playing-time-seek)
+ (add-hook 'emms-player-time-set-functions 'emms-playing-time-set))
(setq emms-playing-time-display-p nil)
(emms-playing-time-stop)
(emms-playing-time-restore-mode-line)
@@ -122,7 +129,8 @@ should enable `emms-playing-time-display-p' first, though."
(remove-hook 'emms-player-stopped-hook 'emms-playing-time-stop)
(remove-hook 'emms-player-finished-hook 'emms-playing-time-stop)
(remove-hook 'emms-player-paused-hook 'emms-playing-time-pause)
- (remove-hook 'emms-player-seeked-functions 'emms-playing-time-seek)))
+ (remove-hook 'emms-player-seeked-functions 'emms-playing-time-seek)
+ (remove-hook 'emms-player-time-set-functions 'emms-playing-time-set)))
;;;###autoload
(defun emms-playing-time-enable ()
diff --git a/emms.el b/emms.el
index 0bcc686..80dc3a1 100644
--- a/emms.el
+++ b/emms.el
@@ -214,6 +214,13 @@ seconds the player did seek."
:group 'emms
:type 'hook)
+(defcustom emms-player-time-set-functions nil
+ "*Functions called when a player is setting the elapsed time of a track.
+The functions are called with a single argument, the time elapsed
+since the beginning of the current track."
+ :group 'emms
+ :type 'hook)
+
(defcustom emms-cache-get-function nil
"A function to retrieve a track entry from the cache.
This is called with two arguments, the type and the name."