X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=elisp.git;a=blobdiff_plain;f=media.el;h=ebddca7cf077568d03a8daab70d8f61801e3321a;hp=299ccba2e474487851ca88ed5765b545e85a55d7;hb=b01b564e2f6c23ab0b5440c7473c724901c600f5;hpb=6c647377c97541756bf9d9d7e350a156078ba997 diff --git a/media.el b/media.el index 299ccba..ebddca7 100644 --- a/media.el +++ b/media.el @@ -53,7 +53,7 @@ (defgroup media () "Major mode to control media players" - :version "1.2.1") + :version "1.2.2") (defcustom media/player-api "media-mplayer" "The file to load for the abstract layer with the media player." @@ -103,6 +103,11 @@ title to display in the list (convenient for internet radios)." :type 'boolean :group 'media) +(defcustom media/continue-mode-hint "*" + "What to append to the MPlayer string when in repeat mode" + :type 'string + :group 'media) + (defcustom media/expert nil "Should the keymap help be shown?" :type 'boolean @@ -247,6 +252,10 @@ parsed from the stream.") ;; Finding and playing URLs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defun media/reset-current-information () + (setq media/current-information nil + media/current-song-in-stream nil)) + (defun media/format-url (url) (if (string-match "^file:.*/\\([^/]+\\)$" url) (match-string 1 url) @@ -258,8 +267,7 @@ parsed from the stream.") (time (get-text-property position 'time))) (if (not url) (media/remove-highlight) (run-hook-with-args 'media/before-play-hook url) - (setq media/current-information nil - media/current-song-in-stream nil) + (media/reset-current-information) (media/api/play url) ;; We keep the information of the url and the title (setq media/played-information (cons url (get-text-property position 'title))) @@ -617,9 +625,11 @@ returns nil if no id3 tags could be found." (title (or (and (consp c) (cdr c)) url))) (if (string-match "^\\(http\\|mms\\)://" url) (media/insert-url (cons url title) 0) - (if (file-regular-p url) (media/insert-file url 0) - (if (file-directory-p url) (media/insert-dir url 0) - (error "Unknown type `%s'" url)))))) + (if (file-exists-p url) + (if (file-regular-p url) (media/insert-file url 0) + (if (file-directory-p url) (media/insert-dir url 0) + (error "Unknown type `%s'" url)))) + ))) list)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -827,8 +837,7 @@ returns nil if no id3 tags could be found." (defun media/stop () (interactive) (message "Stop") - (setq media/current-information nil - media/current-song-in-stream nil) + (media/reset-current-information) (media/api/stop)) (defun media/queue-song-at-point () @@ -878,15 +887,13 @@ the 'Queue' playlist, and plays it if no song is currently playing." (defun media/player-error () (message "Player error") - (setq media/current-information nil - media/current-song-in-stream nil) + (media/reset-current-information) (media/remove-highlight)) (defun media/song-terminates () (with-current-buffer media/buffer (if media/continue-mode (media/play-next t) - (setq media/current-information nil - media/current-song-in-stream nil) + (media/reset-current-information) (media/remove-highlight)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -914,7 +921,7 @@ which stops when the songs ends." (concat " " media/player-id - (if media/continue-mode "*") + (if media/continue-mode media/continue-mode-hint) " " (if media/current-information @@ -939,7 +946,8 @@ which stops when the songs ends." (or (and (string= (car media/played-information) (nth 0 media/current-information)) (cdr media/played-information)) (replace-regexp-in-string "^.*/\\([^/]*\\)$" "\\1" (nth 0 media/current-information))) - (if media/current-song-in-stream (concat "[" media/current-song-in-stream "] ") "") + ;; (if media/current-song-in-stream (concat "[" media/current-song-in-stream "] ") "") + (if media/current-song-in-stream (concat "| " media/current-song-in-stream " ") "") (nth 1 media/current-information) (if (= 2 (nth 2 media/current-information)) "stereo" "mono") (nth 3 media/current-information))