aboutsummaryrefslogtreecommitdiff
path: root/emms-last-played.el
diff options
context:
space:
mode:
authorlucas <lucas>2006-06-25 17:56:00 +0000
committerlucas <mwolson@gnu.org>2006-06-25 17:56:00 +0000
commit5e4ffd984d94f89699d038bfd8ff06154fb27dc7 (patch)
treeaeac7a09a33bc67b18d3f690cde97bb301bacd5c /emms-last-played.el
parentd60c90d8def9ebee49d7cae0acc0010b3abad8c8 (diff)
emms-last-played: Count the number of times a track has been played.
By default, EMMS will now store the number of times you play a track. darcs-hash:20060625175654-4f952-0143f8621918567caed0a6587da7a5d3bfea409c.gz
Diffstat (limited to 'emms-last-played.el')
-rw-r--r--emms-last-played.el16
1 files changed, 15 insertions, 1 deletions
diff --git a/emms-last-played.el b/emms-last-played.el
index 0497e6d..97e5c4d 100644
--- a/emms-last-played.el
+++ b/emms-last-played.el
@@ -32,6 +32,10 @@
(require 'emms)
+(defvar emms-last-played-keep-count t
+ "Specifies if EMMS should record the number of times you play a track.
+Set it to t if you want such a feature, and to nil if you don't.")
+
(defvar emms-last-played-format-alist
'(((emms-last-played-seconds-today) . "%k:%M")
(604800 . "%a %k:%M") ;;that's one week
@@ -62,9 +66,19 @@ of this year, respectively.")
"Updates the last-played time of TRACK."
(emms-track-set track 'last-played (current-time)))
+(defun emms-last-played-increment-count (track)
+ "Increments the play-count property of TRACK.
+If non-existent, it is set to 1."
+ (let ((play-count (emms-track-get track 'play-count)))
+ (if play-count
+ (emms-track-set track 'play-count (1+ play-count))
+ (emms-track-set track 'play-count 1))))
+
(defun emms-last-played-update-current ()
"Updates the current track."
- (emms-last-played-update-track (emms-playlist-current-selected-track)))
+ (emms-last-played-update-track (emms-playlist-current-selected-track))
+ (if emms-last-played-keep-count
+ (emms-last-played-increment-count (emms-playlist-current-selected-track))))
(defun emms-last-played-seconds-today ()
"Return the number of seconds passed today."