def _on_signal(self, element, clocktime, func): # This shim is used to ensure we always return true, and also handles # that not all the callbacks have a time argument. if clocktime is None: func() else: func(utils.clocktime_to_millisecond(clocktime)) return True
def get_position(self): """ Get position in milliseconds. :rtype: int """ try: gst_position = self._playbin.query_position(gst.FORMAT_TIME)[0] return utils.clocktime_to_millisecond(gst_position) except gst.QueryError: logger.debug('Position query failed') return 0
def get_position(self): """ Get position in milliseconds. :rtype: int """ try: gst_position = self._playbin.query_position(gst.FORMAT_TIME)[0] return utils.clocktime_to_millisecond(gst_position) except gst.QueryError: # TODO: take state into account for this and possibly also return # None as the unknown value instead of zero? logger.debug('Position query failed') return 0
def get_position(self): """ Get position in milliseconds. :rtype: int """ success, position = self._playbin.query_position(Gst.Format.TIME) if not success: # TODO: take state into account for this and possibly also return # None as the unknown value instead of zero? logger.debug('Position query failed') return 0 return utils.clocktime_to_millisecond(position)
def _appsrc_on_seek_data(self, appsrc, gst_position): position = utils.clocktime_to_millisecond(gst_position) if self._appsrc_seek_data_callback is not None: self._appsrc_seek_data_callback(position) return True
def _appsrc_on_need_data(self, appsrc, gst_length_hint): length_hint = utils.clocktime_to_millisecond(gst_length_hint) if self._appsrc_need_data_callback is not None: self._appsrc_need_data_callback(length_hint) return True