Added support for displaying the stream title when playing Shoutcast streams.
Sun Mar 21 15:20:24 PDT 2010 Thomas Persson <tompa.persson@gmail.com>
* Added support for displaying the stream title when playing Shoutcast streams.
Warning: CRC errors found. These are probably harmless but should be repaired.
See 'darcs gzcrcs --help' for more information.
diff -rN -u old-climplayer/gui.lisp new-climplayer/gui.lisp
--- old-climplayer/gui.lisp 2014-07-30 04:11:38.000000000 -0700
+++ new-climplayer/gui.lisp 2014-07-30 04:11:38.000000000 -0700
@@ -32,6 +32,7 @@
(loop
(sleep 0.1)
(with-accessors ((currently-playing currently-playing)
+ (current-title current-title)
(mplayer-process mplayer-process)
(play-list play-list)
(next-to-play next-to-play)
@@ -47,7 +48,14 @@
'main-pane)))))
(setf play-list-tab nil))
((and (cl-user::process-p mplayer-process)
- (cl-user::process-alive-p mplayer-process)))
+ (cl-user::process-alive-p mplayer-process))
+ (when (eq (type-of (currently-playing *climplayer-frame*))
+ 'net-node)
+ (let ((title (get-stream-info)))
+ (when title
+ (setf current-title
+ title)
+ (redisplay-climplayer-frame frame)))))
((and (timer frame)
(= (car (timer frame))
(caddr (multiple-value-list (get-decoded-time))))
@@ -77,7 +85,9 @@
player-speed
1
mplayer-process
- (play currently-playing))
+ (play currently-playing)
+ current-title
+ nil)
(redisplay-climplayer-frame frame))
(currently-playing
(unless (current-playlist frame)
@@ -148,6 +158,8 @@
:initform nil)
(currently-playing :accessor currently-playing
:initform nil)
+ (current-title :accessor current-title
+ :initform nil)
(next-to-play :accessor next-to-play
:initform nil)
(player-process :accessor player-process)
@@ -326,18 +338,26 @@
(defun display-info (frame pane)
(with-text-size (pane *climplayer-text-size*)
- (let ((node (currently-playing frame)))
- (updating-output (pane :unique-id node
- :id-test #'eq
- :cache-value node
- :cache-test #'eq)
+ (let ((node (currently-playing frame))
+ (current-title (current-title frame)))
+ (updating-output (pane :unique-id (list node current-title)
+ :id-test #'equal
+ :cache-value (list node current-title)
+ :cache-test #'equal)
(with-drawing-options (pane :ink +darkgreen+)
(with-text-face (pane :bold)
(format pane " Playing: ")))
(if node
(with-output-as-presentation (pane node (type-of node))
- (write-line (extended-title node)
- pane))
+ (write-string (extended-title node)
+ pane)
+ (when current-title
+ (with-drawing-options (pane :ink +black+)
+ (with-text-face (pane :bold)
+ (write-string " - "
+ pane)))
+ (write-string current-title
+ pane)))
(write-string "-" pane))))))
(defun draw-stop-button (pane)
@@ -811,8 +831,21 @@
(parse-for-real-url (node-string-name node))))
#+sbcl :search #+sbcl t
:input :stream
+ :output :stream
:wait nil))
+(defun get-stream-info ()
+ (let ((mplayer-out-stream (cl-user::process-output (mplayer-process *climplayer-frame*))))
+ (when mplayer-out-stream
+ (let ((line (read-line-no-hang mplayer-out-stream)))
+ (multiple-value-bind (start end)
+ (cl-ppcre:scan "StreamTitle='[^;]*."
+ line)
+ (when start
+ (subseq line
+ (+ start 13)
+ (- end 2))))))))
+
;;;; commands