def get_duration(self): try: duration, fmt = self.playbin.query_duration(gst.FORMAT_TIME) return gstutil.to_seconds(duration) except gst.QueryError, qe: logging.warn("get_duration: caught exception: %s" % qe) return None
def get_current_time(self, attempt=0): # query_position fails periodically, so this attempts it 5 times # and if after that it fails, then we return 0. if not self.playbin or attempt == 5: return 0 try: position, fmt = self.playbin.query_position(gst.FORMAT_TIME) return gstutil.to_seconds(position) except gst.QueryError, qe: logging.warn("get_current_time: caught exception: %s" % qe) return self.get_current_time(attempt + 1)
def get_current_time(self, attempt=0): # query_position fails periodically, so this attempts it 5 times # and if after that it fails, then we return 0. if attempt == 5: return 0 try: position, fmt = self.playbin.query_position(gst.FORMAT_TIME) return gstutil.to_seconds(position) except gst.QueryError, qe: logging.warn("get_current_time: caught exception: %s" % qe) return self.get_current_time(attempt + 1)