aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac4
-rw-r--r--examples/Makefile.am11
-rw-r--r--examples/simple.c113
5 files changed, 129 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 57511ca..d471409 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,5 @@ stamp-*
cclosure-marshallers.[ch]
/doc/Doxyfile
/doc/html
+
+/examples/simple
diff --git a/Makefile.am b/Makefile.am
index 0a47a01..7bef0ab 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,2 +1,2 @@
-SUBDIRS = src doc
+SUBDIRS = src examples doc
diff --git a/configure.ac b/configure.ac
index 6fdd713..1260c92 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,7 +42,7 @@ AC_CHECK_PROG(DOXYGEN, doxygen, doxygen)
#
# Checks for libraries.
#
-PKG_CHECK_MODULES(LIBGTK, [gtk+-2.0])
+PKG_CHECK_MODULES(LIBGTK, [gtk+-2.0 gthread-2.0])
PKG_CHECK_EXISTS([gladeui-1.0],
[glade3_catalogsdir=`$PKG_CONFIG --variable=catalogdir gladeui-1.0`])
@@ -118,7 +118,7 @@ AC_DEFINE(GTK_VLC_PLAYER_TIME_ADJ_PAGE, [30000.], [VLC Player time adjustment pa
AC_DEFINE(GTK_VLC_PLAYER_VOL_ADJ_STEP, [0.02], [VLC Player volume adjustment step increment])
AC_DEFINE(GTK_VLC_PLAYER_VOL_ADJ_PAGE, [0.], [VLC Player volume adjustment page increment])
-AC_CONFIG_FILES([Makefile src/Makefile])
+AC_CONFIG_FILES([Makefile src/Makefile examples/Makefile])
AC_CONFIG_FILES([doc/Makefile doc/Doxyfile])
AC_OUTPUT
diff --git a/examples/Makefile.am b/examples/Makefile.am
new file mode 100644
index 0000000..18cc329
--- /dev/null
+++ b/examples/Makefile.am
@@ -0,0 +1,11 @@
+AM_CFLAGS = -Wall
+AM_CPPFLAGS =
+LDADD =
+
+AM_CFLAGS += @LIBGTK_CFLAGS@
+LDADD += @LIBGTK_LIBS@
+
+AM_CPPFLAGS += -I@top_srcdir@/src
+LDADD += @top_srcdir@/src/libgtk-vlc-player.la
+
+check_PROGRAMS = simple
diff --git a/examples/simple.c b/examples/simple.c
new file mode 100644
index 0000000..1570e0c
--- /dev/null
+++ b/examples/simple.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2012-2013 Otto-von-Guericke-Universität Magdeburg
+ * Copyright (C) 2013 Robin Haberkorn
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
+
+/*
+ * GtkVlcPlayer header file
+ */
+#include <gtk-vlc-player.h>
+
+/*
+ * this gets called when we close the toplevel
+ * GtkWindow
+ */
+static gboolean
+delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+ /* exit event loop */
+ gtk_main_quit();
+ /* but do not yet destroy window */
+ return TRUE;
+}
+
+int
+main(int argc, char *argv[])
+{
+ GtkWidget *window, *player;
+ gchar *filename;
+
+ /*
+ * init glib and Gdk threads
+ * GtkVlcPlayer requires this since libVLC uses threads
+ */
+ g_thread_init(NULL);
+ gdk_threads_init();
+
+ gtk_init(&argc, &argv);
+
+ if (argc != 2) {
+ g_printf("Usage: simple <video-file>\n");
+ return 1;
+ }
+ filename = argv[1];
+
+ /*
+ * create top level window
+ */
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(window), "GtkVlcPlayer");
+
+ g_signal_connect(window, "delete-event",
+ G_CALLBACK(delete_event), NULL);
+
+ /*
+ * create GtkVlcPlayer widget and add it to
+ * the window
+ */
+ player = gtk_vlc_player_new();
+ gtk_container_add(GTK_CONTAINER(window), player);
+
+ /*
+ * Load and play video file
+ */
+ if (!gtk_vlc_player_load_filename(GTK_VLC_PLAYER(player), filename)) {
+ g_fprintf(stderr, "Could not load file \"%s\"\n", filename);
+ return 1;
+ }
+ gtk_vlc_player_play(GTK_VLC_PLAYER(player));
+
+ /*
+ * Show window and player widgets
+ */
+ gtk_widget_show_all(window);
+
+ /*
+ * Gtk main loop: do not forget to aquire the
+ * Gdk mutex
+ */
+ gdk_threads_enter();
+ gtk_main();
+ gdk_threads_leave();
+
+ /*
+ * Stop video playback & cleanup
+ */
+ gtk_vlc_player_stop(GTK_VLC_PLAYER(player));
+ gtk_widget_destroy(window);
+
+ return 0;
+}