From 2cc681da96da88d168c7c5d0ab6779eb075bc6f9 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 30 Jun 2023 04:14:04 +0300 Subject: play video using mpv Create yt-play, a simple function that checks if the link starts with "http" and then uses `async-shell-command` to open the URL with `mpv`. It also displays a message confirming the URL being opened. This is still a testing function, a video player should be defined using a defcustom --- org-yt.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/org-yt.el b/org-yt.el index b5b5d9c..0cdb94d 100644 --- a/org-yt.el +++ b/org-yt.el @@ -24,7 +24,17 @@ ;;; Code: -;; TODO: play a video link using a video player from an org-mode read only buffer +(require 'org-element) + +;; TODO: Make a defcustom for video player +(defun yt-play () + "Open the link at point in an `'org-mode buffer with `'mpv." + (interactive) + (let ((url (org-element-property + :raw-link (org-element-context)))) + (when (string-prefix-p "http" url) + (async-shell-command (format "mpv %s" url)) + (message "Opening %s with mpv" url)))) -- cgit v1.2.3