emms-help
[Top][All Lists]
Advanced

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

[emms-help] Playlist shuffle fix


From: Lucas Bonnet
Subject: [emms-help] Playlist shuffle fix
Date: Sun, 29 May 2005 09:47:10 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Morning EMMS users !

I finally found a way to update the playlist after a shuffle.

Jorgen, if you agree with it, I'll install it.


(defun emms-playlist-search-track (track)
  "Returns the index of the track TRACK."
  (catch 'loop
    (let ((i 0)
          (track-fullpath (cdr (assoc 'name track))))
      (while (< i (length emms-playlist))
        (let ((i-fullpath (cdr (assoc 'name (elt emms-playlist i)))))
          (if (string= track-fullpath i-fullpath)
              (throw 'loop i)
            (setq i (1+ i))))))))


(defun emms-playlist-shuffle ()
  "Shuffle the current playlist."
  (let ((current-track (emms-playlist-current-track)))
    (emms-playlist-set-playlist
     (emms-playlist-shuffle-vector
      (emms-playlist-get-playlist)))
    ;; loop to find the "lost" track.
    (let ((new-index (emms-playlist-search-track current-track)))
      (emms-playlist-set-current new-index)
      (emms-pbi-rebuild-playlist-buffer))))


-- 
Lucas, less tired this morning than yesterday evening :)





reply via email to

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