本文整理汇总了Python中pitivi.utils.pipeline.Seeker.seek方法的典型用法代码示例。如果您正苦于以下问题:Python Seeker.seek方法的具体用法?Python Seeker.seek怎么用?Python Seeker.seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pitivi.utils.pipeline.Seeker
的用法示例。
在下文中一共展示了Seeker.seek方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PitiviViewer
# 需要导入模块: from pitivi.utils.pipeline import Seeker [as 别名]
# 或者: from pitivi.utils.pipeline.Seeker import seek [as 别名]
class PitiviViewer(Gtk.VBox, Loggable):
"""
A Widget to control and visualize a Pipeline
@ivar pipeline: The current pipeline
@type pipeline: L{Pipeline}
@ivar action: The action controlled by this Pipeline
@type action: L{ViewAction}
"""
__gtype_name__ = 'PitiviViewer'
__gsignals__ = {
"activate-playback-controls": (GObject.SignalFlags.RUN_LAST,
None, (GObject.TYPE_BOOLEAN,)),
}
INHIBIT_REASON = _("Currently playing")
def __init__(self, app, undock_action=None):
Gtk.VBox.__init__(self)
self.set_border_width(SPACING)
self.app = app
self.settings = app.settings
self.system = app.system
Loggable.__init__(self)
self.log("New PitiviViewer")
self.pipeline = None
self._tmp_pipeline = None # Used for displaying a preview when trimming
self.sink = None
self.docked = True
# Only used for restoring the pipeline position after a live clip trim preview:
self._oldTimelinePos = None
self._haveUI = False
self._createUi()
self.target = self.internal
self.undock_action = undock_action
if undock_action:
self.undock_action.connect("activate", self._toggleDocked)
if not self.settings.viewerDocked:
self.undock()
def setPipeline(self, pipeline, position=None):
"""
Set the Viewer to the given Pipeline.
Properly switches the currently set action to that new Pipeline.
@param pipeline: The Pipeline to switch to.
@type pipeline: L{Pipeline}.
@param position: Optional position to seek to initially.
"""
self.debug("self.pipeline:%r", self.pipeline)
self.seeker = Seeker()
self._disconnectFromPipeline()
if self.pipeline:
self.pipeline.set_state(Gst.State.NULL)
self.pipeline = pipeline
if self.pipeline:
self.pipeline.pause()
self.seeker.seek(position)
self.pipeline.connect("state-change", self._pipelineStateChangedCb)
self.pipeline.connect("position", self._positionCb)
self.pipeline.connect("window-handle-message", self._windowHandleMessageCb)
self.pipeline.connect("duration-changed", self._durationChangedCb)
self._setUiActive()
def _disconnectFromPipeline(self):
self.debug("pipeline:%r", self.pipeline)
if self.pipeline is None:
# silently return, there's nothing to disconnect from
return
self.pipeline.disconnect_by_func(self._pipelineStateChangedCb)
self.pipeline.disconnect_by_func(self._windowHandleMessageCb)
self.pipeline.disconnect_by_func(self._positionCb)
self.pipeline.disconnect_by_func(self._durationChangedCb)
self.pipeline = None
def _setUiActive(self, active=True):
self.debug("active %r", active)
self.set_sensitive(active)
if self._haveUI:
for item in [self.goToStart_button, self.back_button,
self.playpause_button, self.forward_button,
self.goToEnd_button, self.timecode_entry]:
item.set_sensitive(active)
if active:
self.emit("activate-playback-controls", True)
#.........这里部分代码省略.........
示例2: ScaleRuler
# 需要导入模块: from pitivi.utils.pipeline import Seeker [as 别名]
# 或者: from pitivi.utils.pipeline.Seeker import seek [as 别名]
class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
__gsignals__ = {
"button-press-event": "override",
"button-release-event": "override",
"motion-notify-event": "override",
"scroll-event": "override",
"seek": (GObject.SignalFlags.RUN_LAST, None,
[GObject.TYPE_UINT64])
}
border = 0
min_tick_spacing = 3
scale = [0, 0, 0, 0.5, 1, 2, 5, 10, 15, 30, 60, 120, 300, 600, 3600]
subdivide = ((1, 1.0), (2, 0.5), (10, .25))
def __init__(self, instance, hadj):
Gtk.DrawingArea.__init__(self)
Zoomable.__init__(self)
Loggable.__init__(self)
self.log("Creating new ScaleRuler")
self.app = instance
self._seeker = Seeker()
self.hadj = hadj
hadj.connect("value-changed", self._hadjValueChangedCb)
self.add_events(Gdk.EventMask.POINTER_MOTION_MASK |
Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK |
Gdk.EventMask.SCROLL_MASK)
self.pixbuf = None
# all values are in pixels
self.pixbuf_offset = 0
self.pixbuf_offset_painted = 0
# This is the number of width we allocate for the pixbuf
self.pixbuf_multiples = 4
self.position = 0 # In nanoseconds
self.pressed = False
self.min_frame_spacing = 5.0
self.frame_height = 5.0
self.frame_rate = Gst.Fraction(1 / 1)
self.ns_per_frame = float(1 / self.frame_rate) * Gst.SECOND
self.connect('draw', self.drawCb)
self.connect('configure-event', self.configureEventCb)
self.callback_id = None
self.callback_id_scroll = None
def _hadjValueChangedCb(self, hadj):
self.pixbuf_offset = self.hadj.get_value()
if self.callback_id_scroll is not None:
GLib.source_remove(self.callback_id_scroll)
self.callback_id_scroll = GLib.timeout_add(100, self._maybeUpdate)
## Zoomable interface override
def _maybeUpdate(self):
self.queue_draw()
self.callback_id = None
return False
def zoomChanged(self):
if self.callback_id is not None:
GLib.source_remove(self.callback_id)
self.callback_id = GLib.timeout_add(100, self._maybeUpdate)
## timeline position changed method
def timelinePositionChanged(self, value, unused_frame=None):
self.position = value
self.queue_draw()
## Gtk.Widget overrides
def configureEventCb(self, widget, event, data=None):
self.debug("Configuring, height %d, width %d",
widget.get_allocated_width(), widget.get_allocated_height())
# Destroy previous buffer
if self.pixbuf is not None:
self.pixbuf.finish()
self.pixbuf = None
# Create a new buffer
self.pixbuf = cairo.ImageSurface(cairo.FORMAT_ARGB32,
widget.get_allocated_width(), widget.get_allocated_height())
return False
def drawCb(self, widget, cr):
if self.pixbuf is not None:
db = self.pixbuf
# Create cairo context with double buffer as is DESTINATION
cc = cairo.Context(db)
#draw everything
self.drawBackground(cc)
self.drawRuler(cc)
self.drawPosition(cc)
db.flush()
#.........这里部分代码省略.........
示例3: ScaleRuler
# 需要导入模块: from pitivi.utils.pipeline import Seeker [as 别名]
# 或者: from pitivi.utils.pipeline.Seeker import seek [as 别名]
class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
"""
Widget for displaying the ruler.
Displays a series of consecutive intervals. For each interval its beginning
time is shown. If zoomed in enough, shows the frames in alternate colors.
"""
__gsignals__ = {
"button-press-event": "override",
"button-release-event": "override",
"motion-notify-event": "override",
"scroll-event": "override",
"seek": (GObject.SignalFlags.RUN_LAST, None,
[GObject.TYPE_UINT64])
}
def __init__(self, timeline, hadj):
Gtk.DrawingArea.__init__(self)
Zoomable.__init__(self)
Loggable.__init__(self)
self.log("Creating new ScaleRuler")
# Allows stealing focus from other GTK widgets, prevent accidents:
self.props.can_focus = True
self.connect("focus-in-event", self._focusInCb)
self.connect("focus-out-event", self._focusOutCb)
self.timeline = timeline
self._background_color = timeline.get_style_context().lookup_color('theme_bg_color')[1]
self._seeker = Seeker()
self.hadj = hadj
hadj.connect("value-changed", self._hadjValueChangedCb)
self.add_events(Gdk.EventMask.POINTER_MOTION_MASK |
Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK |
Gdk.EventMask.SCROLL_MASK)
self.pixbuf = None
# all values are in pixels
self.pixbuf_offset = 0
self.pixbuf_offset_painted = 0
# This is the number of width we allocate for the pixbuf
self.pixbuf_multiples = 4
self.position = 0 # In nanoseconds
self.pressed = False
self.frame_rate = Gst.Fraction(1 / 1)
self.ns_per_frame = float(1 / self.frame_rate) * Gst.SECOND
self.connect('draw', self.drawCb)
self.connect('configure-event', self.configureEventCb)
self.callback_id = None
self.callback_id_scroll = None
self.set_size_request(0, 25)
style = self.get_style_context()
color_normal = style.get_color(Gtk.StateFlags.NORMAL)
color_insensitive = style.get_color(Gtk.StateFlags.INSENSITIVE)
self._color_normal = color_normal
self._color_dimmed = Gdk.RGBA(
*[(x * 3 + y * 2) / 5
for x, y in ((color_normal.red, color_insensitive.red),
(color_normal.green, color_insensitive.green),
(color_normal.blue, color_insensitive.blue))])
self.scales = SCALES
def _focusInCb(self, unused_widget, unused_arg):
self.log("Ruler has grabbed focus")
self.timeline.setActionsSensitivity(True)
def _focusOutCb(self, unused_widget, unused_arg):
self.log("Ruler has lost focus")
self.timeline.setActionsSensitivity(False)
def _hadjValueChangedCb(self, unused_arg):
self.pixbuf_offset = self.hadj.get_value()
if self.callback_id_scroll is not None:
GLib.source_remove(self.callback_id_scroll)
self.callback_id_scroll = GLib.timeout_add(100, self._maybeUpdate)
## Zoomable interface override
def _maybeUpdate(self):
self.queue_draw()
self.callback_id = None
self.callback_id_scroll = None
return False
def zoomChanged(self):
if self.callback_id is not None:
GLib.source_remove(self.callback_id)
self.callback_id = GLib.timeout_add(100, self._maybeUpdate)
## timeline position changed method
def setPipeline(self, pipeline):
pipeline.connect('position', self.timelinePositionCb)
def timelinePositionCb(self, unused_pipeline, position):
#.........这里部分代码省略.........
示例4: ViewerContainer
# 需要导入模块: from pitivi.utils.pipeline import Seeker [as 别名]
# 或者: from pitivi.utils.pipeline.Seeker import seek [as 别名]
class ViewerContainer(Gtk.Box, Loggable):
"""
A wiget holding a viewer and the controls.
"""
__gtype_name__ = 'ViewerContainer'
__gsignals__ = {
"activate-playback-controls": (GObject.SignalFlags.RUN_LAST,
None, (GObject.TYPE_BOOLEAN,)),
}
INHIBIT_REASON = _("Currently playing")
def __init__(self, app):
Gtk.Box.__init__(self)
self.set_border_width(SPACING)
self.app = app
self.settings = app.settings
self.system = app.system
Loggable.__init__(self)
self.log("New ViewerContainer")
self.pipeline = None
self.docked = True
self.seeker = Seeker()
self.target = None
# Only used for restoring the pipeline position after a live clip trim
# preview:
self._oldTimelinePos = None
self._haveUI = False
self._createUi()
self.__owning_pipeline = False
if not self.settings.viewerDocked:
self.undock()
def setPipeline(self, pipeline, position=None):
"""
Set the Viewer to the given Pipeline.
Properly switches the currently set action to that new Pipeline.
@param pipeline: The Pipeline to switch to.
@type pipeline: L{Pipeline}.
@param position: Optional position to seek to initially.
"""
self._disconnectFromPipeline()
if self.target:
parent = self.target.get_parent()
if parent:
parent.remove(self.target)
self.debug("New pipeline: %r", pipeline)
self.pipeline = pipeline
if position:
self.seeker.seek(position)
self.pipeline.connect("state-change", self._pipelineStateChangedCb)
self.pipeline.connect("position", self._positionCb)
self.pipeline.connect("duration-changed", self._durationChangedCb)
self.__owning_pipeline = False
self.__createNewViewer()
self._setUiActive()
self.pipeline.pause()
def __createNewViewer(self):
self.sink = self.pipeline.createSink()
self.pipeline.setSink(self.sink)
self.target = ViewerWidget(self.sink, self.app)
if self.docked:
self.pack_start(self.target, True, True, 0)
screen = Gdk.Screen.get_default()
height = screen.get_height()
if height >= 800:
# show the controls and force the aspect frame to have at least the same
# width (+110, which is a magic number to minimize dead padding).
req = self.buttons.size_request()
width = req.width
height = req.height
width += 110
height = int(width / self.target.props.ratio)
self.target.set_size_request(width, height)
else:
self.external_vbox.pack_start(self.target, False, False, 0)
self.target.props.expand = True
self.external_vbox.child_set(self.target, fill=True)
self.setDisplayAspectRatio(self.app.project_manager.current_project.getDAR())
self.target.show_all()
def _disconnectFromPipeline(self):
#.........这里部分代码省略.........
示例5: ViewerContainer
# 需要导入模块: from pitivi.utils.pipeline import Seeker [as 别名]
# 或者: from pitivi.utils.pipeline.Seeker import seek [as 别名]
class ViewerContainer(Gtk.VBox, Loggable):
"""
A wiget holding a viewer and the controls.
"""
__gtype_name__ = 'ViewerContainer'
__gsignals__ = {
"activate-playback-controls": (GObject.SignalFlags.RUN_LAST,
None, (GObject.TYPE_BOOLEAN,)),
}
INHIBIT_REASON = _("Currently playing")
def __init__(self, app, undock_action=None):
Gtk.VBox.__init__(self)
self.set_border_width(SPACING)
self.app = app
self.settings = app.settings
self.system = app.system
Loggable.__init__(self)
self.log("New ViewerContainer")
self.pipeline = None
self.docked = True
self.seeker = Seeker()
# Only used for restoring the pipeline position after a live clip trim preview:
self._oldTimelinePos = None
self._haveUI = False
self._createUi()
self.undock_action = undock_action
if undock_action:
self.undock_action.connect("activate", self._toggleDocked)
if not self.settings.viewerDocked:
self.undock()
@property
def target(self):
if self.docked:
return self.internal
else:
return self.external
def setPipeline(self, pipeline, position=None):
"""
Set the Viewer to the given Pipeline.
Properly switches the currently set action to that new Pipeline.
@param pipeline: The Pipeline to switch to.
@type pipeline: L{Pipeline}.
@param position: Optional position to seek to initially.
"""
self._disconnectFromPipeline()
self.debug("New pipeline: %r", pipeline)
self.pipeline = pipeline
self.pipeline.pause()
self.seeker.seek(position)
self.pipeline.connect("state-change", self._pipelineStateChangedCb)
self.pipeline.connect("position", self._positionCb)
self.pipeline.connect("duration-changed", self._durationChangedCb)
self._switch_output_window()
self._setUiActive()
def _disconnectFromPipeline(self):
self.debug("Previous pipeline: %r", self.pipeline)
if self.pipeline is None:
# silently return, there's nothing to disconnect from
return
self.pipeline.disconnect_by_func(self._pipelineStateChangedCb)
self.pipeline.disconnect_by_func(self._positionCb)
self.pipeline.disconnect_by_func(self._durationChangedCb)
self.pipeline = None
def _setUiActive(self, active=True):
self.debug("active %r", active)
self.set_sensitive(active)
if self._haveUI:
for item in [self.goToStart_button, self.back_button,
self.playpause_button, self.forward_button,
self.goToEnd_button, self.timecode_entry]:
item.set_sensitive(active)
if active:
self.emit("activate-playback-controls", True)
def _externalWindowDeleteCb(self, unused_window, unused_event):
self.dock()
return True
def _externalWindowConfigureCb(self, unused_window, event):
self.settings.viewerWidth = event.width
self.settings.viewerHeight = event.height
#.........这里部分代码省略.........
示例6: ScaleRuler
# 需要导入模块: from pitivi.utils.pipeline import Seeker [as 别名]
# 或者: from pitivi.utils.pipeline.Seeker import seek [as 别名]
class ScaleRuler(gtk.DrawingArea, Zoomable, Loggable):
__gsignals__ = {
"expose-event": "override",
"button-press-event": "override",
"button-release-event": "override",
"motion-notify-event": "override",
"scroll-event": "override",
"seek": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
[gobject.TYPE_UINT64])
}
border = 0
min_tick_spacing = 3
scale = [0, 0, 0, 0.5, 1, 2, 5, 10, 15, 30, 60, 120, 300, 600, 3600]
subdivide = ((1, 1.0), (2, 0.5), (10, .25))
def __init__(self, instance, hadj):
gtk.DrawingArea.__init__(self)
Zoomable.__init__(self)
Loggable.__init__(self)
self.log("Creating new ScaleRuler")
self.app = instance
self._seeker = Seeker()
self.hadj = hadj
hadj.connect("value-changed", self._hadjValueChangedCb)
self.add_events(gtk.gdk.POINTER_MOTION_MASK |
gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK)
self.pixbuf = None
# all values are in pixels
self.pixbuf_offset = 0
self.pixbuf_offset_painted = 0
# This is the number of width we allocate for the pixbuf
self.pixbuf_multiples = 4
self.position = 0 # In nanoseconds
self.pressed = False
self.need_update = True
self.min_frame_spacing = 5.0
self.frame_height = 5.0
self.frame_rate = gst.Fraction(1 / 1)
def _hadjValueChangedCb(self, hadj):
self.pixbuf_offset = self.hadj.get_value()
self.queue_draw()
## Zoomable interface override
def zoomChanged(self):
self.need_update = True
self.queue_draw()
## timeline position changed method
def timelinePositionChanged(self, value, unused_frame=None):
self.position = value
self.queue_draw()
## gtk.Widget overrides
def do_expose_event(self, event):
self.log("exposing ScaleRuler %s", list(event.area))
x, y, width, height = event.area
self.repaintIfNeeded(width, height)
# offset in pixbuf to paint
offset_to_paint = self.pixbuf_offset - self.pixbuf_offset_painted
self.window.draw_pixbuf(
self.style.fg_gc[gtk.STATE_NORMAL],
self.pixbuf,
int(offset_to_paint), 0,
x, y, width, height,
gtk.gdk.RGB_DITHER_NONE)
# draw the position
context = self.window.cairo_create()
self.drawPosition(context)
return False
def do_button_press_event(self, event):
self.debug("button pressed at x:%d", event.x)
self.pressed = True
position = self.pixelToNs(event.x + self.pixbuf_offset)
self._seeker.seek(position)
return True
def do_button_release_event(self, event):
self.debug("button released at x:%d", event.x)
self.pressed = False
# The distinction between the ruler and timeline canvas is theoretical.
# If the user interacts with the ruler, have the timeline steal focus
# from other widgets. This reactivates keyboard shortcuts for playback.
timeline = self.app.gui.timeline_ui
timeline._canvas.grab_focus(timeline._root_item)
return False
def do_motion_notify_event(self, event):
position = self.pixelToNs(event.x + self.pixbuf_offset)
#.........这里部分代码省略.........