;;; mpc.el --- A client for the Music Player Daemon -*- lexical-binding: t -*-
-;; Copyright (C) 2006-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2016 Free Software Foundation, Inc.
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
;; Keywords: multimedia
(let ((v (match-string 3 host)))
(setq host (match-string 2 host))
(when (and (stringp v) (not (string= "" v)))
- (setq port
- (if (string-match "[^[:digit:]]" v)
- (string-to-number v)
- v)))))
+ (setq port v))))
(when (file-name-absolute-p host)
;; Expand file name because `file-name-absolute-p'
;; considers paths beginning with "~" as absolute
(mpc-proc-cmd "play")
(mpc-status-refresh))
+(defun mpc-cmd-seekcur (time)
+ (mpc-proc-cmd (list "seekcur" time) #'mpc-status-refresh))
+
(defun mpc-cmd-add (files &optional playlist)
"Add the songs FILES to PLAYLIST.
If PLAYLIST is t or nil or missing, use the main playlist."
(substring time (match-end 0))
time)))))
(`Cover
- (let ((dir (file-name-directory
- (mpc-file-local-copy (cdr (assq 'file info))))))
+ (let ((dir (file-name-directory (cdr (assq 'file info)))))
;; (debug)
(push `(equal ',dir (file-name-directory (cdr (assq 'file info)))) pred)
(if-let ((covers '(".folder.png" "cover.jpg" "folder.jpg"))
- (cover (cl-loop for file in (directory-files dir)
+ (cover (cl-loop for file in (directory-files (mpc-file-local-copy dir))
if (member (downcase file) covers)
return (concat dir file)))
(file (with-demoted-errors "MPC: %s"
(define-key map "s" 'mpc-toggle-play)
(define-key map ">" 'mpc-next)
(define-key map "<" 'mpc-prev)
- (define-key map "g" nil)
+ (define-key map "g" 'mpc-seek-current)
map))
(easy-menu-define mpc-mode-menu mpc-mode-map
["Play/Pause" mpc-toggle-play] ;FIXME: Add one of ⏯/▶/⏸ in there?
["Next Track" mpc-next] ;FIXME: Add ⇥ there?
["Previous Track" mpc-prev] ;FIXME: Add ⇤ there?
+ ["Seek Within Track" mpc-seek-current]
"--"
["Repeat Playlist" mpc-toggle-repeat :style toggle
:selected (member '(repeat . "1") mpc-status)]
(interactive)
(mpc-cmd-pause "0"))
+(defun mpc-seek-current (pos)
+ "Seek within current track."
+ (interactive
+ (list (read-string "Position to go ([+-]seconds): ")))
+ (mpc-cmd-seekcur pos))
+
(defun mpc-toggle-play ()
"Toggle between play and pause.
If stopped, start playback."