emms-help
[Top][All Lists]
Advanced

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

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


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

Hi,

Lucas Bonnet <address@hidden> writes:

> I'm too tired to read your patch (sorry!) but I thought emms alreayd
> handled such cases... If not, well, your patch will should be very
> welcome.

Luckily you haven't already read it :-)

Because I spotted a silly bug in my code which should be resolved with
these changes.

Thanks,
Andrea.

--- old-emms2/emms.el   2006-06-16 22:37:21.000000000 +0200
+++ new-emms2/emms.el   2006-06-16 22:37:21.000000000 +0200
@@ -1218,27 +1218,35 @@
   "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 "/")
+             (continue t))
+         (while (and players continue)
+           (condition-case err
+               (progn
+                 (funcall (emms-player-get (car players) 'start)
+                          track)
+                 (setq continue nil))
+             (error (setq players (cdr players)))))
+         (if (not players)
+             (error "None of the suitable players can play track: %S" track 
)))))))
 
 (defun emms-player-started (player)
   "Declare that the given EMMS PLAYER has started.

-- 
"If you want to build a ship, don't drum up people together to collect 
wood and don't assign them tasks and work, but rather teach them to 
long for the endless immensity of the sea." --Antoine de Saint-Exupery





reply via email to

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