aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Xu <william.xwl@gmail.com>2007-05-15 05:35:00 +0000
committerWilliam Xu <william.xwl@gmail.com>2007-05-15 05:35:00 +0000
commitfdf11ef9e071f2743f7417d3da91cb4cf33d39d3 (patch)
tree448d35ba47e0eb216bef7453bcc04828c6c8c293
parent0294df91c5a8a7129fe4e4b76fe4a9aafc0caf22 (diff)
emms-player-mplayer.el:
(emms-player-mplayer-start-with-subscript-checker): New function. Now mplayer could prompt you to select subscripts when possible. To use, just make it override `emms-player-mplayer-start'. darcs-hash:20070515053552-cfa61-8cc4323446da6396b77eae6f3a5bbbecdd23e143.gz
-rw-r--r--emms-player-mplayer.el38
1 files changed, 38 insertions, 0 deletions
diff --git a/emms-player-mplayer.el b/emms-player-mplayer.el
index 1752ea5..12f553d 100644
--- a/emms-player-mplayer.el
+++ b/emms-player-mplayer.el
@@ -74,5 +74,43 @@
emms-player-simple-process-name
(format "seek %d 2\n" sec)))
+(defun emms-player-mplayer-subscript-checker ()
+ (let* ((track (emms-playlist-current-selected-track))
+ (name (emms-track-name track))
+ (ext (file-name-extension name))
+ (sub (replace-regexp-in-string (concat ext "$") "sub" name))
+ ;; TODO, script for chinese, gb, big, etc.
+ (srt (replace-regexp-in-string (concat ext "$") "srt" name))
+ (choices (remove-if-not 'file-exists-p (list sub srt)))
+ (subscript nil))
+ (cond ((> (length choices) 1)
+ (setq subscript
+ (ido-completing-read "Select subscripts: "
+ choices)))
+ ((= (length choices) 1)
+ (setq subscript (car choices))))
+ (when subscript
+ (setq emms-player-mplayer-parameters
+ (append emms-player-mplayer-parameters
+ (list "-sub" subscript))))))
+
+(defun emms-player-mplayer-start-with-subscript-checker (track)
+ "Start the player process by checking possible subscripts
+additionally."
+ (let ((emms-player-mplayer-parameters emms-player-mplayer-parameters))
+ (emms-player-mplayer-subscript-checker)
+ (emms-player-simple-start (emms-track-name track)
+ emms-player-mplayer
+ emms-player-mplayer-command-name
+ emms-player-mplayer-parameters)))
+
+;; Uncomment me if you want to use
+;; `emms-player-mplayer-start-with-subscript-checker'. We need to
+;; redefine `emms-player-mplayer-start', since i can't figure out an
+;; easy way to achieve this by modifying the emms source. (xwl)
+;;
+;; (defalias 'emms-player-mplayer-start
+;; 'emms-player-mplayer-start-with-subscript-checker)
+
(provide 'emms-player-mplayer)
;;; emms-player-mplayer.el ends here