commit aefac32b50c41a2a6f137b84b80753cd26333aa5
parent 36058f083af2fccf616b72df5fa387a14db3b657
Author: TheJackiMonster <thejackimonster@gmail.com>
Date: Mon, 5 Dec 2022 21:35:25 +0100
Adjusted video file extension support for playback
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat:
3 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/src/ui/message.c b/src/ui/message.c
@@ -502,9 +502,7 @@ _update_file_message(UI_MESSAGE_Handle *handle,
return;
}
- const char* extension = strrchr(filename, '.');
-
- if (0 == g_strcmp0(extension, ".mp4"))
+ if (ui_play_media_window_supports_file_extension(filename))
{
handle->media = TRUE;
goto file_progress;
diff --git a/src/ui/play_media.c b/src/ui/play_media.c
@@ -27,6 +27,27 @@
#include "../application.h"
#include "../ui.h"
+gboolean
+ui_play_media_window_supports_file_extension(const gchar *filename)
+{
+ if (!filename)
+ return FALSE;
+
+ const char* extension = strrchr(filename, '.');
+
+ if (!extension)
+ return FALSE;
+
+ if (0 == g_strcmp0(extension, ".mkv"))
+ return TRUE;
+ if (0 == g_strcmp0(extension, ".mp4"))
+ return TRUE;
+ if (0 == g_strcmp0(extension, ".webm"))
+ return TRUE;
+
+ return FALSE;
+}
+
static void
handle_back_button_click(GtkButton *button,
gpointer user_data)
diff --git a/src/ui/play_media.h b/src/ui/play_media.h
@@ -75,6 +75,17 @@ typedef struct UI_PLAY_MEDIA_Handle
} UI_PLAY_MEDIA_Handle;
/**
+ * Returns whether the file extension of a given
+ * filename is supported for playing the type of
+ * media.
+ *
+ * @param filename Filename of potential media file
+ * @return TRUE if the extension is supported for playback, otherwise FALSE
+ */
+gboolean
+ui_play_media_window_supports_file_extension(const gchar *filename);
+
+/**
* Initializes a handle for the play media window
* of a given messenger application.
*