本文整理匯總了Python中kivy.core.video.Video.play方法的典型用法代碼示例。如果您正苦於以下問題:Python Video.play方法的具體用法?Python Video.play怎麽用?Python Video.play使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類kivy.core.video.Video
的用法示例。
在下文中一共展示了Video.play方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Video
# 需要導入模塊: from kivy.core.video import Video [as 別名]
# 或者: from kivy.core.video.Video import play [as 別名]
class Video(Image):
'''Video class. See module documentation for more information.
'''
play = BooleanProperty(False)
'''Boolean, indicates if the video is playing.
You can start/stop the video by setting this property. ::
# start playing the video at creation
video = Video(source='movie.mkv', play=True)
# create the video, and start later
video = Video(source='movie.mkv')
# and later
video.play = True
:data:`play` is a :class:`~kivy.properties.BooleanProperty`, default to
False.
'''
eos = BooleanProperty(False)
'''Boolean, indicates if the video is done playing (reached end of stream).
:data:`eos` is a :class:`~kivy.properties.BooleanProperty`, default to
False.
'''
position = NumericProperty(-1)
'''Position of the video between 0 and :data:`duration`. The position is
default to -1, and set to real position when the video is loaded.
:data:`position` is a :class:`~kivy.properties.NumericProperty`, default to
-1.
'''
duration = NumericProperty(-1)
'''Duration of the video. The duration is default to -1, and set to real
duration when the video is loaded.
:data:`duration` is a :class:`~kivy.properties.NumericProperty`, default to
-1.
'''
volume = NumericProperty(1.)
'''Volume of the video, in the range 0-1. 1 mean full volume, 0 mean mute.
:data:`volume` is a :class:`~kivy.properties.NumericProperty`, default to
1.
'''
options = ObjectProperty({})
'''Options to pass at Video core object creation.
.. versionadded:: 1.0.4
:data:`options` is a :class:`kivy.properties.ObjectProperty`, default to {}.
'''
def __init__(self, **kwargs):
self._video = None
super(Video, self).__init__(**kwargs)
def texture_update(self, *largs):
'''This method is a no-op in Video widget.
'''
pass
def seek(self, percent):
'''Change the position to a percentage of duration. Percentage must be a
value between 0-1.
.. warning::
Calling seek() before video is loaded have no impact.
.. versionadded:: 1.1.2
'''
if self._video is None:
raise Exception('Video not loaded.')
print 'seek to', percent
self._video.seek(percent)
def on_source(self, instance, value):
self._trigger_video_load()
def _trigger_video_load(self, *largs):
Clock.unschedule(self._do_video_load)
Clock.schedule_once(self._do_video_load, -1)
def _do_video_load(self, *largs):
if self._video:
self._video.stop()
if not self.source:
self._video = None
self.texture = None
else:
filename = self.source
# FIXME make it extensible.
if filename.split(':')[0] not in (
'http', 'https', 'file', 'udp', 'rtp', 'rtsp'):
#.........這裏部分代碼省略.........
示例2: Video
# 需要導入模塊: from kivy.core.video import Video [as 別名]
# 或者: from kivy.core.video.Video import play [as 別名]
class Video(Image):
'''Video class. See module documentation for more information.
'''
state = OptionProperty('stop', options=('play', 'pause', 'stop'))
'''String, indicates whether to play, pause, or stop the video::
# start playing the video at creation
video = Video(source='movie.mkv', state='play')
# create the video, and start later
video = Video(source='movie.mkv')
# and later
video.state = 'play'
:attr:`state` is an :class:`~kivy.properties.OptionProperty` and defaults
to 'stop'.
'''
play = BooleanProperty(False)
'''
.. deprecated:: 1.4.0
Use :attr:`state` instead.
Boolean, indicates whether the video is playing or not.
You can start/stop the video by setting this property::
# start playing the video at creation
video = Video(source='movie.mkv', play=True)
# create the video, and start later
video = Video(source='movie.mkv')
# and later
video.play = True
:attr:`play` is a :class:`~kivy.properties.BooleanProperty` and defaults to
False.
.. deprecated:: 1.4.0
Use :attr:`state` instead.
'''
eos = BooleanProperty(False)
'''Boolean, indicates whether the video has finished playing or not
(reached the end of the stream).
:attr:`eos` is a :class:`~kivy.properties.BooleanProperty` and defaults to
False.
'''
loaded = BooleanProperty(False)
'''Boolean, indicates whether the video is loaded and ready for playback
or not.
.. versionadded:: 1.6.0
:attr:`loaded` is a :class:`~kivy.properties.BooleanProperty` and defaults
to False.
'''
position = NumericProperty(-1)
'''Position of the video between 0 and :attr:`duration`. The position
defaults to -1 and is set to a real position when the video is loaded.
:attr:`position` is a :class:`~kivy.properties.NumericProperty` and
defaults to -1.
'''
duration = NumericProperty(-1)
'''Duration of the video. The duration defaults to -1, and is set to a real
duration when the video is loaded.
:attr:`duration` is a :class:`~kivy.properties.NumericProperty` and
defaults to -1.
'''
volume = NumericProperty(1.)
'''Volume of the video, in the range 0-1. 1 means full volume, 0
means mute.
:attr:`volume` is a :class:`~kivy.properties.NumericProperty` and defaults
to 1.
'''
options = ObjectProperty({})
'''Options to pass at Video core object creation.
.. versionadded:: 1.0.4
:attr:`options` is an :class:`kivy.properties.ObjectProperty` and defaults
to {}.
'''
_video_load_event = None
def __init__(self, **kwargs):
self._video = None
super(Video, self).__init__(**kwargs)
self.fbind('source', self._trigger_video_load)
#.........這裏部分代碼省略.........
示例3: Video
# 需要導入模塊: from kivy.core.video import Video [as 別名]
# 或者: from kivy.core.video.Video import play [as 別名]
class Video(Image):
'''Video class. See module documentation for more information.
'''
state = OptionProperty('stop', options=('play', 'pause', 'stop'))
'''String, indicates whether to play, pause, or stop the video::
# start playing the video at creation
video = Video(source='movie.mkv', state='play')
# create the video, and start later
video = Video(source='movie.mkv')
# and later
video.state = 'play'
:data:`state` is a :class:`~kivy.properties.OptionProperty`, default to
'play'.
'''
play = BooleanProperty(False)
'''
.. deprecated:: 1.4.0
Use :data:`state` instead.
Boolean, indicates if the video is playing.
You can start/stop the video by setting this property::
# start playing the video at creation
video = Video(source='movie.mkv', play=True)
# create the video, and start later
video = Video(source='movie.mkv')
# and later
video.play = True
:data:`play` is a :class:`~kivy.properties.BooleanProperty`, default to
False.
.. deprecated:: 1.4.0
Use :data:`state` instead.
'''
eos = BooleanProperty(False)
'''Boolean, indicates if the video is done playing (reached end of stream).
:data:`eos` is a :class:`~kivy.properties.BooleanProperty`, default to
False.
'''
loaded = BooleanProperty(False)
'''Boolean, indicates if the video is loaded and ready for playback.
.. versionadded:: 1.6.0
:data:`loaded` is a :class:`~kivy.properties.BooleanProperty`, default to
False.
'''
position = NumericProperty(-1)
'''Position of the video between 0 and :data:`duration`. The position
defaults to -1, and is set to a real position when the video is loaded.
:data:`position` is a :class:`~kivy.properties.NumericProperty`, default to
-1.
'''
duration = NumericProperty(-1)
'''Duration of the video. The duration defaults to -1, and is set to a real
duration when the video is loaded.
:data:`duration` is a :class:`~kivy.properties.NumericProperty`, default to
-1.
'''
volume = NumericProperty(1.)
'''Volume of the video, in the range 0-1. 1 means full volume, 0 means mute.
:data:`volume` is a :class:`~kivy.properties.NumericProperty`, default to
1.
'''
options = ObjectProperty({})
'''Options to pass at Video core object creation.
.. versionadded:: 1.0.4
:data:`options` is a :class:`kivy.properties.ObjectProperty`, default to {}.
'''
def __init__(self, **kwargs):
self._video = None
super(Image, self).__init__(**kwargs)
self.bind(source=self._trigger_video_load)
if self.source:
self._trigger_video_load()
def seek(self, percent):
'''Change the position to a percentage of duration. Percentage must be a
value between 0-1.
#.........這裏部分代碼省略.........
示例4: Video
# 需要導入模塊: from kivy.core.video import Video [as 別名]
# 或者: from kivy.core.video.Video import play [as 別名]
class Video(Image):
'''Video class. See module documentation for more informations.
'''
play = BooleanProperty(False)
'''Boolean indicate if the video is playing.
You can start/stop the video by setting this property. ::
# start the video playing at creation
video = Video(source='movie.mkv', play=True)
# create the video, and start later
video = Video(source='movie.mkv')
# and later
video.play = True
:data:`play` is a :class:`~kivy.properties.BooleanProperty`, default to
False.
'''
eos = BooleanProperty(False)
'''Boolean indicate if the video is done playing through the end.
:data:`eos` is a :class:`~kivy.properties.BooleanProperty`, default to
False.
'''
position = NumericProperty(-1)
'''Position of the video between 0 and :data:`duration`. The position is
default to -1, and set to real position when the video is loaded.
:data:`position` is a :class:`~kivy.properties.NumericProperty`, default to
-1.
'''
duration = NumericProperty(-1)
'''Duration of the video. The duration is default to -1, and set to real
duration when the video is loaded.
:data:`duration` is a :class:`~kivy.properties.NumericProperty`, default to
-1.
'''
volume = NumericProperty(1.)
'''Volume of the video, in the range 0-1. 1 mean full volume, 0 mean mute.
:data:`volume` is a :class:`~kivy.properties.NumericProperty`, default to
1.
'''
options = ObjectProperty({})
'''Options to pass at Video core object creation.
.. versionadded:: 1.0.4
:data:`options` is a :class:`kivy.properties.ObjectProperty`, default to {}.
'''
def __init__(self, **kwargs):
self._video = None
super(Video, self).__init__(**kwargs)
def texture_update(self, *largs):
pass
def on_source(self, instance, value):
self._trigger_video_load()
def _trigger_video_load(self, *largs):
Clock.unschedule(self._do_video_load)
Clock.schedule_once(self._do_video_load, -1)
def _do_video_load(self, *largs):
if self._video:
self._video.stop()
if not self.source:
self._video = None
self.texture = None
else:
filename = resource_find(self.source)
self._video = CoreVideo(filename=filename, **self.options)
self._video.bind(
on_load=self._on_video_frame,
on_frame=self._on_video_frame,
on_eos=self._on_eos)
if self.play:
self._video.play()
self.duration = 1.
self.position = 0.
def on_play(self, instance, value):
if not self._video:
return
if value:
if self.eos:
self._video.stop()
self._video.position = 0.
self._video.eos = False
self._video.play()
else:
#.........這裏部分代碼省略.........
示例5: Video
# 需要導入模塊: from kivy.core.video import Video [as 別名]
# 或者: from kivy.core.video.Video import play [as 別名]
class Video(Image):
'''Video class. See module documentation for more informations.
'''
play = BooleanProperty(False)
'''Boolean indicate if the video is playing.
You can start/stop the video by setting this property. ::
# start the video playing at creation
video = Video(source='movie.mkv', play=True)
# create the video, and start later
video = Video(source='movie.mkv')
# and later
video.play = True
:data:`play` is a :class:`~kivy.properties.BooleanProperty`, default to
False.
'''
position = NumericProperty(-1)
'''Position of the video between 0 and :data:`duration`. The position is
default to -1, and set to real position when the video is loaded.
:data:`position` is a :class:`~kivy.properties.NumericProperty`, default to
-1.
'''
duration = NumericProperty(-1)
'''Duration of the video. The duration is default to -1, and set to real
duration when the video is loaded.
:data:`duration` is a :class:`~kivy.properties.NumericProperty`, default to
-1.
'''
volume = NumericProperty(1.)
'''Volume of the video, in the range 0-1. 1 mean full volume, 0 mean mute.
:data:`volume` is a :class:`~kivy.properties.NumericProperty`, default to
1.
'''
def __init__(self, **kwargs):
self._video = None
super(Video, self).__init__(**kwargs)
def on_source(self, instance, value):
if not value:
self._video = None
self.texture = None
else:
filename = resource_find(value)
self._video = CoreVideo(filename=filename)
self._video.bind(on_load=self._on_video_frame,
on_frame=self._on_video_frame)
if self.play:
self._video.play()
self.duration = 1.
self.position = 0.
def on_play(self, instance, value):
if not self._video:
return
if value:
self._video.play()
else:
self._video.stop()
def _on_video_frame(self, *largs):
self.duration = self._video.duration
self.position = self._video.position
self.texture = self._video.texture
示例6: Video
# 需要導入模塊: from kivy.core.video import Video [as 別名]
# 或者: from kivy.core.video.Video import play [as 別名]
class Video(Image):
"""Video class. See module documentation for more information.
"""
play = BooleanProperty(False)
"""Boolean, indicates if the video is playing.
You can start/stop the video by setting this property. ::
# start playing the video at creation
video = Video(source='movie.mkv', play=True)
# create the video, and start later
video = Video(source='movie.mkv')
# and later
video.play = True
:data:`play` is a :class:`~kivy.properties.BooleanProperty`, default to
False.
"""
eos = BooleanProperty(False)
"""Boolean, indicates if the video is done playing (reached end of stream).
:data:`eos` is a :class:`~kivy.properties.BooleanProperty`, default to
False.
"""
position = NumericProperty(-1)
"""Position of the video between 0 and :data:`duration`. The position is
default to -1, and set to real position when the video is loaded.
:data:`position` is a :class:`~kivy.properties.NumericProperty`, default to
-1.
"""
duration = NumericProperty(-1)
"""Duration of the video. The duration is default to -1, and set to real
duration when the video is loaded.
:data:`duration` is a :class:`~kivy.properties.NumericProperty`, default to
-1.
"""
volume = NumericProperty(1.0)
"""Volume of the video, in the range 0-1. 1 mean full volume, 0 mean mute.
:data:`volume` is a :class:`~kivy.properties.NumericProperty`, default to
1.
"""
options = ObjectProperty({})
"""Options to pass at Video core object creation.
.. versionadded:: 1.0.4
:data:`options` is a :class:`kivy.properties.ObjectProperty`, default to {}.
"""
def __init__(self, **kwargs):
self._video = None
super(Video, self).__init__(**kwargs)
def texture_update(self, *largs):
"""This method is a no-op in Video widget.
"""
pass
def on_source(self, instance, value):
self._trigger_video_load()
def _trigger_video_load(self, *largs):
Clock.unschedule(self._do_video_load)
Clock.schedule_once(self._do_video_load, -1)
def _do_video_load(self, *largs):
if self._video:
self._video.stop()
if not self.source:
self._video = None
self.texture = None
else:
filename = self.source
# FIXME make it extensible.
if filename.split(":")[0] not in ("http", "https", "file", "udp", "rtp", "rtsp"):
filename = resource_find(filename)
self._video = CoreVideo(filename=filename, **self.options)
self._video.bind(on_load=self._on_video_frame, on_frame=self._on_video_frame, on_eos=self._on_eos)
if self.play:
self._video.play()
self.duration = 1.0
self.position = 0.0
def on_play(self, instance, value):
if not self._video:
return
if value:
if self.eos:
self._video.stop()
self._video.position = 0.0
self._video.eos = False
#.........這裏部分代碼省略.........