当前位置: 首页>>代码示例>>Python>>正文


Python Gst.SECOND属性代码示例

本文整理汇总了Python中gi.repository.Gst.SECOND属性的典型用法代码示例。如果您正苦于以下问题:Python Gst.SECOND属性的具体用法?Python Gst.SECOND怎么用?Python Gst.SECOND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在gi.repository.Gst的用法示例。


在下文中一共展示了Gst.SECOND属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_slider_seek

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def on_slider_seek(self, widget):
        if self.uri.endswith(".JPG"):
            seek_intvl = ply.slider.get_value()
            files = len(os.listdir("Images_100"))
            seek_file = int((files * seek_intvl) / 100)
            self.clear_playbin()
            self.setup_player(os.path.join("Images_100",
                                           sorted(os.listdir("Images_100"))[seek_file]),
                              )
            self.pause()
        elif not self.uri.endswith(".png"):
            seek_time = ply.slider.get_value()
            self.player.seek_simple(Gst.Format.TIME,
                                    Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT,
                                    seek_time * Gst.SECOND / self.mult,
                                    ) 
开发者ID:encarsia,项目名称:gpt,代码行数:18,代码来源:modules.py

示例2: set_position

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def set_position(self, position):
        if self.player is not None:
            self.player.get_state(Gst.CLOCK_TIME_NONE)
            self.player.set_state(Gst.State.PAUSED)
            try:
                assert self.player.seek_simple(Gst.Format.TIME,
                                               Gst.SeekFlags.FLUSH,
                                               position * Gst.SECOND)
                self.player.get_state(Gst.CLOCK_TIME_NONE)
                pos = self.player.query_position(Gst.Format.TIME)[1]
                self.player.seek(self.speed, Gst.Format.TIME,
                                 Gst.SeekFlags.FLUSH, Gst.SeekType.SET, pos,
                                 Gst.SeekType.NONE, -1)
            except AssertionError as e:
                print(e)
            self.player.set_state(Gst.State.PLAYING) 
开发者ID:atareao,项目名称:lplayer,代码行数:18,代码来源:player.py

示例3: _create_intersrc

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def _create_intersrc(self, audio_or_video):
        '''
        Create the intervideosrc / interaudiosrc
        '''
        assert(audio_or_video in ['audio', 'video'])

        # Create the receiving 'inter' element to accept the AV into the main pipeline
        self._intersrc_element[audio_or_video] =\
            self._add_element_to_dest_pipeline('inter%ssrc' % audio_or_video, audio_or_video)

        # We ask the src to hold the frame for 24 hours (basically, a very long time)
        # This is optional, but prevents it from going black when it's better to show the last frame.
        if audio_or_video is 'video':
            self._intersrc_element[audio_or_video].set_property('timeout', Gst.SECOND * 60 * 60 * 24)

        return self._intersrc_element[audio_or_video] 
开发者ID:bbc,项目名称:brave,代码行数:18,代码来源:connection_to_mixer.py

示例4: __init__

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def __init__(self):
        GObject.GObject.__init__(self)
        GstPbutils.pb_utils_init()
        self._discoverer = GstPbutils.Discoverer.new(10 * Gst.SECOND)

        self.is_playing = False
        self.filepath = None
        self._duration = Gst.CLOCK_TIME_NONE
        self.asset = None

        self._playbin = Gst.ElementFactory.make("playbin", "player")
        bus = self._playbin.get_bus()
        bus.add_signal_watch()
        bus.connect("message::error", self.__on_bus_error)
        bus.connect("message::eos", self.__on_bus_eos)
        bus.connect("message::element", self.__on_bus_element)
        bus.connect("message::stream-start", self._on_stream_start) 
开发者ID:bilelmoussaoui,项目名称:Audio-Cutter,代码行数:19,代码来源:player.py

示例5: _notify_caps

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def _notify_caps(self, pad, *args):
        """notify::caps callback"""
        self._caps = True
        info = pad.get_current_caps().get_structure(0)

        self._duration = pad.get_peer().query_duration(Gst.Format.TIME).duration / Gst.SECOND
        channels = info.get_int('channels')[1]
        sample_rate = info.get_int('rate')[1]
        sample_size = int("".join(filter(str.isdigit, info.get_string('format'))))

        self.audio_format = AudioFormat(channels=channels,
                                        sample_size=sample_size,
                                        sample_rate=sample_rate)

        # Allow __init__ to complete:
        self._is_ready.set() 
开发者ID:pyglet,项目名称:pyglet,代码行数:18,代码来源:gstreamer.py

示例6: get_audio_data

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def get_audio_data(self, num_bytes, compensation_time=0.0):
        if self._finished.is_set():
            return None

        data = bytes()
        while len(data) < num_bytes:
            packet = self._queue.get()
            if packet == self._sentinal:
                self._finished.set()
                break
            data += packet

        if not data:
            return None

        timestamp = self._pipeline.query_position(Gst.Format.TIME).cur / Gst.SECOND
        duration = self.audio_format.bytes_per_second / len(data)

        return AudioData(data, len(data), timestamp, duration, []) 
开发者ID:pyglet,项目名称:pyglet,代码行数:21,代码来源:gstreamer.py

示例7: _get_length

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def _get_length(self):
        if self._data is not None:
            if self._data.get_state()[1] != Gst.State.PLAYING:
                volume_before = self._data.get_property('volume')
                self._data.set_property('volume', 0)
                self._data.set_state(Gst.State.PLAYING)
                try:
                    self._data.get_state()
                    ret, value = self._data.query_duration(Gst.Format.TIME)
                    if ret:
                        return value / float(Gst.SECOND)
                finally:
                    self._data.set_state(Gst.State.NULL)
                    self._data.set_property('volume', volume_before)
            else:
                ret, value = self._data.query_duration(Gst.Format.TIME)
                if ret:
                    return value / float(Gst.SECOND)
        return super(SoundGi, self)._get_length() 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:21,代码来源:audio_gi.py

示例8: update_slider

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def update_slider(self):
        if not self.is_playing:
            return False # cancel timeout
            
        else:
            success, self.duration = self.playbin.query_duration(Gst.Format.TIME)
            if not success:
                raise GenericException("Couldn't fetch song duration")
            else:
                self.slider.set_range(0, self.duration / Gst.SECOND)
            #fetching the position, in nanosecs
            success, position = self.playbin.query_position(Gst.Format.TIME)
            if not success:
                raise GenericException("Couldn't fetch current song position to update slider")

            # block seek handler so we don't seek when we set_value()
            self.slider.handler_block(self.slider_handler_id)

            self.slider.set_value(float(position) / Gst.SECOND)

            self.slider.handler_unblock(self.slider_handler_id)

        return True # continue calling every x milliseconds 
开发者ID:hadware,项目名称:gstreamer-python-player,代码行数:25,代码来源:seek.py

示例9: skip_minute

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def skip_minute(self, direction=1):
        self.player.seek_simple(Gst.Format.TIME,
                                Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT,
                                self.current_position() + float(60) * Gst.SECOND * direction,
                                ) 
开发者ID:encarsia,项目名称:gpt,代码行数:7,代码来源:modules.py

示例10: update_slider

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def update_slider(self):
        if not self.is_playing:
            return False  # cancel timeout
        else:
            success, self.duration = self.player.query_duration(Gst.Format.TIME)
            # adjust duration and position relative to absolute scale of 100
            try:
                self.mult = 100 / (self.duration / Gst.SECOND)
            except ZeroDivisionError:
                cli.log.exception(_("Exception error"))
            if not success:
                # raise SliderUpdateException("Couldn"t fetch duration")
                cli.log.warning(_("Couldn't fetch duration"))
            # fetching the position, in nanosecs
            success, position = self.player.query_position(Gst.Format.TIME)
            if not success:
                # raise SliderUpdateException("Couldn"t fetch current position to update slider")
                cli.log.warning(_("Couldn't fetch current position to update slider"))

            # block seek handler so we don"t seek when we set_value()
            self.slider.handler_block(self.slider_handler_id)

            self.slider.set_value(float(position) / Gst.SECOND * self.mult)

            self.slider.handler_unblock(self.slider_handler_id)
        return True  # continue calling every x milliseconds 
开发者ID:encarsia,项目名称:gpt,代码行数:28,代码来源:modules.py

示例11: get_position

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def get_position(self):
        if self.player is not None:
            self.player.get_state(Gst.CLOCK_TIME_NONE)
            nanosecs = self.player.query_position(Gst.Format.TIME)[1]
            position = float(nanosecs) / Gst.SECOND
            return position
        return 0 
开发者ID:atareao,项目名称:lplayer,代码行数:9,代码来源:player.py

示例12: get_duration

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def get_duration(self):
        if self.player is not None:
            self.player.get_state(Gst.CLOCK_TIME_NONE)
            duration_nanosecs = self.player.query_duration(Gst.Format.TIME)[1]
            duration = float(duration_nanosecs) / Gst.SECOND
            return duration
        return 0 
开发者ID:atareao,项目名称:lplayer,代码行数:9,代码来源:player.py

示例13: _video_pipeline_start

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def _video_pipeline_start(self):
        '''
        The standard start to the pipeline string for video.
        It starts with intervideosrc, which accepts video from the source.
        '''
        # The large timeout holds any stuck frame for 24 hours (basically, a very long time)
        # This is optional, but prevents it from going black when it's better to show the last frame.
        timeout = Gst.SECOND * 60 * 60 * 24
        return ('intervideosrc name=intervideosrc timeout=%d ! videoconvert ! videoscale ! '
                'videorate ! capsfilter name=capsfilter ! ' % timeout) 
开发者ID:bbc,项目名称:brave,代码行数:12,代码来源:output.py

示例14: pixelToNs

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def pixelToNs(cls, pixel):
        """Returns the duration equivalent of the specified pixel."""
        return int(pixel * Gst.SECOND / cls.zoomratio) 
开发者ID:bilelmoussaoui,项目名称:Audio-Cutter,代码行数:5,代码来源:audio_graph.py

示例15: pixelToNsAt

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def pixelToNsAt(cls, pixel, ratio):
        """Returns the duration equivalent of the specified pixel."""
        return int(pixel * Gst.SECOND / ratio) 
开发者ID:bilelmoussaoui,项目名称:Audio-Cutter,代码行数:5,代码来源:audio_graph.py


注:本文中的gi.repository.Gst.SECOND属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。