[Top][All Lists]

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

[emms-help] make emms-player-start cycle players

From: Andrea Russo
Subject: [emms-help] make emms-player-start cycle players
Date: Fri, 16 Jun 2006 19:53:55 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)


This patch make emms-player-start a little more "fault tolerant" by
trying all suitable players for the specified track in
`emms-player-list' until one succeeds.

This can be useful when using emms customizations in different
machines where the set of available players can vary.

I prepared a Changelog entry just in case you want to merge in the
mainstream.  If necessary I'm willing to sign legal papers to assign
copyright to the FSF.

Hope this is useful.


2006-06-16  Andrea Russo  <address@hidden>

        * emms.el (emms-player-for): Returns a list of players that can
        play the passed track instead of returning the first one.
        (emms-player-start): Now it cycles through a list of players until
        one starts without errors.

--- old-emms2/emms.el   2006-06-16 19:43:25.000000000 +0200
+++ new-emms2/emms.el   2006-06-16 19:43:25.000000000 +0200
@@ -1218,27 +1218,33 @@
   "Return an EMMS player capable of playing TRACK.
 This will be the first player whose PLAYABLEP function returns non-nil,
 or nil if no such player exists."
-  (let ((lis emms-player-list))
-    (while (and lis
-                (not (funcall (emms-player-get (car lis) 'playablep)
-                              track)))
+  (let ((lis emms-player-list)
+       players)
+    (while lis
+      (if (funcall (emms-player-get (car lis) 'playablep)
+                  track)
+         (add-to-list 'players (car lis) t))
       (setq lis (cdr lis)))
-    (if lis
-        (car lis)
-      nil)))
+    players))
 (defun emms-player-start (track)
   "Start playing TRACK."
   (if emms-player-playing-p
       (error "A player is already playing")
-    (let ((player (emms-player-for track)))
-      (if (not player)
+    (let ((players (emms-player-for track)))
+      (if (not players)
           (error "Don't know how to play track: %S" track)
         ;; Change default-directory so we don't accidentally block any
         ;; directories the current buffer was visiting.
-        (let ((default-directory "/"))
-          (funcall (emms-player-get player 'start)
-                   track))))))
+       (let ((default-directory "/")
+             (problems t))
+         (while problems
+           (condition-case err
+               (progn
+                 (funcall (emms-player-get (car players) 'start)
+                          track)
+                 (setq problems nil))
+             (file-error (setq players (cdr players))))))))))
 (defun emms-player-started (player)
   "Declare that the given EMMS PLAYER has started.

I've seen things you people wouldn't believe. Attack ships on fire off
the shoulder of Orion. I watched C-beams glitter in the dark near the
Tannhauser gate. All those moments will be lost in time, like tears in
rain. Time to die. -- Roy Batty

reply via email to

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