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:
Import the usual
kivy
packages.Import the
VideoPlayer
package.Define the
MyW()
class.Define the
__init__()
method.Define
videoplayer
with your video.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...