[Music] Introduce ‘db/play-auto-playlist’
This is the main entry point to play automatically generated playlists (“auto playlists”). It is using the value of ‘db/auto-playlist-file-function’ to generate a list of files to play. This list if currently played using EMMS, via ‘db/-emms-playlist-from-files’.
This commit is contained in:
parent
bc41e3c5be
commit
9e075d6e0c
12
init.el
12
init.el
|
@ -2145,10 +2145,14 @@ search commands like `db/helm-shortcuts’."
|
|||
(require 'helm-adaptive)))
|
||||
|
||||
(use-package db-music
|
||||
:init (setq db/playlist-play-function #'db/play-playlist-from-git-annex-find)
|
||||
:commands (db/play-playlist-from-cache
|
||||
db/play-playlist-from-git-annex-find
|
||||
db/update-playlist-from-directory))
|
||||
:init (setq db/auto-playlist-file-function
|
||||
#'(lambda ()
|
||||
(db/playlist-files-from-git-annex-find
|
||||
"--metadata db-playlist=include")))
|
||||
:commands (db/play-auto-playlist
|
||||
db/playlist-files-from-cache
|
||||
db/playlist-files-from-git-annex-find
|
||||
db/update-playlist-cache-from-directory))
|
||||
|
||||
|
||||
;; * Shells and such
|
||||
|
|
|
@ -131,7 +131,7 @@ _RET_: ?RET? _M_: ?M?
|
|||
("-" emms-volume-lower "lower volume")
|
||||
("+" emms-volume-raise "raise volume")
|
||||
("M" emms "show playlist")
|
||||
("P" (call-interactively db/playlist-play-function)
|
||||
("P" (db/play-auto-playlist)
|
||||
"Play automatically generated playlist"))
|
||||
|
||||
|
||||
|
|
|
@ -13,18 +13,22 @@
|
|||
:group 'convenience
|
||||
:tag "db-music")
|
||||
|
||||
(defcustom db/playlist-play-function #'db/play-playlist-from-cache
|
||||
"Function to use to automatically generate playlists"
|
||||
(defcustom db/auto-playlist-file-function #'db/play-playlist-from-cache
|
||||
"Function that has to return a list of all music files that
|
||||
should be included in the auto playlist."
|
||||
:group 'db-music
|
||||
:type 'function)
|
||||
|
||||
(defcustom db/playlist nil
|
||||
"List of songs to include in a random playlist."
|
||||
:group 'db-music
|
||||
:type '(alist :value-type (choice (const :tag "Undecided" :undecided)
|
||||
(const :tag "Include" :include)
|
||||
(const :tag "Exclude" :exclude))
|
||||
:key-type file))
|
||||
(defun db/play-auto-playlist ()
|
||||
"Generate playlist using `db/auto-playlist-file-function’ and
|
||||
start playing it.
|
||||
|
||||
Current backend is EMMS."
|
||||
(interactive)
|
||||
(db/-emms-playlist-from-files (funcall db/auto-playlist-file-function)))
|
||||
|
||||
;; Idea: make this customizable, so that we can later switch to another backend
|
||||
;; if necessary
|
||||
|
||||
(defun db/-emms-playlist-from-files (files)
|
||||
"Generate EMMS playlist from FILES.
|
||||
|
@ -47,16 +51,23 @@ Shuffle it and start playing it afterwards."
|
|||
(emms-playlist-select-first)
|
||||
(emms-start)))))
|
||||
|
||||
(defun db/play-playlist-from-cache ()
|
||||
"Start playing songs from `db/playlist’"
|
||||
(defcustom db/playlist nil
|
||||
"List of songs to include in a random playlist."
|
||||
:group 'db-music
|
||||
:type '(alist :value-type (choice (const :tag "Undecided" :undecided)
|
||||
(const :tag "Include" :include)
|
||||
(const :tag "Exclude" :exclude))
|
||||
:key-type file))
|
||||
|
||||
(defun db/playlist-files-from-cache ()
|
||||
"Generate files for auto playlist from `db/playlist’ cache."
|
||||
(interactive)
|
||||
(db/-emms-playlist-from-files
|
||||
(->> db/playlist
|
||||
(cl-remove-if-not #'(lambda (track)
|
||||
(eq (cdr track) :include)))
|
||||
(mapcar #'car))))
|
||||
(mapcar #'car)))
|
||||
|
||||
(defun db/play-playlist-from-git-annex-find (match-expression)
|
||||
(defun db/playlist-files-from-git-annex-find (match-expression)
|
||||
"Generate playlist from git annex find on MATCH-EXPRESSION.
|
||||
|
||||
Prompts for MATCH-EXPRESSION when called interactively.
|
||||
|
@ -65,7 +76,6 @@ are match it. Assumes `emms-source-file-default-directory’ to be
|
|||
part of a git-annex repository, and will complain otherwise."
|
||||
(interactive "smatch expression: ")
|
||||
(let* ((default-directory emms-source-file-default-directory))
|
||||
(db/-emms-playlist-from-files
|
||||
(->> (split-string (with-output-to-string
|
||||
(with-current-buffer standard-output
|
||||
(let ((return-value (apply #'call-process
|
||||
|
@ -83,9 +93,9 @@ part of a git-annex repository, and will complain otherwise."
|
|||
(mapcar #'(lambda (path)
|
||||
(expand-file-name
|
||||
path
|
||||
emms-source-file-default-directory)))))))
|
||||
emms-source-file-default-directory))))))
|
||||
|
||||
(defun db/update-playlist-from-directory (directory)
|
||||
(defun db/update-playlist-cache-from-directory (directory)
|
||||
"Recursively traverse DIRECTORY and update `db/playlist’.
|
||||
|
||||
Files not present `db/playlist’ but that are found in DIRECTORY
|
||||
|
|
Loading…
Reference in New Issue
Block a user