aboutsummaryrefslogtreecommitdiff
path: root/emms-playing-time.el
diff options
context:
space:
mode:
authorwilliam.xwl <william.xwl>2006-11-12 12:33:00 +0000
committerwilliam.xwl <mwolson@gnu.org>2006-11-12 12:33:00 +0000
commit35728800bcb93f1078d0d3c72b769b9010e2ab8a (patch)
tree78c38f29693531b517df92d2483cc8d96f03e31b /emms-playing-time.el
parentde7f530b99b24ff4d1e2611fddd23a9e5882422a (diff)
emms-playing-time.el: New variable `emms-playing-time-style', it
supports two styles at present, `time' and `bar'. darcs-hash:20061112123308-e8fe6-144635260d3ece1eae45593f6900478b4f089bc2.gz
Diffstat (limited to 'emms-playing-time.el')
-rw-r--r--emms-playing-time.el47
1 files changed, 34 insertions, 13 deletions
diff --git a/emms-playing-time.el b/emms-playing-time.el
index 7b078e0..9b8726c 100644
--- a/emms-playing-time.el
+++ b/emms-playing-time.el
@@ -44,9 +44,8 @@
:group 'emms)
(defcustom emms-playing-time-display-short-p nil
- "If non-nil, only display elapsed time, don't display total
-playing time. e.g., display 02:37 instead of 02:37/05:49. You
-should enable `emms-playing-time-display-p' first, though."
+ "Non-nil will only display elapsed time.
+e.g., display 02:37 instead of 02:37/05:49."
:type 'boolean
:group 'emms-playing-time)
@@ -55,6 +54,12 @@ should enable `emms-playing-time-display-p' first, though."
:type 'string
:group 'emms-playing-time)
+(defcustom emms-playing-time-style 'time
+ "Style used for displaying playing time.
+Valid styles are `time' (e.g., 01:30/4:20) and `bar' (e.g., [===> ])."
+ :type 'symbol
+ :group 'emms-playing-time)
+
;;; Emms Playing Time
@@ -162,17 +167,33 @@ should enable `emms-playing-time-display-p' first, though."
0))
(total-min-only (/ total-playing-time 60))
(total-sec-only (% total-playing-time 60)))
+ (case emms-playing-time-style
+ ((bar)
+ (if (zerop total-playing-time)
+ (setq emms-playing-time-string "[==>........]")
+ (let ((progress "[")
+ ;; percent based on 10
+ (percent (/ (* emms-playing-time 10) total-playing-time)))
+ (dotimes (i percent)
+ (setq progress (concat progress "=")))
+ (setq progress (concat progress ">"))
+ (dotimes (i (- 10 percent))
+ (setq progress (concat progress " ")))
+ (setq progress (concat progress "]"))
+ (setq emms-playing-time-string progress))))
+ (t
+ (setq emms-playing-time-string
+ (emms-replace-regexp-in-string
+ " " "0"
+ (if (or emms-playing-time-display-short-p
+ ;; unable to get total playing-time
+ (eq total-playing-time 0))
+ (format "%2d:%2d" min sec)
+ (format "%2d:%2d/%2s:%2s"
+ min sec total-min-only total-sec-only))))))
(setq emms-playing-time-string
- (format
- emms-playing-time-display-format
- (emms-replace-regexp-in-string
- " " "0"
- (if (or emms-playing-time-display-short-p
- ;; unable to get total playing-time
- (eq total-playing-time 0))
- (format "%2d:%2d" min sec)
- (format "%2d:%2d/%2s:%2s"
- min sec total-min-only total-sec-only)))))
+ (format emms-playing-time-display-format
+ emms-playing-time-string))
(force-mode-line-update)))
(defun emms-playing-time-mode-line ()