mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 11:11:08 +00:00
tests: use elapsed label of volume example
This commit is contained in:
parent
b2db18cda2
commit
bd2a86e353
1 changed files with 21 additions and 2 deletions
|
@ -64,8 +64,8 @@ setup_gui (GstElement * volume)
|
|||
|
||||
/* elapsed widget */
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
label = gtk_label_new ("Elapsed");
|
||||
elapsed = gtk_label_new ("0.000");
|
||||
label = gtk_label_new ("Elapsed: ");
|
||||
elapsed = gtk_label_new ("0.0");
|
||||
gtk_container_add (GTK_CONTAINER (hbox), label);
|
||||
gtk_container_add (GTK_CONTAINER (hbox), elapsed);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), hbox);
|
||||
|
@ -86,6 +86,24 @@ setup_gui (GstElement * volume)
|
|||
gtk_widget_show_all (GTK_WIDGET (window));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
progress_update (gpointer data)
|
||||
{
|
||||
GstElement *pipeline = (GstElement *) data;
|
||||
gint64 position;
|
||||
gchar *position_str;
|
||||
|
||||
if (gst_element_query_position (pipeline, GST_FORMAT_TIME, &position))
|
||||
position_str = g_strdup_printf ("%.1f", (gfloat) position / GST_SECOND);
|
||||
else
|
||||
position_str = g_strdup_printf ("n/a");
|
||||
gtk_label_set_text (GTK_LABEL (elapsed), position_str);
|
||||
|
||||
g_free (position_str);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
|
||||
{
|
||||
|
@ -165,6 +183,7 @@ main (int argc, char *argv[])
|
|||
|
||||
/* go to main loop */
|
||||
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||
g_timeout_add (100, progress_update, pipeline);
|
||||
gtk_main ();
|
||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||
gst_object_unref (pipeline);
|
||||
|
|
Loading…
Reference in a new issue