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 |
may be you should check the return value of
gst_element_seek (play, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, fpos, GST_SEEK_TYPE_NONE, 0); only if its true means the seeking is possible else not. On Wed, Nov 4, 2009 at 10:37 PM, vincent meserette <[hidden email]> wrote:
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |