本文整理汇总了Python中pitivi.timeline.timeline.Timeline.addTimelineObject方法的典型用法代码示例。如果您正苦于以下问题:Python Timeline.addTimelineObject方法的具体用法?Python Timeline.addTimelineObject怎么用?Python Timeline.addTimelineObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pitivi.timeline.timeline.Timeline
的用法示例。
在下文中一共展示了Timeline.addTimelineObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testConnectionAndDisconnection
# 需要导入模块: from pitivi.timeline.timeline import Timeline [as 别名]
# 或者: from pitivi.timeline.timeline.Timeline import addTimelineObject [as 别名]
def testConnectionAndDisconnection(self):
timeline = Timeline()
stream = new_stream()
factory = new_source_factory()
track = Track(stream)
track_object1 = SourceTrackObject(factory, stream)
track.addTrackObject(track_object1)
timeline.addTrack(track)
timeline_object1 = TimelineObject(factory)
timeline_object1.addTrackObject(track_object1)
timeline.addTimelineObject(timeline_object1)
self.observer.startObserving(timeline)
self.failUnless(timeline.connected)
self.failUnless(timeline_object1.connected)
timeline.removeTimelineObject(timeline_object1)
self.failIf(timeline_object1.connected)
timeline.addTimelineObject(timeline_object1)
self.failUnless(timeline_object1)
self.observer.stopObserving(timeline)
self.failIf(timeline.connected)
self.failIf(timeline_object1.connected)
示例2: TestTimelineUndo
# 需要导入模块: from pitivi.timeline.timeline import Timeline [as 别名]
# 或者: from pitivi.timeline.timeline.Timeline import addTimelineObject [as 别名]
class TestTimelineUndo(TestCase):
def setUp(self):
self.stream = new_stream()
self.factory = new_source_factory()
self.effect_factory = TestEffectFactory(self.stream)
self.track1 = Track(self.stream)
self.track2 = Track(self.stream)
self.timeline = Timeline()
self.timeline.addTrack(self.track1)
self.timeline.addTrack(self.track2)
self.track_object1 = SourceTrackObject(self.factory, self.stream)
self.track_object2 = SourceTrackObject(self.factory, self.stream)
self.track_effect1 = TrackEffect(self.effect_factory, self.stream)
self.track_effect2 = TrackEffect(self.effect_factory, self.stream)
self.track1.addTrackObject(self.track_object1)
self.track2.addTrackObject(self.track_object2)
self.timeline_object1 = TimelineObject(self.factory)
self.timeline_object1.addTrackObject(self.track_object1)
self.timeline_object1.addTrackObject(self.track_object2)
self.action_log = UndoableActionLog()
self.observer = TestTimelineLogObserver(self.action_log)
self.observer.startObserving(self.timeline)
def testAddTimelineObject(self):
stacks = []
def commitCb(action_log, stack, nested):
stacks.append(stack)
self.action_log.connect("commit", commitCb)
self.action_log.begin("add clip")
self.timeline.addTimelineObject(self.timeline_object1)
self.action_log.commit()
self.failUnlessEqual(len(stacks), 1)
stack = stacks[0]
self.failUnlessEqual(len(stack.done_actions), 1)
action = stack.done_actions[0]
self.failUnless(isinstance(action, TimelineObjectAdded))
self.failUnless(self.timeline_object1 \
in self.timeline.timeline_objects)
self.action_log.undo()
self.failIf(self.timeline_object1 \
in self.timeline.timeline_objects)
self.action_log.redo()
self.failUnless(self.timeline_object1 \
in self.timeline.timeline_objects)
def testRemoveTimelineObject(self):
stacks = []
def commitCb(action_log, stack, nested):
stacks.append(stack)
self.action_log.connect("commit", commitCb)
self.timeline.addTimelineObject(self.timeline_object1)
self.action_log.begin("remove clip")
self.timeline.removeTimelineObject(self.timeline_object1, deep=True)
self.action_log.commit()
self.failUnlessEqual(len(stacks), 1)
stack = stacks[0]
self.failUnlessEqual(len(stack.done_actions), 1)
action = stack.done_actions[0]
self.failUnless(isinstance(action, TimelineObjectRemoved))
self.failIf(self.timeline_object1 \
in self.timeline.timeline_objects)
self.action_log.undo()
self.failUnless(self.timeline_object1 \
in self.timeline.timeline_objects)
self.action_log.redo()
self.failIf(self.timeline_object1 \
in self.timeline.timeline_objects)
def testAddEffectToTimelineObject(self):
stacks = []
pipeline = Pipeline()
def commitCb(action_log, stack, nested):
stacks.append(stack)
self.action_log.connect("commit", commitCb)
self.observer.pipeline = pipeline
#FIXME Should I commit it and check there are 2 elements
#in the stacks
self.timeline.addTimelineObject(self.timeline_object1)
self.track1.addTrackObject(self.track_effect1)
self.action_log.begin("add effect")
self.timeline_object1.addTrackObject(self.track_effect1)
self.action_log.commit()
self.failUnlessEqual(len(stacks), 1)
stack = stacks[0]
self.failUnlessEqual(len(stack.done_actions), 1)
action = stack.done_actions[0]
#.........这里部分代码省略.........
示例3: TestGap
# 需要导入模块: from pitivi.timeline.timeline import Timeline [as 别名]
# 或者: from pitivi.timeline.timeline.Timeline import addTimelineObject [as 别名]
class TestGap(TestCase):
def setUp(self):
self.factory = StubFactory()
self.stream = AudioStream(gst.Caps('audio/x-raw-int'))
self.factory.addOutputStream(self.stream)
self.track1 = Track(self.stream)
self.timeline = Timeline()
def makeTimelineObject(self):
track_object = SourceTrackObject(self.factory, self.stream)
self.track1.addTrackObject(track_object)
timeline_object = TimelineObject(self.factory)
timeline_object.addTrackObject(track_object)
self.timeline.addTimelineObject(timeline_object)
return timeline_object
def testGapCmp(self):
gap1 = Gap(None, None, start=10, duration=5)
gap2 = Gap(None, None, start=10, duration=5)
self.failUnlessEqual(gap1, gap2)
gap2 = Gap(None, None, start=15, duration=4)
self.failUnless(gap1 > gap2)
self.failUnless(gap2 < gap1)
def testFindAroundObject(self):
timeline_object1 = self.makeTimelineObject()
timeline_object2 = self.makeTimelineObject()
timeline_object1.start = 5 * gst.SECOND
timeline_object1.duration = 10 * gst.SECOND
timeline_object2.start = 20 * gst.SECOND
timeline_object2.duration = 10 * gst.SECOND
left_gap, right_gap = Gap.findAroundObject(timeline_object1)
self.failUnlessEqual(left_gap.left_object, None)
self.failUnlessEqual(left_gap.right_object, timeline_object1)
self.failUnlessEqual(left_gap.start, 0 * gst.SECOND)
self.failUnlessEqual(left_gap.duration, 5 * gst.SECOND)
self.failUnlessEqual(right_gap.left_object, timeline_object1)
self.failUnlessEqual(right_gap.right_object, timeline_object2)
self.failUnlessEqual(right_gap.start, 15 * gst.SECOND)
self.failUnlessEqual(right_gap.duration, 5 * gst.SECOND)
left_gap, right_gap = Gap.findAroundObject(timeline_object2)
self.failUnlessEqual(left_gap.left_object, timeline_object1)
self.failUnlessEqual(left_gap.right_object, timeline_object2)
self.failUnlessEqual(left_gap.start, 15 * gst.SECOND)
self.failUnlessEqual(left_gap.duration, 5 * gst.SECOND)
self.failUnlessEqual(right_gap.left_object, timeline_object2)
self.failUnlessEqual(right_gap.right_object, None)
self.failUnlessEqual(right_gap.start, 30 * gst.SECOND)
self.failUnlessEqual(right_gap.duration, infinity)
# make the objects overlap
timeline_object2.start = 10 * gst.SECOND
left_gap, right_gap = Gap.findAroundObject(timeline_object1)
self.failUnlessEqual(right_gap.left_object, timeline_object1)
self.failUnlessEqual(right_gap.right_object, timeline_object2)
self.failUnlessEqual(right_gap.start, 15 * gst.SECOND)
self.failUnlessEqual(right_gap.duration, -5 * gst.SECOND)
def testGapFinder(self):
timeline_object1 = self.makeTimelineObject()
timeline_object2 = self.makeTimelineObject()
timeline_object3 = self.makeTimelineObject()
timeline_object4 = self.makeTimelineObject()
timeline_object1.start = 5 * gst.SECOND
timeline_object1.duration = 10 * gst.SECOND
timeline_object1.priority = 1
timeline_object2.start = 20 * gst.SECOND
timeline_object2.duration = 10 * gst.SECOND
timeline_object2.priority = 1
timeline_object3.start = 31 * gst.SECOND
timeline_object3.duration = 10 * gst.SECOND
timeline_object3.priority = 2
timeline_object4.start = 50 * gst.SECOND
timeline_object4.duration = 10 * gst.SECOND
timeline_object4.priority = 2
gap_finder = SmallestGapsFinder(set([timeline_object2,
timeline_object3]))
gap_finder.update(*Gap.findAroundObject(timeline_object2))
gap_finder.update(*Gap.findAroundObject(timeline_object3))
left_gap = gap_finder.left_gap
right_gap = gap_finder.right_gap
self.failUnlessEqual(left_gap.left_object, timeline_object1)
self.failUnlessEqual(left_gap.right_object, timeline_object2)
self.failUnlessEqual(left_gap.start, 15 * gst.SECOND)
self.failUnlessEqual(left_gap.duration, 5 * gst.SECOND)
self.failUnlessEqual(right_gap.left_object, timeline_object3)
self.failUnlessEqual(right_gap.right_object, timeline_object4)
self.failUnlessEqual(right_gap.start, 41 * gst.SECOND)
self.failUnlessEqual(right_gap.duration, 9 * gst.SECOND)
#.........这里部分代码省略.........