summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavi Artigas <xartigas@fluendo.com>2012-11-07 10:55:45 (GMT)
committerXavi Artigas <xartigas@fluendo.com>2012-11-07 10:55:45 (GMT)
commit36d03232e1c593e8d590333cbae73e9f8d7394f3 (patch)
treefd052c4a9802dfbc8be6d526e5436b8d74d7a272
parent3c9c405464545f9736bdde90d2490ffb4e1aa345 (diff)
downloadgst-sdk-tutorials-36d03232e1c593e8d590333cbae73e9f8d7394f3.tar.gz
gst-sdk-tutorials-36d03232e1c593e8d590333cbae73e9f8d7394f3.tar.xz
Handle media with no position or duration correctly (pictures, for example)
-rwxr-xr-xgst-sdk/tutorials/android-tutorial-5/jni/tutorial-5.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/gst-sdk/tutorials/android-tutorial-5/jni/tutorial-5.c b/gst-sdk/tutorials/android-tutorial-5/jni/tutorial-5.c
index 2bf1d57..33d4bc0 100755
--- a/gst-sdk/tutorials/android-tutorial-5/jni/tutorial-5.c
+++ b/gst-sdk/tutorials/android-tutorial-5/jni/tutorial-5.c
@@ -135,14 +135,18 @@ static gboolean refresh_ui (CustomData *data) {
/* If we didn't know it yet, query the stream duration */
if (!GST_CLOCK_TIME_IS_VALID (data->duration)) {
if (!gst_element_query_duration (data->pipeline, &fmt, &data->duration)) {
- GST_WARNING ("Could not query current duration");
+ GST_WARNING ("Could not query current duration (normal for still pictures)");
+ data->duration = 0;
}
}
- if (gst_element_query_position (data->pipeline, &fmt, &position)) {
- /* Java expects these values in milliseconds, and GStreamer provides nanoseconds */
- set_current_ui_position (position / GST_MSECOND, data->duration / GST_MSECOND, data);
+ if (!gst_element_query_position (data->pipeline, &fmt, &position)) {
+ GST_WARNING ("Could not query current position (normal for still pictures)");
+ position = 0;
}
+
+ /* Java expects these values in milliseconds, and GStreamer provides nanoseconds */
+ set_current_ui_position (position / GST_MSECOND, data->duration / GST_MSECOND, data);
return TRUE;
}