Hi Tim and everyone, I read in the mailing list that before seeeking is necessary for waiting for the pipeline to preroll, since the pipeline changes its state asynchronically.<br>I use the "get_bus_timed_pop_filtered" function before doing the event seeking as the code below shows.<br>
Now it works as expected.<br><br>Is there a better manner to do this? In the seeking examples I saw this function is barely mentioned, of the contrary seeking event is almost a fashion template procedure. <br><br>I appreciate any concepts to clarify this issue. Thanks so much.<br>
<br>Rossana<br><br>// handler error routine EOS, ERROR, etc<br><br>// global variable definitions<br><br>gint main (gint argc, char *argv[])<br>{<br> GMainLoop *loop = 0;<br> GstBus *bus = 0;<br><br><br><br> /* set up */<br>
gst_init (&argc, &argv);<br><br> loop = g_main_loop_new (NULL, FALSE);<br> play = gst_element_factory_make ("playbin2", "play");<br><br> bus = gst_pipeline_get_bus (GST_PIPELINE (play));<br>
gst_bus_add_watch (bus, bus_call, loop);<br> gst_object_unref (bus);<br><br> <br> g_object_set (G_OBJECT (play), "uri",playlist[0], NULL);<br> g_object_set (G_OBJECT (play), "suburi",playsubt[0], NULL);<br>
<br> gst_element_set_state (play, GST_STATE_PLAYING);<br> <br><br> GstMessage *msg2 = 0;<br><br> msg2 = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (play), GST_CLOCK_TIME_NONE, GST_MESSAGE_ASYNC_DONE);<br><br>
if (GST_MESSAGE_TYPE (msg2) == GST_MESSAGE_ERROR) {<br> return 0;<br> }<br><br> gst_message_unref (msg2);<br><br> if (!gst_element_seek (GST_ELEMENT(play), 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,<br> GST_SEEK_TYPE_SET, 15*GST_SECOND,<br>
GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)) {<br> g_print ("Seek failed!\n");}<br> else<br> g_print ("Seek OK!\n");<br><br><br> /* now run */<br> g_main_loop_run (loop);<br>
<br> /* also clean up */<br> gst_element_set_state (play, GST_STATE_NULL);<br> gst_object_unref (GST_OBJECT (play));<br><br> return 0;<br>}<br><br><br><br><br><br><br><div class="gmail_quote">2012/2/25 Rossana Guerra <span dir="ltr"><<a href="mailto:guerra.rossana@gmail.com">guerra.rossana@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Tim, the seeking is not working, according to the code it is expected it reaches the position that corresponds to the 15 seconds of video and it doesn't. It begins to play from the begining as if no seeking wasn't applied.<br>
According to this code, the seeking it's done (it prints "seek OK")<br><br>// gst int and so on<br>//here I create the pipeline and I attach the callback event<div class="im"><br><br> gst_element_set_state (play, GST_STATE_PLAYING);<br>
<br> gst_element_set_state (play, GST_STATE_PAUSED);<br> if (!gst_element_seek (GST_ELEMENT(play), 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,<br>
GST_SEEK_TYPE_SET, 15*GST_SECOND,<br> GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)) {<br> g_print ("Seek failed!\n");}<br> else<br></div><div class="im"> g_print ("Seek OK!\n")<br>
<br></div>Thanks, cheers<span class="HOEnZb"><font color="#888888"><br><br>Rossana</font></span><div class="HOEnZb"><div class="h5"><br><br><div class="gmail_quote">2012/2/25 Tim-Philipp Müller <span dir="ltr"><<a href="mailto:t.i.m@zen.co.uk" target="_blank">t.i.m@zen.co.uk</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On Sat, 2012-02-25 at 05:08 -0200, Rossana Guerra wrote:<br>
<br>
> I need it to do a seek at the start of the 'player'.<br>
> This is the code, according to the message, the seek is done, but not<br>
> in the place it should be. I want it to start at 15 seconds from its<br>
> begining<br>
><br>
</div>> ....<br>
<div>> g_print ("Seek OK!\n"); // it seems it does the seek, but it<br>
> doesn't it plays the video from the begining.<br>
><br>
> What is wrong?, I see these line in many examples.<br>
<br>
</div>What is it that actually happens insteaad then? It's not quite clear to<br>
me how it fails.<br>
<br>
Cheers<br>
-Tim<br>
<br>
<br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
</blockquote></div><br>
</div></div></blockquote></div><br>