本文整理汇总了Python中buffer.Buffer.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Buffer.connect方法的具体用法?Python Buffer.connect怎么用?Python Buffer.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buffer.Buffer
的用法示例。
在下文中一共展示了Buffer.connect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: YouTubePlayer
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import connect [as 别名]
class YouTubePlayer(cream.Module):
state = STATE_NULL
fullscreen = False
_current_video_id = None
_seek_timeout = None
def __init__(self):
cream.Module.__init__(self)
self.videos = {}
# Connect to YouTube:
self.youtube = youtube.API(YOUTUBE_DEVELOPER_KEY)
self.threadlock = Lock(self)
# Build GTK+ interface:
self.ui = cream.gui.builder.GtkBuilderInterface(INTERFACE_FILE)
self.ui.throbber = Throbber()
self.ui.slider = cream.gui.widgets.slider.Slider()
self.ui.slider.append_widget(self.ui.search_box)
self.ui.slider.append_widget(self.ui.info_box)
self.ui.slider.set_size_request(240, 300)
self.ui.sidebar.add(self.ui.slider)
self.ui.fullscreen_window.fullscreen()
self.ui.fullscreen_video_area.set_app_paintable(True)
self.ui.fullscreen_video_area.connect("button-press-event", self.video_area_click_cb)
self.ui.fullscreen_video_area.connect("expose-event", self.expose_cb)
self.ui.video_area.set_app_paintable(True)
self.ui.video_area.connect("expose-event", self.expose_cb)
self.ui.video_area.connect("button-press-event", self.video_area_click_cb)
self.ui.play_pause_image.set_from_icon_name("media-playback-start", gtk.ICON_SIZE_BUTTON)
self.ui.play_pause_button.connect("clicked", self.play_pause_cb)
self.ui.search_entry.connect("activate", self.search_cb)
self.ui.search_entry.connect("icon-release", lambda *args: self.ui.sort_by_menu.popup(None, None, None, 1, 0))
self.ui.resolution_chooser.connect("changed", self.resolution_changed_cb)
self.ui.sort_by_menu.connect("selection-done", self.search_cb)
self.ui.back_to_search_button.connect("clicked", self.back_to_search_button_clicked_cb)
self.ui.info_label_description.connect(
"size-allocate", lambda source, allocation: source.set_size_request(allocation.width - 2, -1)
)
self.ui.show_subtitles_btn.connect("toggled", self.subtitles_toggled_cb)
self.ui.progress_scale.connect("change-value", self.seek_cb)
def _reset_timeout(*args):
self.ui.slider.try_reset_slide_timeout(self.ui.info_box)
self.ui.search_entry.connect("changed", _reset_timeout)
self.ui.search_entry.connect("motion-notify-event", _reset_timeout)
self.ui.search_results_treeview.connect("motion-notify-event", _reset_timeout)
self.ui.search_results_treeview.connect("row-activated", self.row_activated_cb)
self.ui.search_results_treeview.connect("size-allocate", self.treeview_size_allocate_cb)
self.buffer = Buffer()
self.buffer.connect("update", self.buffer_update_cb)
self.buffer.connect("ready", lambda *args: self.set_state(STATE_BUFFERING))
# Initialize GStreamer stuff:
self.player = gst.Pipeline("player")
self.playbin = gst.element_factory_make("playbin2", "playbin")
self.video_sink = gst.element_factory_make("xvimagesink", "vsink")
self.playbin.set_property("video-sink", self.video_sink)
self.playbin.set_property("buffer-duration", 10000000000)
self.playbin.set_property("buffer-size", 2000000000)
self.player.add(self.playbin)
bus = self.player.get_bus()
bus.add_signal_watch()
bus.enable_sync_message_emission()
bus.connect("message", self.on_message)
bus.connect("sync-message::element", self.on_sync_message)
self.ui.window.connect("destroy", lambda *args: self.quit())
self.ui.window.show_all()
gobject.timeout_add(200, self.update_progressbar)
def buffer_update_cb(self, source, position):
self.ui.progress_scale.set_fill_level(max(0, position - 1))
if position == -1:
self.ui.throbber.set_mode(MODE_SPINNING)
else:
self.ui.throbber.set_mode(MODE_STATIC)
try:
duration = self.playbin.query_duration(gst.FORMAT_TIME, None)[0]
except gst.QueryError:
#.........这里部分代码省略.........