aboutsummaryrefslogtreecommitdiff
path: root/emms.el
diff options
context:
space:
mode:
authoryoni-r <yoni-r>2006-09-22 08:55:00 +0000
committeryoni-r <mwolson@gnu.org>2006-09-22 08:55:00 +0000
commit876bc87c3b24ee8dea7fe697d1b0f127ed16621b (patch)
treea84a899a01a8798e7dede12a80288d571ecec77e /emms.el
parentf71dc5daf9eec2626f49250c2c703a5d6993696e (diff)
Added `seek-to' to emms.el and emms-player-mplayer.el.
darcs-hash:20060922085513-85c19-7ae430e7e6945666cef8fce5ba13d82bd669e0c8.gz
Diffstat (limited to 'emms.el')
-rw-r--r--emms.el27
1 files changed, 27 insertions, 0 deletions
diff --git a/emms.el b/emms.el
index 2ff6fd6..4e567d2 100644
--- a/emms.el
+++ b/emms.el
@@ -219,6 +219,13 @@ seconds the player did seek."
:group 'emms
:type 'hook)
+(defcustom emms-player-seeked-to-functions nil
+ "*Functions called when a player is seeking.
+The functions are called with a single argument, the amount of
+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
@@ -331,6 +338,14 @@ It can also be negative to seek backwards."
(emms-ensure-player-playing-p)
(emms-player-seek seconds))
+(defun emms-seek-to (seconds)
+ "Seek the current player to SECONDS seconds.
+This can be a floating point number for sub-second fractions.
+It can also be negative to seek backwards."
+ (interactive "nSeconds to seek to: ")
+ (emms-ensure-player-playing-p)
+ (emms-player-seek-to seconds))
+
(defun emms-seek-forward ()
"Seek ten seconds forward."
(interactive)
@@ -1324,6 +1339,18 @@ or negative to seek backwards."
(funcall seek seconds)
(run-hook-with-args 'emms-player-seeked-functions seconds)))))
+(defun emms-player-seek-to (seconds)
+ "Seek the current player to SECONDS seconds.
+This can be a floating point number for fractions of a second,
+or negative to seek backwards."
+ (if (not emms-player-playing-p)
+ (error "Can't seek-to player, nothing playing right now")
+ (let ((seek (emms-player-get emms-player-playing-p 'seek-to)))
+ (if (not seek)
+ (error "Player does not know how to seek-to")
+ (funcall seek seconds)
+ (run-hook-with-args 'emms-player-seeked-to-functions seconds)))))
+
;;; Dictionaries