Added control and display of volume.
Tue Mar 23 23:19:16 PDT 2010 Thomas Persson <tompa.persson@gmail.com>
* Added control and display of volume.
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-23 11:06:36.000000000 -0700
+++ new-climplayer/gui.lisp 2014-07-23 11:06:36.000000000 -0700
@@ -49,13 +49,7 @@
(setf play-list-tab nil))
((and (cl-user::process-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)))))
+ (get-stream-info))
((and (timer frame)
(= (car (timer frame))
(caddr (multiple-value-list (get-decoded-time))))
@@ -179,7 +173,11 @@
(continuous-playbackp :accessor continuous-playbackp
:initform t)
(timer :accessor timer
- :initform nil))
+ :initform nil)
+ (volume :accessor volume
+ :initform 0)
+ (volume-updated :accessor volume-updated
+ :initform (get-universal-time)))
(:panes
(info (make-pane 'application-pane
:scroll-bars nil
@@ -208,7 +206,7 @@
(outlining ()
(vertically ()
(40 info)
- (14 control)))
+ (30 control)))
(with-tab-layout ('pane :name 'main-pane)
("Browser" browser :drawing-options `(:ink ,+dark-green+
:text-style ,(make-text-style nil :bold nil))))
@@ -385,7 +383,7 @@
(write-string " " pane)
(with-output-as-presentation (pane `(com-next) 'command)
(write-string ">>" pane))
- (write-string " " pane)
+ (write-string " " pane)
(with-drawing-options (pane :ink (if (random-playbackp frame)
+darkgreen+
+lightgray+))
@@ -400,9 +398,28 @@
(with-output-as-presentation (pane `(com-continuous-playback) 'command)
(write-string "C"
pane))))
+ (multiple-value-bind (x y)
+ (stream-cursor-position pane)
+ (format pane
+ " Volume: ~A"
+ (if (and (cl-user::process-p (mplayer-process frame))
+ (cl-user::process-alive-p (mplayer-process frame)))
+ (format nil "~A%" (volume frame))
+ "-"))
+ (stream-set-cursor-position pane
+ (+ x
+ (stream-string-width pane " Volume: 100% "))
+ y))
+ (with-text-face (pane :bold)
+ (with-output-as-presentation (pane `(com-increase-volume) 'command)
+ (write-string "+" pane))
+ (write-string " " pane)
+ (with-output-as-presentation (pane `(com-decrease-volume) 'command)
+ (write-string "-" pane)))
+ (terpri pane)
(when (timer frame)
(let ((timer (timer frame)))
- (write-string " Will play "
+ (write-string " Will play "
pane)
(with-drawing-options (pane :ink +darkred+)
(with-output-as-presentation (pane `(com-change-file-or-url)
@@ -425,6 +442,26 @@
(cadr timer))))
(write-string "." pane)))))
+(define-climplayer-command (com-increase-volume :name nil)
+ ()
+ (setf (volume *application-frame*)
+ (min (+ (volume *application-frame*)
+ 10)
+ 100))
+ (mplayer-command (format nil
+ "set_property volume ~A"
+ (volume *application-frame*))))
+
+(define-climplayer-command (com-decrease-volume :name nil)
+ ()
+ (setf (volume *application-frame*)
+ (max (- (volume *application-frame*)
+ 10)
+ 0))
+ (mplayer-command (format nil
+ "set_property volume ~A"
+ (volume *application-frame*))))
+
(define-climplayer-command (com-change-file-or-url :name nil)
()
(when (timer *application-frame*)
@@ -835,16 +872,38 @@
:wait nil))
(defun get-stream-info ()
- (let ((mplayer-out-stream (cl-user::process-output (mplayer-process *climplayer-frame*))))
+ (let ((mplayer-out-stream (cl-user::process-output (mplayer-process *climplayer-frame*)))
+ (*application-frame* *climplayer-frame*))
(when mplayer-out-stream
+ (when (< 1 (- (get-universal-time)
+ (volume-updated *climplayer-frame*)))
+ (mplayer-command "get_property volume")
+ (setf (volume-updated *climplayer-frame*)
+ (get-universal-time)))
(let ((line (read-line-no-hang mplayer-out-stream)))
(multiple-value-bind (start end)
- (cl-ppcre:scan "StreamTitle='[^;]*."
+ (cl-ppcre:scan "ANS_volume=[^\.]*."
line)
(when start
- (subseq line
- (+ start 13)
- (- end 2))))))))
+ (let ((new-volume (parse-integer (subseq line
+ (+ start 11)
+ (1- end)))))
+ (when (not (equal new-volume
+ (volume *climplayer-frame*)))
+ (setf (volume *climplayer-frame*)
+ new-volume)
+ (redisplay-climplayer-frame *climplayer-frame*)))))
+ (when (eq (type-of (currently-playing *climplayer-frame*))
+ 'net-node)
+ (multiple-value-bind (start end)
+ (cl-ppcre:scan "StreamTitle='[^;]*."
+ line)
+ (when start
+ (setf (current-title *climplayer-frame*)
+ (subseq line
+ (+ start 13)
+ (- end 2)))
+ (redisplay-climplayer-frame *climplayer-frame*))))))))
;;;; commands
diff -rN -u old-climplayer/playlist.lisp new-climplayer/playlist.lisp
--- old-climplayer/playlist.lisp 2014-07-23 11:06:36.000000000 -0700
+++ new-climplayer/playlist.lisp 2014-07-23 11:06:36.000000000 -0700
@@ -294,5 +294,5 @@
"/tmp/climplayer-temp-file"))
#+sbcl :search #+sbcl t
:input :stream
- :output nil
+ :output :stream
:wait nil))