From e31fada906bbcdebc4f0fd88b68f9921264726c0 Mon Sep 17 00:00:00 2001 From: Leon Rische Date: Tue, 27 Sep 2022 20:30:04 +0200 Subject: Add audio replay commands --- docs/extensions.org | 5 +++++ org-fc-audio.el | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/docs/extensions.org b/docs/extensions.org index 30dea9c..dbe6f22 100644 --- a/docs/extensions.org +++ b/docs/extensions.org @@ -16,6 +16,11 @@ Files are played using the ~mpv~ media player. Commands: - ~org-fc-audio-set-before~ - ~org-fc-audio-set-after~ + +Each time an audio file is played, it's path is stored in +~org-fc-audio-last-file~ and can be replayed using +~org-fc-audio-replay~ or ~org-fc-audio-replay-slow~. + * ~org-fc-keymap-hint~ Can be enabled with ~(require 'org-fc-keymap-hint)~. diff --git a/org-fc-audio.el b/org-fc-audio.el index 2e95f7a..2774603 100644 --- a/org-fc-audio.el +++ b/org-fc-audio.el @@ -52,6 +52,8 @@ :type 'string :group 'org-fc) +(defvar org-fc-audio-last-file nil) + (defun org-fc-audio-set-before-setup (file) "Set the befor-setup audio property of the current card to FILE." (interactive "f") @@ -79,6 +81,7 @@ the file at the given speed." (defun org-fc-audio-play-file (file speed) "Play the audio FILE at SPEED." + (setq org-fc-audio-last-file file) (start-process-shell-command "org-fc audio" nil @@ -96,6 +99,17 @@ the file at the given speed." 'org-fc-after-flip-hook (lambda () (org-fc-audio-play org-fc-audio-after-flip-property))) +(defun org-fc-audio-replay () + (interactive) + (when org-fc-audio-last-file + (org-fc-audio-play-file org-fc-audio-last-file 1.0))) + +(defun org-fc-audio-replay-slow () + (interactive) + (when org-fc-audio-last-file + (org-fc-audio-play-file org-fc-audio-last-file 0.7))) + + ;;; Footer (provide 'org-fc-audio) -- cgit v1.2.3