may be you should check the return value of <br><br>gst_element_seek (play,<br>
1.0,<br>
GST_FORMAT_TIME,<br>
GST_SEEK_FLAG_FLUSH,<br>
GST_SEEK_TYPE_SET,<br>
fpos,<br>
GST_SEEK_TYPE_NONE, 0);<br><br>only if its true means the seeking is possible else not.<br><br><br><div class="gmail_quote">On Wed, Nov 4, 2009 at 10:37 PM, vincent meserette <span dir="ltr"><<a href="mailto:vmeserette@gmail.com">vmeserette@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Hi all,<br>
<br>
I am a newbie in the use of gstreamer, so I hope you will excuse the<br>
simplicity of my question.<br>
I wrote a little program to play wav and mp3 files with the playbin element,<br>
and a function to seek on this element.<br>
For wav files it works perfectly, but it doesn't seek on mp3 files, even if<br>
I haven't error message from the gst_element_seek function.<br>
Does anyone know from where could come the problem ?<br>
<br>
Here is the construction of my pipeline :<br>
<br>
gst_init (0, 0);<br>
GMainLoop *loop = g_main_loop_new (NULL, FALSE);<br>
<br>
// -------------- play with playbin --------------------<br>
GstElement *play = gst_element_factory_make ("playbin", "play");<br>
std::string uri="file:///"+pFileName;<br>
std::cout << "playing " << uri << std::endl;<br>
g_object_set (G_OBJECT (play), "uri", uri.c_str(), NULL);<br>
<br>
GstElement *sink = gst_element_factory_make ("alsasink","sink");<br>
g_object_set (G_OBJECT (play),"audio-sink", sink, NULL);<br>
<br>
GstBus*bus = gst_pipeline_get_bus (GST_PIPELINE (play));<br>
gst_bus_add_watch (bus, (GstBusFunc) bus_call, thisApp);<br>
gst_bus_add_signal_watch (bus);<br>
gst_object_unref (GST_OBJECT (bus));<br>
gst_element_set_state (play, GST_STATE_PLAYING);<br>
g_main_loop_run (loop);<br>
<br>
And here the seeking function :<br>
<br>
<br>
void GstPlayer::goToPosition(const float &position)<br>
{<br>
gint64 fpos=position*GST_SECOND;<br>
GstQuery *query;<br>
if (!play)<br>
{<br>
std::cout << "play is not construct "<< std::endl ;<br>
return;<br>
}<br>
/**<br>
* Determine whether we can seek.<br>
**/<br>
query = gst_query_new_seeking (GST_FORMAT_TIME);<br>
while (!gst_element_query (play, query))<br>
{<br>
std::cout << "not OK to seek"<< std::endl ;<br>
}<br>
<br>
GstState state, pending;<br>
<br>
/**<br>
* Store old state.<br>
**/<br>
gst_element_get_state ( play,<br>
&state,<br>
&pending,<br>
0);<br>
if (pending)<br>
state = pending;<br>
<br>
/**<br>
* State to PAUSED.<br>
**/<br>
gst_element_set_state (play, GST_STATE_PAUSED);<br>
<br>
/**<br>
* Perform the seek.<br>
**/<br>
std::cout << "seeking to " << position << " s" << std::endl;<br>
gst_element_seek (play,<br>
1.0,<br>
GST_FORMAT_TIME,<br>
GST_SEEK_FLAG_FLUSH,<br>
GST_SEEK_TYPE_SET,<br>
fpos,<br>
GST_SEEK_TYPE_NONE, 0);<br>
/**<br>
* Restore state.<br>
**/<br>
gst_element_set_state (play, state);<br>
<br>
Thanks in advance<br>
<br>
Vincent<br>
--<br>
View this message in context: <a href="http://old.nabble.com/problem-to-seek-mp3-tp26196581p26196581.html" target="_blank">http://old.nabble.com/problem-to-seek-mp3-tp26196581p26196581.html</a><br>
Sent from the GStreamer-devel mailing list archive at Nabble.com.<br>
<br>
<br>
------------------------------------------------------------------------------<br>
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day<br>
trial. Simplify your report design, integration and deployment - and focus on<br>
what you do best, core application coding. Discover what's new with<br>
Crystal Reports now. <a href="http://p.sf.net/sfu/bobj-july" target="_blank">http://p.sf.net/sfu/bobj-july</a><br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.sourceforge.net">gstreamer-devel@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br>
</blockquote></div><br>