emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals-release/ement b692c4a061 02/12: Add basic support for m


From: ELPA Syncer
Subject: [elpa] externals-release/ement b692c4a061 02/12: Add basic support for m.audio events
Date: Thu, 25 Jan 2024 21:57:56 -0500 (EST)

branch: externals-release/ement
commit b692c4a061950e5609f2f9fcd92d99ededcae4ad
Author: Arto Jantunen <viiru@iki.fi>
Commit: Adam Porter <adam@alphapapa.net>

    Add basic support for m.audio events
    
    Very similar to the m.video handler (which is very similar to the m.file
    handler).
    
    Again uses the message body as the title, and displays both audio duration
    and size.
---
 ement-room.el | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/ement-room.el b/ement-room.el
index ce1088825f..8379819b86 100644
--- a/ement-room.el
+++ b/ement-room.el
@@ -3508,6 +3508,7 @@ If FORMATTED-P, return the formatted body content, when 
available."
                            ("m.image" (ement-room--format-m.image event))
                            ("m.file" (ement-room--format-m.file event))
                            ("m.video" (ement-room--format-m.video event))
+                           ("m.audio" (ement-room--format-m.audio event))
                            (_ (if (or local-redacted-by unsigned-redacted-by)
                                   nil
                                 (format "[unsupported msgtype: %s]" msgtype 
))))))
@@ -4307,6 +4308,31 @@ Then invalidate EVENT's node to show the image."
             (propertize " "
                         'display '(space :relative-height 1.5)))))
 
+(defun ement-room--format-m.audio (event)
+  "Return \"m.audio\" EVENT formatted as a string."
+  (pcase-let* (((cl-struct ement-event
+                           (content (map body
+                                         ('info (map mimetype duration size))
+                                         ('url mxc-url))))
+                event)
+               (url (when mxc-url
+                      (ement--mxc-to-url mxc-url ement-session)))
+               (human-size (file-size-human-readable size))
+               (human-duration (format-seconds "%m:%s" (/ duration 1000)))
+               (string (format "[audio: %s (%s) (%s) (%s)]" body mimetype 
human-duration human-size)))
+    (concat (propertize string
+                        'action #'browse-url
+                        'button t
+                        'button-data url
+                        'category t
+                        'face 'button
+                        'follow-link t
+                        'help-echo url
+                        'keymap button-map
+                        'mouse-face 'highlight)
+            (propertize " "
+                        'display '(space :relative-height 1.5)))))
+
 ;;;;; Org format sending
 
 ;; Some of these declarations may need updating as Org changes.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]