summaryrefslogtreecommitdiffhomepage
path: root/lib/media
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2026-09-15 15:39:24 +0100
committerjao <jao@gnu.org>2026-09-15 15:39:24 +0100
commitd2c6a0057dcf7d02434418ad98a70789f1458e8d (patch)
tree9d7241f85e1eddc33c1114e944248a9d9feb1f2c /lib/media
parentef8e6a9664df0cf93a74260239d63b61a504db64 (diff)
downloadelibs-d2c6a0057dcf7d02434418ad98a70789f1458e8d.tar.gz
elibs-d2c6a0057dcf7d02434418ad98a70789f1458e8d.tar.bz2
mpc fixesmain
Diffstat (limited to 'lib/media')
-rw-r--r--lib/media/jao-mpc.el16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/media/jao-mpc.el b/lib/media/jao-mpc.el
index 238a06c..23b2dda 100644
--- a/lib/media/jao-mpc.el
+++ b/lib/media/jao-mpc.el
@@ -212,19 +212,21 @@
(accept-process-output nil 0.5)
(setq jao-random-album-active st)))
+(defun jao-mpc--time-to-secs (str)
+ (if-let* ((ts (string-split (or str "") ":"))
+ (mins (string-to-number (car ts)))
+ (secs (string-to-number (or (cadr ts) "0"))))
+ (+ secs (* 60 mins))
+ 0))
+
(defun jao-mpc--playlist-duration (&optional current port)
(let* ((current (or current (jao-mpc--current)))
(times (string-split (jao-mpc--cmd "playlist -f %time%") nil t))
(offset (- (string-to-number (alist-get 'songpos current "1")) 1))
(times (drop offset times))
- (times (cons (format "-%s" (alist-get 'currenttime current "0:0")) times))
- (total 0))
+ (total (- (jao-mpc--time-to-secs (alist-get 'currenttime current)))))
(dolist (time times total)
- (when-let* ((ts (string-split time ":"))
- (mins (string-to-number (car ts)))
- (secs (string-to-number (or (cadr ts) "0")))
- (secs (if (< 0 mins) (- secs) secs)))
- (setq total (+ total (* 60 mins) secs))))))
+ (setq total (+ total (jao-mpc--time-to-secs time))))))
;;;###autoload
(defun jao-mpc-playlist-duration-string (&optional current)