Loop player for GStreamer

Thomas Scheuermann scheuermann at barco.com
Mon May 4 00:15:20 PDT 2015


Hi all,

I need to write a player that loops over a file and plays it
continuously. I found in some mails that I should use gst_element_seek
with GST_SEEK_FLAG_SEGMENT. But it doesn't work. Here is the event loop
I use:

     bus = gst_pipeline_get_bus(GST_PIPELINE(bin));

     while(!done)
     {
         message = gst_bus_timed_pop(bus, GST_CLOCK_TIME_NONE);
         switch(GST_MESSAGE_TYPE(message))
         {
             case GST_MESSAGE_ERROR:
                 g_print("Error occured\n");
                 g_print("%s :\n", GST_MESSAGE_SRC_NAME(message));
                 break;
             case GST_MESSAGE_STATE_CHANGED:
gst_element_get_state(GST_ELEMENT(GST_MESSAGE_SRC(message)), &state,
NULL, 0);
                 g_print("Element %s changed state to %d\n",
GST_MESSAGE_SRC_NAME(message), state);
                 if(GST_ELEMENT(message->src) == bin) {
                     if(state == GST_STATE_PLAYING) {
                         g_print("gst_element_seek (end)\n");
                         if(!gst_element_seek(bin, 1.0, GST_FORMAT_TIME,
GST_SEEK_FLAG_SEGMENT, GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_END, 0)) {
                             g_print("gst_element_seek failed\n");
                         }
                     }
                 }
                 break;
             case GST_MESSAGE_EOS:
                 g_print("End Of Stream\n");
                 done = TRUE;
                 break;
             case GST_MESSAGE_SEGMENT_DONE:
                 g_print("segment done\n");
                         g_print("gst_element_seek_simple (pos)\n");
                         if(!gst_element_seek_simple(bin,
GST_FORMAT_TIME, GST_SEEK_FLAG_SNAP_NEAREST | GST_SEEK_FLAG_FLUSH, 0)) {
                             g_print("gst_element_seek_simple failed\n");
                         }
                 break;
             default:
                 g_print("Messgae %s\n", GST_MESSAGE_TYPE_NAME(message));
                 break;
         }
         gst_message_unref(message);
     }
     gst_object_unref(bus);

I don't know if these are the correct seek functions I call.
How and with which arguments should I call the seek functions that I get
the the player playing the file in a loop?

Regards,

Thomas
This message is subject to the following terms and conditions: MAIL DISCLAIMER<http://www.barco.com/en/maildisclaimer>


More information about the gstreamer-devel mailing list