本文整理汇总了Python中kivy.uix.video.Video.seek方法的典型用法代码示例。如果您正苦于以下问题:Python Video.seek方法的具体用法?Python Video.seek怎么用?Python Video.seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.video.Video
的用法示例。
在下文中一共展示了Video.seek方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: VideoPlayer
# 需要导入模块: from kivy.uix.video import Video [as 别名]
# 或者: from kivy.uix.video.Video import seek [as 别名]
#.........这里部分代码省略.........
def _do_video_load(self, *largs):
self._video = Video(source=self.source, state=self.state,
volume=self.volume, pos_hint={'x': 0, 'y': 0},
**self.options)
self._video.bind(texture=self._play_started,
duration=self.setter('duration'),
position=self.setter('position'),
volume=self.setter('volume'),
state=self._set_state)
def on_play(self, instance, value):
value = 'play' if value else 'stop'
return self.on_state(instance, value)
def on_volume(self, instance, value):
if not self._video:
return
self._video.volume = value
def on_position(self, instance, value):
labels = self._annotations_labels
if not labels:
return
for label in labels:
start = label.start
duration = label.duration
if start > value or (start + duration) < value:
if label.parent:
label.parent.remove_widget(label)
elif label.parent is None:
self.container.add_widget(label)
def seek(self, percent):
'''Change the position to a percentage of the duration. Percentage must
be a value between 0-1.
.. warning::
Calling seek() before video is loaded has no effect.
'''
if not self._video:
return
self._video.seek(percent)
def _play_started(self, instance, value):
self.container.clear_widgets()
self.container.add_widget(self._video)
def on_touch_down(self, touch):
if not self.collide_point(*touch.pos):
return False
if touch.is_double_tap and self.allow_fullscreen:
self.fullscreen = not self.fullscreen
return True
return super(VideoPlayer, self).on_touch_down(touch)
def on_fullscreen(self, instance, value):
window = self.get_parent_window()
if not window:
Logger.warning('VideoPlayer: Cannot switch to fullscreen, '
'window not found.')
if value:
self.fullscreen = False
return
if not self.parent: