Kivy Tutorials
About Lesson

In this Kivy Tutorial we are going to learn How to Play Video in Kivy, according to Kivy Documentation 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.

 

 

Before starting our coding you need to install these two libraries, if you don’t do this there will be error when you play the video in kivy.

 

 

 

OK now let’s create our coding for How to Play Video in Kivy, this is the complete code.

 

 

OK in the above code, first of all i have imported the required modules from kivy, after that i have created my class the extends from the App class, and i have created the object of my video widget. and there are different attributes that you can use with kivy video widget, also make sure that you have already added a video in your working directory, as i have already added the video.

 

 

  • 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. loaded is a BooleanProperty and defaults to False.
  • options: options to pass at Video core object creation.

 

 

 

Run the complete code and this is the result.

Kivy Tutorial - How to Play Video in Kivy
Kivy Tutorial – How to Play Video in Kivy