Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)