From b3890172faf554f9e7bee0049c615ec79947f4d8 Mon Sep 17 00:00:00 2001 From: mousebot Date: Wed, 5 Jan 2022 21:28:57 +0100 Subject: add play symbol as after-string overlay to gifv and video types also update the help-echo for the command to play them --- lisp/mastodon-media.el | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-media.el b/lisp/mastodon-media.el index 38087d6..0a669cd 100644 --- a/lisp/mastodon-media.el +++ b/lisp/mastodon-media.el @@ -271,7 +271,16 @@ Replace them with the referenced image." ;; proceed to load this image asynchronously (put-text-property start end 'media-state 'loading) (mastodon-media--load-image-from-url - image-url media-type start (- end start)))))))) + image-url media-type start (- end start)) + (mastodon-media--moving-image-overlay start end))))))) + +(defun mastodon-media--moving-image-overlay (start end) + "Add play symbol overlay to moving image media items." + (let ((ov (make-overlay start end)) + (type (get-text-property start 'mastodon-media-type))) + (when (or (equal type "gifv") + (equal type "video")) + (overlay-put ov 'after-string " [ ⏯ ]")))) (defun mastodon-media--get-avatar-rendering (avatar-url) "Return the string to be written that renders the avatar at AVATAR-URL." @@ -298,7 +307,7 @@ Replace them with the referenced image." FULL-REMOTE-URL is used for `shr-browse-image'. TYPE is the attachment's type field on the server." (let ((help-echo - "RET/i: load full image (prefix: copy URL), C-RET: play moving image, +/-: zoom, r: rotate, o: save preview")) + "RET/i: load full image (prefix: copy URL), +/-: zoom, r: rotate, o: save preview")) (concat (propertize "[img]" 'media-url media-url @@ -312,7 +321,7 @@ TYPE is the attachment's type field on the server." 'keymap mastodon-tl--shr-image-map-replacement 'help-echo (if (string= type "image") help-echo - (concat help-echo "\ntype: " type))) + (concat help-echo "\nC-RET: play " type " with mpv"))) " "))) (provide 'mastodon-media) -- cgit v1.2.3