- try:
- position, format = self._player.query_position(gst.FORMAT_TIME)
- except:
- position = 0
-
- # Create the seek event
- if rate > 0:
- seek_event = gst.event_new_seek(rate,
- gst.FORMAT_TIME,
- gst.SEEK_FLAG_FLUSH | gst.SEEK_FLAG_ACCURATE,
- gst.SEEK_TYPE_SET, position,
- gst.SEEK_TYPE_NONE, 0)
+ position = self._player.query_position(Gst.Format.TIME)[1]
+ self.set_seek(position)
+
+ def set_seek(self, position):
+ flags = Gst.SeekFlags.SKIP | Gst.SeekFlags.FLUSH | Gst.SeekFlags.ACCURATE
+
+ if self._rate >= 0:
+ seek_event = Gst.Event.new_seek(self._rate,
+ Gst.Format.TIME,
+ flags,
+ Gst.SeekType.SET, position,
+ Gst.SeekType.NONE, 0)