Book Image

Kivy Cookbook

By : Hugo Solis
Book Image

Kivy Cookbook

By: Hugo Solis

Overview of this book

Table of Contents (16 chapters)
Kivy Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Working with video


The video reproduction is a useful tool for any app. In this app, we will load a widget to reproduce a video file in our app.

Getting ready

It is necessary to have a video file in the usual format to be reproduced in our app (.avi, .mov, .mpg, .mp4, .flv, .wmv, .ogg). If you do not have one, you can visit https://commons.wikimedia.org/wiki/Main_Page to get free media.

How to do it…

In this recipe, we are going to use a simple Python file to create our app within a player widget. To complete the task, follow these:

  1. Import the usual kivy packages.

  2. Import the VideoPlayer package.

  3. Define the MyW() class.

  4. Define the __init__() method.

  5. Define videoplayer with your video.

  6. Add the video player to the app.

    import kivy
    kivy.require('1.9.0')
    from kivy.app import App
    from kivy.uix.widget import Widget
    from kivy.uix.videoplayer import VideoPlayer
    
    class MyW(Widget):
    
        def __init__(self, **kwargs):
            super(MyW, self).__init__(**kwargs)
            player= VideoPlayer( source='GOR.MOV',state...