Last active
December 19, 2015 04:09
-
-
Save kuanyui/5895133 to your computer and use it in GitHub Desktop.
dired-add-to-smplayer-playlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun dired-add-to-smplayer-playlist () | |
"Add a multimedia file or all multimedia files under a directory into SMPlayer's playlist via Dired." | |
(interactive) | |
(require 'cl) | |
(let* (PATTERN FILE full-path-FILE n) | |
(setq PATTERN "\\(\\.mp4\\|\\.flv\\|\\.rmvb\\|\\.mkv\\|\\.avi\\|\\.rm\\|\\.mp3\\|\\.wav\\|\\.wma\\|\\.m4a\\|\\.mpeg\\|\\.aac\\|\\.ogg\\|\\.flac\\|\\.ape\\|\\.mp2\\|\\.wmv\\)$") | |
(setq FILE (dired-get-filename nil t)) | |
(setq n 0) | |
(if (file-directory-p FILE) ;if it's a dir. | |
(progn | |
(setq full-path-FILE (cl-loop for i in (directory-files FILE nil PATTERN) | |
collect (concat FILE "/" i))) | |
(message "Opening %s files..." (list-length full-path-FILE)) | |
(cl-loop for i in full-path-FILE | |
do (call-process "smplayer" nil 0 nil "-add-to-playlist" i) | |
(sit-for 0.1)) ;Or playlist will be not in order. | |
(dired-next-line 1) | |
) | |
(if (string-match PATTERN FILE) ;if it's a file | |
(progn | |
(call-process "smplayer" nil 0 nil "-add-to-playlist" FILE) | |
(dired-next-line 1)) | |
(progn | |
(message "This is not a supported audio or video file.") | |
(dired-next-line 1)))))) | |
(define-key dired-mode-map (kbd "M-a") 'dired-add-to-smplayer-playlist) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment