#include <gst/gst.h>
static int seek_table[] = { 5, 10, 20, 15};
int
main (int argc, gchar ** argv)
{
  GstElement *playbin;
  gint64 position;
  gchar *uri;

  gst_init(&argc, &argv);


  playbin = gst_element_factory_make("playbin", NULL);

 /* set uri filename */
  if (gst_uri_is_valid (argv[1]))
    uri = g_strdup (argv[1]);
  else
    uri = gst_filename_to_uri (argv[1], NULL);
  g_object_set (playbin, "uri", uri, NULL);
  g_free (uri);

  /* get into preroll  state*/
  gst_element_set_state(playbin,GST_STATE_PAUSED);

  gst_element_get_state(playbin, NULL, NULL, -1);

  for (int i=0;i<sizeof(seek_table)/sizeof(seek_table[0]);i++) {
     /* do seek */
     gst_element_seek(playbin, 
        1.0,
	GST_FORMAT_TIME,
        (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
        GST_SEEK_TYPE_SET, seek_table[i] * GST_SECOND,
        GST_SEEK_TYPE_NONE, 0);

     /* wait for state to finish */
     gst_element_get_state(playbin, NULL, NULL, 4*GST_SECOND);

     /* get position */
     gst_element_query_position(playbin,GST_FORMAT_TIME,&position); 

     g_message("seek(%d) to position(%d s), playbin position after seek:%" GST_TIME_FORMAT, i, seek_table[i], GST_TIME_ARGS(position));
  }

  gst_element_set_state(playbin,GST_STATE_NULL);

  return 0;
}

