After doing seek the pipeline doesn't display the following avi files
Rossana Guerra
guerra.rossana at gmail.com
Sat Feb 25 16:44:29 PST 2012
Hello every one, it seems I solve the seeking event, however it works
fine for the first video of the playlist. But the following videos
aren't displayed, although the pipeline "read" them the playing state
is dismissed. The playlist has 3 elements, the actual pipeline plays
the first video since the seek-time to its end, but not the following
of the playlist.
Thanks so much for any help.
Here is the code:
// Manejador de errores
static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg))
{
case GST_MESSAGE_EOS:
{
cont++;
if (cont == 3)
g_main_loop_quit (loop);
else
{
g_print ("cont%d \n ",cont);
g_print ("nombre del video %s \n ",playlist[cont]); //
set the 2nd and following videos of the playlist
gst_element_set_state (play, GST_STATE_PAUSED);
g_object_set (G_OBJECT (play), "uri",playlist[cont], NULL);
g_object_set (G_OBJECT (play), "suburi",playsubt[cont], NULL);
gst_element_set_state (play, GST_STATE_PLAYING);
}
break;
}
case GST_MESSAGE_ERROR:
{
gchar *debug;
GError *error;
gst_message_parse_error (msg, &error, &debug);
g_free (debug);
g_printerr ("Error: %s\n", error->message);
g_error_free (error);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
gint main (gint argc, char *argv[])
{
GMainLoop *loop = 0;
GstBus *bus = 0;
/* make sure we have a URI */
if (argc != 1)
{
g_print ("Uso: %s <URI>\n", argv[1]);
return -1;
}
/* set up */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
play = gst_element_factory_make ("playbin2", "play");
bus = gst_pipeline_get_bus (GST_PIPELINE (play));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
g_object_set (G_OBJECT (play), "subtitle-font-desc","arial 20", NULL);
g_object_set (G_OBJECT (play), "uri",playlist[0], NULL);
g_object_set (G_OBJECT (play), "suburi",playsubt[0], NULL);
gst_element_set_state (play, GST_STATE_PLAYING);
GstMessage *msg2 = 0;
msg2 = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (play),
GST_CLOCK_TIME_NONE, GST_MESSAGE_ASYNC_DONE);
if (GST_MESSAGE_TYPE (msg2) == GST_MESSAGE_ERROR) {
return 0;
}
gst_message_unref (msg2);
if (!gst_element_seek (GST_ELEMENT(play), 1.0, GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH,
GST_SEEK_TYPE_SET, 175*GST_SECOND,
GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)) {
g_print ("Seek failed!\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 0;
}
More information about the gstreamer-devel
mailing list