Using The Videoplayer Widget In A Kivy App

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:

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:

 


Copyright 2019 © pythontic.com