aboutsummaryrefslogtreecommitdiff
path: root/emms-player-xine.el
diff options
context:
space:
mode:
authorTassilo Horn <tassilo@member.fsf.org>2007-01-08 20:59:00 +0000
committerTassilo Horn <tassilo@member.fsf.org>2007-01-08 20:59:00 +0000
commitffa6c3be8a1eebfd9ef04015cd1ef688d7258953 (patch)
treeb149721f384abbfb23bcb1cca6cfc8b3a572f635 /emms-player-xine.el
parent921bc18f85725299a0ccdef54e6cda3d33afb747 (diff)
relative-seeking-for-xine.dpatch
darcs-hash:20070108205923-c06f4-43ce67680b8401a113b4388046ef64028a2f9646.gz
Diffstat (limited to 'emms-player-xine.el')
-rw-r--r--emms-player-xine.el57
1 files changed, 34 insertions, 23 deletions
diff --git a/emms-player-xine.el b/emms-player-xine.el
index b9be937..266c0bb 100644
--- a/emms-player-xine.el
+++ b/emms-player-xine.el
@@ -27,9 +27,10 @@
;;; Code:
-;; TODO: The video window cannot be disabled and I dunno how seeking works with
-;; xine's stdin control. I asked on gmane.comp.video.xine.user
-;; (<87y7ohqcbq.fsf@baldur.tsdh.de>)...
+;; TODO: The video window cannot be disabled. I asked on
+;; gmane.comp.video.xine.user (<87y7ohqcbq.fsf@baldur.tsdh.de>)...
+
+;; TODO: Implement seek-to with "SetPositionX%\n" where X is in {0,10,..,90}
(require 'emms-player-simple)
@@ -48,32 +49,42 @@
'resume
nil)
-;; TODO: Find out how seeking works.
-;; (emms-player-set emms-player-xine
-;; 'seek
-;; 'emms-player-xine-seek)
-
-;; (emms-player-set emms-player-xine
-;; 'seek-to
-;; 'emms-player-xine-seek-to)
+(emms-player-set emms-player-xine
+ 'seek
+ 'emms-player-xine-seek)
(defun emms-player-xine-pause ()
"Depends on xine's --stdctl mode."
(process-send-string
emms-player-simple-process-name "pause\n"))
-;; TODO: Find out how seeking works.
-;; (defun emms-player-xine-seek (sec)
-;; "Depends on xine's --stdctl mode."
-;; (process-send-string
-;; emms-player-simple-process-name
-;; (format "seek %d\n" sec)))
-
-;; (defun emms-player-xine-seek-to (sec)
-;; "Depends on xine's --stdctl mode."
-;; (process-send-string
-;; emms-player-simple-process-name
-;; (format "seek %d 2\n" sec)))
+(defun emms-player-xine-seek (secs)
+ "Depends on xine's --stdctl mode."
+ ;; xine-ui's stdctl supports only seeking forward/backward in 7/15/30 and 60
+ ;; second steps, so we take the value that is nearest to SECS.
+ (let ((s (emms-nearest-value secs '(-60 -30 -15 -7 7 15 30 60))))
+ (when (/= s secs)
+ (message (concat "EMMS: Xine only supports seeking for [+/-] 7/15/30/60 "
+ "seconds, so we seeked %d seconds") s))
+ (process-send-string
+ emms-player-simple-process-name
+ (if (< s 0)
+ (format "SeekRelative%d\n" s)
+ (format "SeekRelative+%d\n" s)))))
+
+(defun emms-nearest-value (val list)
+ "Returns the value of LIST which is nearest to VAL.
+
+LIST should be a list of integers."
+ (let* ((nearest (car list))
+ (dist (abs (- val nearest))))
+ (dolist (lval (cdr list))
+ (let ((ndist (abs (- val lval))))
+ (when (< ndist dist)
+ (setq nearest lval
+ dist ndist))))
+ nearest))
+
(provide 'emms-player-xine)
;;; emms-player-xine.el ends here