[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[emms-help] a workaround for pause, seek, etc.

From: William Xu
Subject: [emms-help] a workaround for pause, seek, etc.
Date: Thu, 14 Jul 2005 20:57:05 +0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

If you are like me, who rely on mplayer to play almost everything, then
this's good for you. :-)

I'd love emms someday would support pause, seek, repeat, etc, especially
pause, which I think is quite useful. Currently i found mplayer has a
'-slave' mode, with which to implement pause becomes quite easy. Hope
it'll be useful for some.

And, do you plan to add more user-level control functions? like repeat
current track, repeat all tracks ? These implementations would be quite 
straightforward. I've written some myself.



(setq emms-player-mplayer-command-name "mplayer"
      emms-player-mplayer-parameters '("-slave") ; slave mode
      emms-player-mpg321-command-name "mpg123"

;; mplayer: pause, seek
(defun my-emms-pause ()
  "Depends on mplayer's -slave mode."
  (if (equal emms-player-playing-p
       emms-player-simple-process-name "pause\n")
    (message "Pause is only available for mplayer.")))

(defun my-emms-seek (second)
  "Depends on mplayer's -slave mode."
  (if (equal emms-player-playing-p
       (concat "seek " second "\n"))
    (message "Seek is only available for mplayer.")))

;; repeat
(setq my-emms-repeat-curr-p nil)

; redefine this function
(defun emms-next-noerror ()
  "Start playing the next track in the EMMS playlist.
Unlike `emms-next', this function doesn't signal an error when called
at the end of the playlist.
This function should only be called when no player is playing.
This is a good function to put in `emms-player-finished-hook'."
  (when emms-player-playing-p
    (error "A track is already being played"))
  (cond (my-emms-repeat-curr-p          ; repeat current track only.
         (setq emms-playlist-current 0)
         (message "No next track in playlist"))))

(defun my-emms-repeat-curr ()
  (setq my-emms-repeat-curr-p t)
  (message "Repeat current track."))

(defun my-emms-unrepeat-curr ()
  (setq my-emms-repeat-curr-p nil)
  (message "Stop repeating current track."))

(setq emms-repeat-playlist nil)

(defun my-emms-repeat-all ()
  (setq my-emms-repeat-curr-p nil
        emms-repeat-playlist t)
  (message "Repeat all tracks."))

(defun my-emms-unrepeat-all ()
  (setq my-emms-repeat-curr-p nil
        emms-repeat-playlist nil)
  (message "Stop Repeating all tracks."))

;; keys
(global-set-key (kbd "C-c e SPC") 'my-emms-pause)
(global-set-key (kbd "C-c e r")   'my-emms-repeat-curr)
(global-set-key (kbd "C-c e R")   'my-emms-unrepeat-curr)

(global-set-key (kbd "C-c e <left>")  (lambda () (interactive) (my-emms-seek 
(global-set-key (kbd "C-c e <right>") (lambda () (interactive) (my-emms-seek 
(global-set-key (kbd "C-c e <up>")    (lambda () (interactive) (my-emms-seek 
(global-set-key (kbd "C-c e <down>")  (lambda () (interactive) (my-emms-seek 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]