Version

Quick search

Video

The Video widget is used to display video files and streams. Depending on your Video core provider, platform, and plugins, you will be able to play different formats. For example, the pygame video provider only supports MPEG1 on Linux and OSX. GStreamer is more versatile, and can read many video containers and codecs such as MKV, OGV, AVI, MOV, FLV (if the correct gstreamer plugins are installed). Our VideoBase implementation is used under the hood.

Video loading is asynchronous - many properties are not available until the video is loaded (when the texture is created):

def on_position_change(instance, value):
    print('The position in the video is', value)

def on_duration_change(instance, value):
    print('The duration of the video is', value)

video = Video(source='PandaSneezes.avi')
video.bind(
    position=on_position_change,
    duration=on_duration_change
)

One can define a preview image which gets displayed until the video is started/loaded by passing preview to the constructor:

video = Video(
    source='PandaSneezes.avi',
    preview='PandaSneezes_preview.png'
)

One can display the placeholder image when the video stops by reacting on eos:

def on_eos_change(self, inst, val):
    if val and self.preview:
        self.set_texture_from_resource(self.preview)

video.bind(eos=on_eos_change)
class kivy.uix.video.Video(**kwargs)[source]

Bases: kivy.uix.image.Image

Video class. See module documentation for more information.

duration

Duration of the video. The duration defaults to -1, and is set to a real duration when the video is loaded.

duration is a NumericProperty and defaults to -1.

eos

Boolean, indicates whether the video has finished playing or not (reached the end of the stream).

eos is a BooleanProperty and defaults to False.

loaded

Boolean, indicates whether the video is loaded and ready for playback or not.

New in version 1.6.0.

loaded is a BooleanProperty and defaults to False.

options

Options to pass at Video core object creation.

New in version 1.0.4.

options is an kivy.properties.ObjectProperty and defaults to {}.

play

Deprecated since version 1.4.0: Use 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

play is a BooleanProperty and defaults to False.

Deprecated since version 1.4.0: Use state instead.

position

Position of the video between 0 and duration. The position defaults to -1 and is set to a real position when the video is loaded.

position is a NumericProperty and defaults to -1.

preview

Filename / source of a preview image displayed before video starts.

preview is a StringProperty and defaults to None.

If set, it gets displayed until the video is loaded/started.

New in version 2.1.0.

seek(percent, precise=True)[source]
Change the position to a percentage (strictly, a proportion)

of duration.

Parameters:
percent: float or int

Position to seek as a proportion of the total duration, must be between 0-1.

precise: bool, defaults to True

Precise seeking is slower, but seeks to exact requested percent.

Warning

Calling seek() before the video is loaded has no effect.

New in version 1.2.0.

Changed in version 1.10.1: The precise keyword argument has been added.

state

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'

state is an OptionProperty and defaults to ‘stop’.

unload()[source]

Unload the video. The playback will be stopped.

New in version 1.8.0.

volume

Volume of the video, in the range 0-1. 1 means full volume, 0 means mute.

volume is a NumericProperty and defaults to 1.