From e645eccb2ea0cbff800c6bf9b5cd72609c99d936 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 4 Jun 2024 02:57:05 +0200 Subject: [PATCH] Audio message playback --- sbapp/ui/messages.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sbapp/ui/messages.py b/sbapp/ui/messages.py index 99e9f20..49c9ce2 100644 --- a/sbapp/ui/messages.py +++ b/sbapp/ui/messages.py @@ -164,7 +164,8 @@ class Messages(): titlestr = "[b]Title[/b] "+msg["title"].decode("utf-8")+"\n" w.heading = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] "+sphrase+prgstr+" " if w.has_audio: - w.heading += f"\n[b]Audio Recording Included[/b]" + alstr = RNS.prettysize(w.audio_size) + w.heading += f"\n[b]Audio Message[/b] ({alstr})" m["state"] = msg["state"] @@ -176,7 +177,8 @@ class Messages(): titlestr = "[b]Title[/b] "+msg["title"].decode("utf-8")+"\n" w.heading = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] Delivered" if w.has_audio: - w.heading += f"\n[b]Audio Recording Included[/b]" + alstr = RNS.prettysize(w.audio_size) + w.heading += f"\n[b]Audio Message[/b] ({alstr})" m["state"] = msg["state"] if msg["method"] == LXMF.LXMessage.PAPER: @@ -196,7 +198,8 @@ class Messages(): titlestr = "[b]Title[/b] "+msg["title"].decode("utf-8")+"\n" w.heading = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] On Propagation Net" if w.has_audio: - w.heading += f"\n[b]Audio Recording Included[/b]" + alstr = RNS.prettysize(w.audio_size) + w.heading += f"\n[b]Audio Message[/b] ({alstr})" m["state"] = msg["state"] if msg["state"] == LXMF.LXMessage.FAILED: @@ -208,7 +211,8 @@ class Messages(): w.heading = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] Failed" m["state"] = msg["state"] if w.has_audio: - w.heading += f"\n[b]Audio Recording Included[/b]" + alstr = RNS.prettysize(w.audio_size) + w.heading += f"\n[b]Audio Message[/b] ({alstr})" w.dmenu.items.append(w.dmenu.retry_item) @@ -403,7 +407,8 @@ class Messages(): heading_str = heading_str[:-2] if has_audio: - heading_str += f"\n[b]Audio Recording Included[/b]" + alstr = RNS.prettysize(len(audio_field[1])) + heading_str += f"\n[b]Audio Message[/b] ({alstr})" item = ListLXMessageCard( text=pre_content+message_markup.decode("utf-8")+extra_content, @@ -430,6 +435,7 @@ class Messages(): Clock.schedule_once(cb, 0.25) item.has_audio = True + item.audio_size = len(audio_field[1]) item.audio_field = audio_field item.bind(on_release=play_audio)