Using the videoplayer widget in a kivy app

videoplayer widget from kivy.uix.videoplayer is a composite widget and enables playing of video from multiple sources.Options to customize the player are available.

Kivy Updated 3 May 2017 1 min read

Overview

  • Kivy has a video player widget which is a composite widget, derived from gridlayout class of Kivy.
  • The class VideoPlayer has several attributes that can customise the the videoplayer. They include options for
    • Controlling the fullscreen view
    • Initial state of the video. The video could be in playing state or paused state or in stopped state.
    • Setting the position in the timeline of video, setting the volume of the video
    • Annotations for the video
    • Thumbnail of the video

Example

python
import kivy

kivy.require('1.9.1') # the kivy version required

# import the kivy modules/widgets

from kivy.app import App

from kivy.uix.widget import Widget

from kivy.uix.gridlayout import GridLayout

from kivy.uix.videoplayer import VideoPlayer

# An App running a video file

class MyVideoApp(App):

            def build(self):

                        self.player                   = VideoPlayer(source='/users/vinodh/downloads/Sintel_DivXPlus_6500kbps.mkv',  state='play', options={'allow_stretch': True})

                        return (self.player)

# Start the Video App

if __name__ == '__main__':

            MyVideoApp().run()

Output

Kivy -videoplayer output