[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emms-patches] darcs patch: emms-player-mpd: Overhaul for streamlist...
From: |
Michael Olson |
Subject: |
[Emms-patches] darcs patch: emms-player-mpd: Overhaul for streamlist... (and 1 more) |
Date: |
Wed, 24 May 2006 02:17:51 -0400 |
Wed May 24 01:57:07 EDT 2006 Michael Olson <address@hidden>
* emms-player-mpd: Overhaul for streamlist support, and fix a few
miscellaneous issues.
Wed May 24 02:16:55 EDT 2006 Michael Olson <address@hidden>
* emms-player-mpd: Fix bug that caused unconditional reloading of the entire
MusicPD playlist whenever the track was changed manually.
New patches:
[emms-player-mpd: Overhaul for streamlist support, and fix a few miscellaneous
issues.
Michael Olson <address@hidden>**20060524055707] {
hunk ./emms-player-mpd.el 556
-(defun emms-player-mpd-sync-from-emms-1 (closure id)
- (let ((buffer (car closure))
- (fn (cadr closure))
- (close (cddr closure)))
- (when (buffer-live-p buffer)
- (with-current-buffer buffer
- (setq emms-player-mpd-playlist-id id))
- (when (functionp fn)
- (funcall fn close)))))
+(defun emms-player-mpd-sync-from-emms-1 (closure)
+ (emms-player-mpd-get-playlist-id
+ closure
+ (lambda (closure id)
+ (let ((buffer (car closure))
+ (fn (cdr closure)))
+ (funcall fn buffer id)))))
hunk ./emms-player-mpd.el 564
-(defun emms-player-mpd-sync-from-emms (&optional closure callback)
+(defun emms-player-mpd-sync-from-emms (callback)
hunk ./emms-player-mpd.el 567
-If CALLBACK is provided, call it with CLOSURE once we are done."
+
+If CALLBACK is provided, call it with the current EMMS playlist
+buffer and MusicPD playlist ID when we are done, if there were no
+errors."
hunk ./emms-player-mpd.el 573
- (save-excursion
- (mapc #'emms-player-mpd-add
- (nreverse
- (emms-playlist-tracks-in-region (point-min) (point-max)))))
- (emms-player-mpd-get-playlist-id
- (cons (current-buffer) (cons callback closure))
- #'emms-player-mpd-sync-from-emms-1)))
+ (let (tracks)
+ (save-excursion
+ (setq tracks (nreverse
+ (emms-playlist-tracks-in-region
+ (point-min) (point-max)))))
+ (emms-player-mpd-add-several-tracks
+ tracks
+ (cons (current-buffer) callback)
+ #'emms-player-mpd-sync-from-emms-1))))
hunk ./emms-player-mpd.el 666
- (if (or (null emms-player-mpd-music-directory)
+ (if (or (not emms-player-mpd-music-directory)
hunk ./emms-player-mpd.el 680
-;;; MusicPD commands
-
hunk ./emms-player-mpd.el 687
-(defun emms-player-mpd-add-file (file)
+;;; Adding to the MusicPD playlist
+
+(defun emms-player-mpd-add-file (file closure callback)
hunk ./emms-player-mpd.el 691
-If an error occurs, display a relevant message."
+If an error occurs, display a relevant message.
+
+Execute CALLBACK with CLOSURE as its first argument when done."
hunk ./emms-player-mpd.el 697
- file
- (lambda (file response)
- (let ((output (emms-player-mpd-parse-response response)))
- (when (car output)
- (message "MusicPD error: %s: %s" file (cdar output)))))))
+ (cons file (cons callback closure))
+ (lambda (closure response)
+ (let ((output (emms-player-mpd-parse-response response))
+ (file (car closure))
+ (callback (cadr closure))
+ (close (cddr closure)))
+ (if (car output)
+ (message "MusicPD error: %s: %s" file (cdar output))
+ (when (functionp callback)
+ (funcall callback close)))))))
+
+(defun emms-player-mpd-add-buffer-contents (closure callback)
+ "Load contents of the current buffer into MusicPD by adding each line.
+This handles both m3u and pls type playlists.
hunk ./emms-player-mpd.el 712
-(defun emms-player-mpd-add-playlist (playlist)
+Execute CALLBACK with CLOSURE as its first argument when done."
+ (goto-char (point-min))
+ (let ((format (emms-source-playlist-determine-format)))
+ (when format
+ (emms-player-mpd-add-several-files
+ (emms-source-playlist-files format)
+ closure callback))))
+
+(defun emms-player-mpd-add-playlist (playlist closure callback)
hunk ./emms-player-mpd.el 722
-This handles both m3u and pls type playlists."
+This handles both m3u and pls type playlists.
+
+Execute CALLBACK with CLOSURE as its first argument when done."
hunk ./emms-player-mpd.el 728
- (goto-char (point-min))
- (let ((format (emms-source-playlist-determine-format)))
- (when format
- (let ((list (emms-source-playlist-files format)))
- (dolist (file list)
- (emms-player-mpd-add-file file)))))))
+ (emms-player-mpd-add-buffer-contents closure callback)))
+
+(defun emms-player-mpd-add-streamlist (url closure callback)
+ "Download contents of URL and then add its feeds into MusicPD.
+
+Execute CALLBACK with CLOSURE as its first argument when done."
+ ;; This is useful with emms-streams.el
+ (condition-case nil
+ (progn
+ (require 'url)
+ (with-temp-buffer
+ (url-insert-file-contents url)
+ (emms-player-mpd-add-buffer-contents closure callback)))
+ (error (message (concat "You need to install url.el so that"
+ " Emms can retrieve this stream")))))
hunk ./emms-player-mpd.el 744
-(defun emms-player-mpd-add (track)
- "Add TRACK to the MusicPD playlist."
+(defun emms-player-mpd-add (track closure callback)
+ "Add TRACK to the MusicPD playlist.
+
+Execute CALLBACK with CLOSURE as its first argument when done."
hunk ./emms-player-mpd.el 751
- (emms-player-mpd-add-file name))
+ (emms-player-mpd-add-file name closure callback))
+ ((eq type 'streamlist)
+ (emms-player-mpd-add-streamlist name closure callback))
hunk ./emms-player-mpd.el 756
- (emms-player-mpd-add-playlist name))
+ (emms-player-mpd-add-playlist name closure callback))
hunk ./emms-player-mpd.el 758
- (emms-player-mpd-add-file name)))))
+ (emms-player-mpd-add-file name closure callback)))))
+
+(defun emms-player-mpd-add-several-tracks (tracks closure callback)
+ "Add TRACKS to the MusicPD playlist.
+
+Execute CALLBACK with CLOSURE as its first argument when done."
+ (when (consp tracks)
+ (while (cdr tracks)
+ (emms-player-mpd-add (car tracks) nil #'ignore)
+ (setq tracks (cdr tracks)))
+ ;; only execute callback on last track
+ (emms-player-mpd-add (car tracks) closure callback)))
+
+(defun emms-player-mpd-add-several-files (files closure callback)
+ "Add FILES to the MusicPD playlist.
+
+Execute CALLBACK with CLOSURE as its first argument when done."
+ (when (consp files)
+ (while (cdr files)
+ (emms-player-mpd-add-file (car files) nil #'ignore)
+ (setq files (cdr files)))
+ ;; only execute callback on last file
+ (emms-player-mpd-add-file (car files) closure callback)))
hunk ./emms-player-mpd.el 786
- (and (memq (emms-track-type track) '(file url playlist))
+ (and (memq (emms-track-type track) '(file url playlist streamlist))
hunk ./emms-player-mpd.el 813
-(defun emms-player-mpd-start-and-sync-1 (buffer)
+(defun emms-player-mpd-start-and-sync-1 (buffer id)
hunk ./emms-player-mpd.el 820
+ (setq emms-player-mpd-playlist-id id)
hunk ./emms-player-mpd.el 834
- (emms-player-mpd-start-and-sync-1 emms-playlist-buffer)
+ (emms-player-mpd-start-and-sync-1 emms-playlist-buffer id)
hunk ./emms-player-mpd.el 836
- emms-playlist-buffer
hunk ./emms-player-mpd.el 865
- (if emms-player-mpd-sync-playlist
+ (if (and emms-player-mpd-sync-playlist
+ (not (memq (emms-track-get track 'type) '(streamlist playlist)))
+ (not (string-match "\\`http://" (emms-track-get track 'name))))
hunk ./emms-player-mpd.el 870
- (when (emms-player-mpd-add track)
- ;; if we have loaded the item successfully, play it
- (emms-player-mpd-play))))
+ ;; if we have loaded the item successfully, play it
+ (emms-player-mpd-add track nil #'emms-player-mpd-play)))
hunk ./emms-player-mpd.el 950
+ (name (cdr (assoc "name" info)))
hunk ./emms-player-mpd.el 953
- (emms-track-set track 'type 'file)
- (emms-track-set track 'name (cdr (assoc "file" info)))
- (emms-info-mpd track info)
- (setq desc (emms-track-description track)))
+ (if name
+ (setq desc name)
+ (emms-track-set track 'type 'file)
+ (emms-track-set track 'name (cdr (assoc "file" info)))
+ (emms-info-mpd track info)
+ (setq desc (emms-track-description track))))
hunk ./emms-playlist-mode.el 193
- (string-match "\\.\\(m3u\\|pls\\)\\'" name))
+ (and (eq type 'file)
+ (string-match "\\.\\(m3u\\|pls\\)\\'" name)))
}
[emms-player-mpd: Fix bug that caused unconditional reloading of the entire
MusicPD playlist whenever the track was changed manually.
Michael Olson <address@hidden>**20060524061655] {
hunk ./emms-player-mpd.el 882
- (setq emms-player-mpd-playlist-id nil)
hunk ./emms-player-mpd.el 884
+ (setq emms-player-mpd-playlist-id nil)
}
Context:
[emms-player-mpd: Add a few checks to make sure that the given buffer exists
before trying to do anything with it.
Michael Olson <address@hidden>**20060517035419]
[emms-source-playlist: Do not expand names of files in playlists, as this can
cause problems with emms-player-mpd in some configurations.
Michael Olson <address@hidden>**20060516081257]
[emms-playlist-mode: Implement the option (disabled by default) of opening a
new EMMS buffer for a playlist, when hitting RET on one.
Michael Olson <address@hidden>**20060510040730]
[emms-playlist-mode.el: Don't put a period after the mode map. This hangs 21.4
on display.
address@hidden
[TAG 2.0
address@hidden
Patch bundle hash:
41b0932140be92b941cc3400d64a5282385b7c15
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emms-patches] darcs patch: emms-player-mpd: Overhaul for streamlist... (and 1 more),
Michael Olson <=