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


Python Engine.query_position方法代码示例

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


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

示例1: Wolfgang

# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import query_position [as 别名]

#.........这里部分代码省略.........
        self.previous_button.set_sensitive(False)
        self.next_button.set_sensitive(False)
        if self.queue_store.iter_previous(self.queue_current_iter):
            self.previous_button.set_sensitive(True)
        if self.queue_store.iter_next(self.queue_current_iter):
            self.next_button.set_sensitive(True)

    def _sliderMouseEvent(self, widget, event):
        """
        We handle the mouse button clicks and movements (scrubbing) here.
        This is thus called by button-press-event, button-release-event and
        motion-notify-event.

        This is also where seeks are triggered on click.
        """
        if Gtk.get_major_version() >= 3 and Gtk.get_minor_version() < 6:
            # Override the event button to use a middle-click when left-clicking
            # the slider, allowing it to wark directly to the desired position.
            # This behavior has been fixed in GTK 3.6.
            event.button = 2
        if event.type is Gdk.EventType.BUTTON_PRESS:
            self._sliderGrabbed = True
        elif event.type is Gdk.EventType.BUTTON_RELEASE:
            self._sliderGrabbed = False

        if event.type is Gdk.EventType.BUTTON_RELEASE:
            target_percent = widget.get_adjustment().props.value / 100.0
            duration = self.engine.query_duration()
            target_position = target_percent * duration
            self.engine.seek(target_position)

    def _updateSliderPosition(self):
        if self.is_playing and not self._sliderGrabbed:
            pos = self.engine.query_position()
            duration = self.engine.query_duration()
            if not duration == 0:  # GStreamer nonsense, occurring randomly.
                print "Position is", pos, "and duration is", duration
                new_slider_pos = pos / float(duration) * 100
                print "\tUpdate slider position to", new_slider_pos
                self.time_slider.get_adjustment().props.value = new_slider_pos
        return True

    def quit(self, unused_window=None, unused_event=None):
        Gtk.main_quit
        exit(0)

    """
    Public playback methods (not callbacks)
    """
    def play(self):
        if self.uri is None:
            # The user clicked play without selecting a track, play the 1st
            self.uri = self.queue_store.get_value(self.queue_current_iter, 2)
            self.queue_store.set_value(self.queue_current_iter, 0, "♪")
        self.engine.play(self.uri)
        self.is_playing = True
        self.play_button.props.active = True
        self.time_slider.set_sensitive(True)
        if self.queue_store.iter_next(self.queue_current_iter):
            self.next_button.set_sensitive(True)
        if self.queue_store.iter_previous(self.queue_current_iter):
            self.previous_button.set_sensitive(True)

    def pause(self):
        self.engine.pause()
        self.play_button.props.active = False
开发者ID:luisbg,项目名称:wolfgang,代码行数:70,代码来源:wolfgang.py


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