aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Olson <mwolson@gnu.org>2007-01-05 23:06:00 +0000
committerMichael Olson <mwolson@gnu.org>2007-01-05 23:06:00 +0000
commitef7fe16f8b6a1283012099998c4abea2818abd93 (patch)
treed9c7341d6376d418f603c24beebb1d623fa61731
parent11b83c0e196570462740e544d0b86bbce14a1c44 (diff)
Add support for playing Last.fm streams using emms-streams interface
darcs-hash:20070105230616-1bfb2-51c5cd5cdac1b0ab9daee569c4258296a030cdf3.gz
-rw-r--r--emms-lastfm.el32
-rw-r--r--emms-source-file.el11
-rw-r--r--emms-streams.el12
-rw-r--r--emms.texinfo28
4 files changed, 72 insertions, 11 deletions
diff --git a/emms-lastfm.el b/emms-lastfm.el
index 2f4ac73..4c8d328 100644
--- a/emms-lastfm.el
+++ b/emms-lastfm.el
@@ -48,6 +48,13 @@
;; `M-x emms-lastfm-radio RET lastfm://artist/Britney Spears/fans'
;; (Of course you don't need to use _this_ URL. :-))
+;; You can also insert Last.fm streams into playlists (or use
+;; emms-streams.el to listen to them) by activating the player as
+;; follows.
+;; (add-to-list 'emms-player-list 'emms-player-lastfm-radio)
+;; To insert a Last.fm stream into a playlist, do
+;; (emms-insert-lastfm "lastfm://rest-of-url")
+
;; There are some functions for conveniently playing the Similar Artists and
;; the Global Tag Radio. Here you only need to enter the band's name or the tag
;; respectively.
@@ -294,6 +301,18 @@ well or if an error occured."
;;; Playback of lastfm:// streams
+(defgroup emms-player-lastfm-radio nil
+ "EMMS player for Last.fm streams."
+ :group 'emms-player
+ :prefix "emms-player-lastfm-")
+
+(defcustom emms-player-lastfm-radio (emms-player 'emms-lastfm-radio-start
+ 'ignore ; no need to stop
+ 'emms-lastfm-radio-playable-p)
+ "*Parameters for the Last.fm radio player."
+ :type '(cons symbol alist)
+ :group 'emms-player-lastfm-radio)
+
(defconst emms-lastfm-radio-base-url "http://ws.audioscrobbler.com/radio/"
"The base URL for playing lastfm:// stream.
-- only used internally --")
@@ -366,6 +385,19 @@ or
(emms-lastfm-radio-handshake #'emms-lastfm-radio-1 lastfm-url)
(emms-lastfm-radio-1 lastfm-url)))
+(defun emms-lastfm-radio-playable-p (track)
+ "Determine whether the Last.fm player can play this track."
+ (let ((name (emms-track-get track 'name))
+ (type (emms-track-get track 'type)))
+ (and (eq type 'lastfm)
+ (string-match "^lastfm://" name))))
+
+(defun emms-lastfm-radio-start (track)
+ "Start playing TRACK."
+ (when (emms-lastfm-radio-playable-p track)
+ (let ((name (emms-track-get track 'name)))
+ (emms-lastfm-radio name))))
+
(defcustom emms-lastfm-radio-metadata-period 15
"When listening to Last.fm Radio every how many seconds should
emms-lastfm poll for metadata? If set to nil, there won't be any
diff --git a/emms-source-file.el b/emms-source-file.el
index e3c8a59..5384f4a 100644
--- a/emms-source-file.el
+++ b/emms-source-file.el
@@ -280,10 +280,17 @@ files) can play."
;;;###autoload (autoload 'emms-play-streamlist "emms-source-file" nil t)
;;;###autoload (autoload 'emms-add-streamlist "emms-source-file" nil t)
(define-emms-source streamlist (streamlist)
- "An EMMS source for streaming playlists (usually URLs ending in .pls."
- (interactive "sPlay URL: ")
+ "An EMMS source for streaming playlists (usually URLs ending in .pls)."
+ (interactive "sPlay streamlist URL: ")
(emms-playlist-insert-track (emms-track 'streamlist streamlist)))
+;;;###autoload (autoload 'emms-play-lastfm "emms-lastfm" nil t)
+;;;###autoload (autoload 'emms-add-lastfm "emms-lastfm" nil t)
+(define-emms-source lastfm (lastfm-url)
+ "An EMMS source for Last.fm URLs, which begin with lastfm://."
+ (interactive "sPlay Last.fm URL: ")
+ (emms-playlist-insert-track (emms-track 'lastfm lastfm-url)))
+
(provide 'emms-source-file)
;;; emms-source-file.el ends here
diff --git a/emms-streams.el b/emms-streams.el
index e464a12..3bb62e3 100644
--- a/emms-streams.el
+++ b/emms-streams.el
@@ -88,8 +88,10 @@ needed info.")
"The EMMS playlist buffer associated with emms-streams.")
;; Format: (("descriptive name" url feed-number type))
-;; type could be either url or playlist. If url, then it represents a
-;; direct IP, otherwite it's a stream playlist
+;;
+;; type could be either url, playlist, or lastfm. If url, then it
+;; represents a direct IP, if streamlist it's a stream playlist, if
+;; lastfm it's a lastfm station
(defvar emms-stream-default-list
'(("SomaFM: Beatblender"
"http://www.somafm.com/beatblender.pls" 1 streamlist)
@@ -384,8 +386,8 @@ Don't forget to run `emms-stream-save-bookmarks-file' after !"
(read-string "URL: ")
nil
(completing-read
- "Type (url or streamlist): "
- (mapcar #'list '("url" "streamlist")))))
+ "Type (url, streamlist, or lastfm): "
+ (mapcar #'list '("url" "streamlist" "lastfm")))))
(unless fd (setq fd (emms-stream-determine-fd name)))
(let* ((line (emms-line-number-at-pos (point)))
(index (+ (/ line 2) 1)))
@@ -415,7 +417,7 @@ Don't forget to save your modifications !"
(emms-stream-url bookmark)))
(fd (read-from-minibuffer "Feed Descriptor: "
(int-to-string (emms-stream-fd bookmark))))
- (type (read-from-minibuffer "Type (url or streamlist): "
+ (type (read-from-minibuffer "Type (url, streamlist, or lastfm): "
(format "%s" (emms-stream-type bookmark)))))
(emms-stream-delete-bookmark)
(emms-stream-add-bookmark name url (string-to-number fd) type)))
diff --git a/emms.texinfo b/emms.texinfo
index f625e18..ccf44d1 100644
--- a/emms.texinfo
+++ b/emms.texinfo
@@ -1060,8 +1060,8 @@ just test if there are other files to play and close the process otherwise.
@end lisp
@noindent
-And to make that a playable example i also added
-@command{emms-mpg321-remote-playablep}, which i just really steal
+And to make that a playable example I also added
+@command{emms-mpg321-remote-playablep}, which I really just steal
from @file{emms-player-simple.el}
@lisp
@@ -1672,10 +1672,10 @@ order to prime the cache.
To activate this, add the following to your .emacs.
-@example
+@lisp
(require 'emms-volume)
(setq emms-volume-change-function 'emms-volume-mpd-change)
-@end example
+@end lisp
@node Lyrics
@chapter Lyrics
@@ -1844,6 +1844,19 @@ Starts playing the stream referenced by @var{lastfm-url}. When run
interactively you will be prompted for a last.fm URL.
@end defun
+You can also insert Last.fm streams into playlists (or use
+emms-streams.el to listen to them) by activating the player as follows.
+
+@lisp
+(add-to-list 'emms-player-list 'emms-player-lastfm-radio)
+@end lisp
+
+To insert a Last.fm stream into a playlist, do the following.
+
+@lisp
+(emms-insert-lastfm "lastfm://rest-of-url")
+@end lisp
+
For your convenience there are some functions which let you choose a
common radio station without having to remember or type its last.fm URL.
@@ -1930,6 +1943,13 @@ own.@footnote{If you enjoy a particular streaming audio station on the
Web and think that it belongs in the default list, please send us a
link and we will gladly add it!}
+If you want to play Last.fm streams, invoke the following and use the
+``lastfm'' type when adding a bookmark to a Last.fm stream.
+
+@lisp
+(require 'emms-lastfm)
+@end lisp
+
The following is a list of the key-bindings for the emms-streams
interface: