[gst-devel] problem to seek mp3
vincent meserette
vmeserette at gmail.com
Wed Nov 4 14:47:54 CET 2009
Hi all,
I am a newbie in the use of gstreamer, so I hope you will excuse the
simplicity of my question.
I wrote a little program to play wav and mp3 files with the playbin element,
and a function to seek on this element.
For wav files it works perfectly, but it doesn't seek on mp3 files, even if
I haven't error message from the gst_element_seek function.
Does anyone know from where could come the problem ?
Here is the construction of my pipeline :
gst_init (0, 0);
GMainLoop *loop = g_main_loop_new (NULL, FALSE);
// -------------- play with playbin --------------------
GstElement *play = gst_element_factory_make ("playbin", "play");
std::string uri="file:///"+pFileName;
std::cout << "playing " << uri << std::endl;
g_object_set (G_OBJECT (play), "uri", uri.c_str(), NULL);
GstElement *sink = gst_element_factory_make ("alsasink","sink");
g_object_set (G_OBJECT (play),"audio-sink", sink, NULL);
GstBus*bus = gst_pipeline_get_bus (GST_PIPELINE (play));
gst_bus_add_watch (bus, (GstBusFunc) bus_call, thisApp);
gst_bus_add_signal_watch (bus);
gst_object_unref (GST_OBJECT (bus));
gst_element_set_state (play, GST_STATE_PLAYING);
g_main_loop_run (loop);
And here the seeking function :
void GstPlayer::goToPosition(const float &position)
{
gint64 fpos=position*GST_SECOND;
GstQuery *query;
if (!play)
{
std::cout << "play is not construct "<< std::endl ;
return;
}
/**
* Determine whether we can seek.
**/
query = gst_query_new_seeking (GST_FORMAT_TIME);
while (!gst_element_query (play, query))
{
std::cout << "not OK to seek"<< std::endl ;
}
GstState state, pending;
/**
* Store old state.
**/
gst_element_get_state ( play,
&state,
&pending,
0);
if (pending)
state = pending;
/**
* State to PAUSED.
**/
gst_element_set_state (play, GST_STATE_PAUSED);
/**
* Perform the seek.
**/
std::cout << "seeking to " << position << " s" << std::endl;
gst_element_seek (play,
1.0,
GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH,
GST_SEEK_TYPE_SET,
fpos,
GST_SEEK_TYPE_NONE, 0);
/**
* Restore state.
**/
gst_element_set_state (play, state);
Thanks in advance
Vincent
--
View this message in context: http://old.nabble.com/problem-to-seek-mp3-tp26196581p26196581.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
More information about the gstreamer-devel
mailing list