[gst-devel] Playbin and Gtk
João Paulo Mafra
jpmneofito at gmail.com
Thu Aug 6 17:59:18 CEST 2009
Hi all,
I'm trying to make a small video player with Gstreamer and Gtk. I've seen
the blog post on
http://tristanswork.blogspot.com/2008/09/fullscreen-video-in-gstreamer-with-gtk.htmland
it helped me a lot. But I need to show real videos, and after I did
read
the Gstreamer documentation, I figured out that I should use Playbin to
display the videos the simpler way. I modified the example I found on the
blog to use
Playbin instead of a handmade pipeline. When I run the application I have
made, it only displays the Gtk window, without the video that should be on
it. No output, no error.
The code is as below:
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
#include <gtk/gtk.h>
#include <gst/interfaces/xoverlay.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
static gboolean expose_callback(GtkWidget *widget, GdkEventExpose *event,
gpointer data){
gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(data),
GDK_WINDOW_XWINDOW(widget->window));
return TRUE;
}
int main(int argc, char** argv) {
GstStateChangeReturn ret;
GMainLoop *loop;
GstElement *play, *sink;
GtkWidget *window;
/* init GStreamer */
gst_init (&argc, &argv);
gtk_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* set up */
play = gst_element_factory_make ("playbin", "play");
sink = gst_element_factory_make("xvimagesink", "videosink");
if (!sink)
g_print ("output could not be found - check your install\n");
g_object_set (G_OBJECT (play), "video-sink", sink, NULL);
g_object_set (G_OBJECT (play), "uri",
"file:///home/jp/SpiritOfUbuntu.ogv", NULL);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "expose-event",
G_CALLBACK(expose_callback), sink);
gtk_widget_show_all(window);
gst_element_set_state (play, GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE) {
g_print ("Failed to start up pipeline!\n");
}
/* now run */
g_main_loop_run (loop);
/* also clean up */
gst_element_set_state (play, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (play));
return (EXIT_SUCCESS);
}
Any help will be very apreciated.
Thanks a lot,
Joao Paulo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20090806/6ae9306b/attachment.htm>
More information about the gstreamer-devel
mailing list