diff options
-rw-r--r-- | emms-player-mplayer.el | 10 | ||||
-rw-r--r-- | emms.el | 27 |
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 @@ -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 |