aboutsummaryrefslogtreecommitdiff
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
parentf71dc5daf9eec2626f49250c2c703a5d6993696e (diff)
Added `seek-to' to emms.el and emms-player-mplayer.el.
darcs-hash:20060922085513-85c19-7ae430e7e6945666cef8fce5ba13d82bd669e0c8.gz
-rw-r--r--emms-player-mplayer.el10
-rw-r--r--emms.el27
2 files changed, 37 insertions, 0 deletions
diff --git a/emms-player-mplayer.el b/emms-player-mplayer.el
index 4976144..52dcf6b 100644
--- a/emms-player-mplayer.el
+++ b/emms-player-mplayer.el
@@ -53,6 +53,10 @@
'seek
'emms-player-mplayer-seek)
+(emms-player-set emms-player-mplayer
+ 'seek-to
+ 'emms-player-mplayer-seek-to)
+
(defun emms-player-mplayer-pause ()
"Depends on mplayer's -slave mode."
(process-send-string
@@ -64,5 +68,11 @@
emms-player-simple-process-name
(format "seek %d\n" sec)))
+(defun emms-player-mplayer-seek-to (sec)
+ "Depends on mplayer's -slave mode."
+ (process-send-string
+ emms-player-simple-process-name
+ (format "seek %d 2\n" sec)))
+
(provide 'emms-player-mplayer)
;;; emms-player-mplayer.el ends here
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