summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2013-08-02 16:46:20 +0200
committerLionel Landwerlin <llandwerlin@gmail.com>2013-11-18 16:15:28 +0000
commit37889b48957d1476f9f1a7641e72e1fec1f8025b (patch)
tree2c23eecca679c36311bbc96a0ac19996eef77feb
parent5db247a74be8495840c361f33ed5aefa5f71cc42 (diff)
downloadclutter-gst-37889b48957d1476f9f1a7641e72e1fec1f8025b.tar.gz
ClutterGstPlayback: implement a method to get position in seconds
-rw-r--r--clutter-gst/clutter-gst-playback.c30
-rw-r--r--clutter-gst/clutter-gst-playback.h1
2 files changed, 31 insertions, 0 deletions
diff --git a/clutter-gst/clutter-gst-playback.c b/clutter-gst/clutter-gst-playback.c
index 1aa4163..209ba76 100644
--- a/clutter-gst/clutter-gst-playback.c
+++ b/clutter-gst/clutter-gst-playback.c
@@ -812,6 +812,21 @@ set_subtitle_font_name (ClutterGstPlayback *self,
g_object_set (priv->pipeline, "subtitle-font-desc", font_name, NULL);
}
+static gdouble
+get_position (ClutterGstPlayback *self)
+{
+ ClutterGstPlaybackPrivate *priv = self->priv;
+ gboolean success;
+ GstFormat format = GST_FORMAT_TIME;
+ gint64 position;
+
+ success = gst_element_query_position (priv->pipeline, format, &position);
+ if (G_UNLIKELY (success != TRUE))
+ return 0.0;
+
+ return (gdouble) position / GST_SECOND;
+}
+
static gboolean
player_buffering_timeout (gpointer data)
{
@@ -2764,6 +2779,21 @@ clutter_gst_playback_get_progress (ClutterGstPlayback *self)
return get_progress (self);
}
+/**
+ * clutter_gst_playback_get_position:
+ * @self: a #ClutterGstPlayback
+ *
+ * Retrieves the position in the media stream that @self represents.
+ *
+ * Return value: the position in the media stream, in seconds
+ */
+gdouble
+clutter_gst_playback_get_position (ClutterGstPlayback *self)
+{
+ g_return_val_if_fail (CLUTTER_GST_IS_PLAYBACK (self), 0);
+
+ return get_position (self);
+}
/**
* clutter_gst_playback_get_duration:
diff --git a/clutter-gst/clutter-gst-playback.h b/clutter-gst/clutter-gst-playback.h
index ba8ae3e..d92905b 100644
--- a/clutter-gst/clutter-gst-playback.h
+++ b/clutter-gst/clutter-gst-playback.h
@@ -159,6 +159,7 @@ gboolean clutter_gst_playback_get_in_seek (ClutterGstPl
void clutter_gst_playback_set_progress (ClutterGstPlayback *self,
gdouble progress);
gdouble clutter_gst_playback_get_progress (ClutterGstPlayback *self);
+gdouble clutter_gst_playback_get_position (ClutterGstPlayback *self);
gdouble clutter_gst_playback_get_duration (ClutterGstPlayback *self);
gboolean clutter_gst_playback_is_live_media (ClutterGstPlayback *self);