commit abeaae1be53be7264f5f7bed0331b5aa009bf793
parent 55728292d4b360c4ca7a55e48c98bf1221bc6f63
Author: Jacki <jacki@thejackimonster.de>
Date: Sun, 12 May 2024 04:09:54 +0200
Fix replay of recorded voice message
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
4 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/resources/ui/play_media.ui b/resources/ui/play_media.ui
@@ -53,6 +53,7 @@ Author: Tobias Frisch
<object class="HdyHeaderBar" id="title_bar">
<property name="visible">True</property>
<property name="can-focus">False</property>
+ <property name="title" translatable="yes">Play Media</property>
<property name="show-close-button">True</property>
<child>
<object class="GtkButton" id="back_button">
diff --git a/src/ui/chat.c b/src/ui/chat.c
@@ -905,13 +905,18 @@ handle_recording_play_button_click(UNUSED GtkButton *button,
_stop_playing_recording(handle, TRUE);
else if (handle->recording_filename[0])
{
+ GString* uri = g_string_new("file://");
+ g_string_append(uri, handle->recording_filename);
+
g_object_set(
- G_OBJECT(handle->play_source),
- "location",
- handle->recording_filename,
+ G_OBJECT(handle->play_pipeline),
+ "uri",
+ uri->str,
NULL
);
+ g_string_free(uri, TRUE);
+
gst_element_set_state(handle->play_pipeline, GST_STATE_PLAYING);
handle->playing = TRUE;
@@ -995,10 +1000,13 @@ _play_timer_func(gpointer user_data)
UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data;
- if (handle->play_time < handle->record_time * 100)
+ const gdouble played_seconds = 0.010 * handle->play_time + 0.005;
+ const gdouble listen_seconds = MAX(handle->record_time - 0.010, 0.0);
+
+ if (played_seconds < listen_seconds)
gtk_progress_bar_set_fraction(
handle->recording_progress_bar,
- 0.01 * handle->play_time / handle->record_time
+ played_seconds / listen_seconds
);
else
gtk_progress_bar_set_fraction(
@@ -1103,13 +1111,17 @@ _setup_gst_pipelines(UI_CHAT_Handle *handle)
gst_object_unref(bus);
}
- handle->play_pipeline = gst_parse_launch(
- "filesrc name=source ! oggdemux ! vorbisdec ! audioconvert ! autoaudiosink",
- NULL
- );
+ handle->play_pipeline = gst_element_factory_make("playbin", NULL);
+ handle->play_sink = gst_element_factory_make("autoaudiosink", "asink");
+
+ if ((!(handle->play_pipeline)) || (!(handle->play_sink)))
+ return;
- handle->play_source = gst_bin_get_by_name(
- GST_BIN(handle->play_pipeline), "source"
+ g_object_set(
+ G_OBJECT(handle->play_pipeline),
+ "audio-sink",
+ handle->play_sink,
+ NULL
);
{
diff --git a/src/ui/chat.h b/src/ui/chat.h
@@ -59,7 +59,7 @@ typedef struct UI_CHAT_Handle
GstElement *record_sink;
GstElement *play_pipeline;
- GstElement *play_source;
+ GstElement *play_sink;
guint record_watch;
guint play_watch;
diff --git a/src/ui/play_media.c b/src/ui/play_media.c
@@ -656,8 +656,6 @@ ui_play_media_window_init(MESSENGER_Application *app,
gtk_builder_get_object(handle->builder, "title_bar")
);
- hdy_header_bar_set_title(handle->title_bar, _("Play Media"));
-
handle->back_button = GTK_BUTTON(
gtk_builder_get_object(handle->builder, "back_button")
);
@@ -796,8 +794,8 @@ ui_play_media_window_init(MESSENGER_Application *app,
void
ui_play_media_window_update(UI_PLAY_MEDIA_Handle *handle,
- const gchar *uri,
- const struct GNUNET_CHAT_File *file)
+ const gchar *uri,
+ const struct GNUNET_CHAT_File *file)
{
g_assert((handle) && (uri));